bunqueue-dashboard 1.0.1 → 1.0.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.
Files changed (39) hide show
  1. package/README.md +5 -3
  2. package/agent/backup/routes.ts +20 -12
  3. package/agent/server/router.ts +5 -1
  4. package/dist/.vite/manifest.json +31 -31
  5. package/dist/assets/{Alerts-DzKKoA9U.js → Alerts-DCKl_C8D.js} +1 -1
  6. package/dist/assets/{Benchmark-CHYDL31K.js → Benchmark-DyHvEM8x.js} +1 -1
  7. package/dist/assets/{Database-BoxVpjts.js → Database-BBzyi7f0.js} +1 -1
  8. package/dist/assets/{Diagnostics-B3QSQuFF.js → Diagnostics-E_icHggb.js} +1 -1
  9. package/dist/assets/{Dlq-DHOfgORa.js → Dlq-DNs32CzV.js} +1 -1
  10. package/dist/assets/{DlqControl-BY1e55-x.js → DlqControl-DawwIsTI.js} +1 -1
  11. package/dist/assets/{DlqPro-CfwKDcpc.js → DlqPro-BEdxFiNN.js} +1 -1
  12. package/dist/assets/{Flows-CDCQrPit.js → Flows-DKZxI7ta.js} +1 -1
  13. package/dist/assets/{JobInspector-Bw3Gs1Iy.js → JobInspector-BARE52q3.js} +1 -1
  14. package/dist/assets/{Jobs-IrlneOy6.js → Jobs-CKzKpQ7i.js} +1 -1
  15. package/dist/assets/{JobsPro-vlPd6Ows.js → JobsPro-DxDw-akG.js} +1 -1
  16. package/dist/assets/{Logs-DG7cK-tF.js → Logs-Bj60G_FP.js} +1 -1
  17. package/dist/assets/{LogsPro-ClSqFKys.js → LogsPro-Hv8xwXDK.js} +1 -1
  18. package/dist/assets/{McpServer-DoNFY0Pj.js → McpServer-zxSMjG8K.js} +1 -1
  19. package/dist/assets/{Metrics-BkePZiCZ.js → Metrics-BBLdWOw1.js} +1 -1
  20. package/dist/assets/{MetricsPro-ooSvpQ3H.js → MetricsPro-D470b1aP.js} +1 -1
  21. package/dist/assets/{Overview-CuWmPRra.js → Overview-B_AOa5kW.js} +1 -1
  22. package/dist/assets/{QueueControl-C01l6bBJ.js → QueueControl-DaZjeZnw.js} +1 -1
  23. package/dist/assets/{QueueDetail-gSf9Tb7G.js → QueueDetail-Dgo9Ukmp.js} +1 -1
  24. package/dist/assets/{QueueDetailPro-BKszqI0M.js → QueueDetailPro-D7U8ahp2.js} +1 -1
  25. package/dist/assets/{Queues-BAg2nSz0.js → Queues-CS8LeZtJ.js} +1 -1
  26. package/dist/assets/{QueuesOverview-BLSjiYsA.js → QueuesOverview-BySSnCm0.js} +1 -1
  27. package/dist/assets/{S3BackupPro-DcjlrzC5.js → S3BackupPro-UwWu0yxr.js} +1 -1
  28. package/dist/assets/{ServerControl-SiZBNo9P.js → ServerControl-Ch1wZcKB.js} +1 -1
  29. package/dist/assets/{Settings-DR_iqW0T.js → Settings-FOzwrB25.js} +1 -1
  30. package/dist/assets/{Usage-ZWfB7PcR.js → Usage-DR90dCt0.js} +1 -1
  31. package/dist/assets/{UsagePro-BjdeS2zb.js → UsagePro-DAlE3oCE.js} +1 -1
  32. package/dist/assets/{Workers-C1h6hCPp.js → Workers-D1Ead02h.js} +1 -1
  33. package/dist/assets/{WorkersPro-B0f_Nfdz.js → WorkersPro-XuLxtU4A.js} +1 -1
  34. package/dist/assets/{index-Bat1DN5U.js → index-DZFZr0Mi.js} +2 -2
  35. package/dist/assets/{index-C9yGKhQ8.css → index-DaEyLvTR.css} +1 -1
  36. package/dist/index.html +2 -2
  37. package/package.json +21 -11
  38. package/scripts/bunVersion.ts +1 -1
  39. package/scripts/embedded.gen.ts +154 -154
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t,g as n,r,t as i}from"./react-vendor-CFL9l8LK.js";import{t as a}from"./bq-DR2BTISO.js";import{t as o}from"./toastStore-XmMX7A5W.js";import{T as s,d as c,f as l,x as u}from"./icons-DH9SS1DA.js";import{r as d,t as f}from"./StatusBadge-DereLzOj.js";import{n as p}from"./usePolledData-CEyyLRYa.js";import{n as m,t as h}from"./Button-_aSJvRoW.js";import{i as g,n as _,r as v}from"./feedback-CtGN_kqB.js";import{t as y}from"./PageHeader-CQzNsw8r.js";import{a as b,c as x,i as S,s as C,t as ee}from"./format-Cg7VCIZW.js";import{r as w}from"./index-Bat1DN5U.js";import{a as T}from"./form-DG3X6cLL.js";import{t as E}from"./Pagination-CSkzhNW6.js";import{r as D,t as O}from"./useServerActionGuard-CUx8TOAC.js";import{t as te}from"./exportFile-C7xhE8Yh.js";import{t as k}from"./flowOperationPolicy-B2Etcb3f.js";var A=e(n(),1),j=i();function ne(e){return(0,j.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4 xl:grid-cols-8`,children:[(0,j.jsx)(w,{label:`Total`,value:e.total,hint:`all queues`,compact:!0}),(0,j.jsx)(w,{label:`Waiting`,value:e.waiting,tone:`amber`,hint:`standard priority`,compact:!0}),(0,j.jsx)(w,{label:`Prioritized`,value:e.prioritized,tone:`amber`,compact:!0}),(0,j.jsx)(w,{label:`Active`,value:e.active,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Flow-blocked`,value:e.flowBlocked,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Completed`,value:e.completed,tone:`green`,compact:!0}),(0,j.jsx)(w,{label:`Failed`,value:e.failed,tone:e.failedCount!=null&&e.failedCount>0?`red`:`default`,compact:!0}),(0,j.jsx)(w,{label:`Error Rate`,value:e.errorRate,tone:e.errorRateTone,compact:!0})]})}var M=[`all`,`waiting`,`prioritized`,`active`,`delayed`,`waiting-children`,`paused`,`completed`,`failed`];function N(e,t){return e===t?`${t} selected`:`${e} of ${t} selected match this filter`}function P(e,t){let n=new Set(e);for(let e of t)n.delete(e);return n}function F(e=0){return e>=10?{text:`HIGH`,className:`text-warning`}:e>=1?{text:`MEDIUM`,className:`text-blue-400`}:{text:`LOW`,className:`text-faint`}}function re({queue:e,rows:t,search:n,discoveryError:i,selected:o,allSelected:s,bulkBusy:c,busyIds:p,page:h,hasNext:g,onToggleAll:_,onToggle:v,onRun:y,onPage:x}){return(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`text-faint`,children:`Jobs in queue`}),(0,j.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-fg`,children:e})]}),(0,j.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,j.jsx)(`th`,{className:`w-10 px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:s,ref:e=>{e&&(e.indeterminate=o.size>0&&!s)},"aria-checked":o.size>0&&!s?`mixed`:s,onChange:_,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Priority`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,j.jsx)(`th`,{className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,j.jsx)(`tbody`,{children:t.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:n.trim()?`No jobs on this page match your ID or name filter.`:e?`No jobs found.`:i?`Queue discovery failed. Retry above.`:`Select a queue.`})}):t.map(e=>{let t=F(e.priority),n=k(e.state),i=c||p.has(e.id);return(0,j.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:o.has(e.id),onChange:()=>v(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,j.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(f,{status:String(e.state??`waiting`)})}),(0,j.jsx)(`td`,{className:d(`px-5 py-3 text-xs font-semibold`,t.className),children:t.text}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:S(e.createdAt)}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,j.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect job ${e.id}`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,j.jsx)(l,{className:`size-3.5`})}),n.promote&&(0,j.jsx)(m,{"aria-label":`Promote job`,disabled:i,onClick:()=>y(e,`Promote`,()=>a.promoteJob(e.id)),children:(0,j.jsx)(u,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,j.jsx)(E,{page:h,pageSize:25,hasNext:g,onPageChange:x,label:`jobs`})]})}function I({queue:e,summary:t,status:n,search:r,selectedTotal:i,selectedVisible:a,canPromote:o,bulkBusy:c,onQueue:l,onStatus:u,onSearch:d,onPromote:f}){return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{value:e,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>l(e.target.value),children:t.map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{"aria-label":`Job state`,name:`jobs-state`,value:n,onChange:e=>u(e.target.value),children:M.map(e=>(0,j.jsx)(`option`,{value:e,children:e===`all`?`All states`:e},e))})}),(0,j.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,j.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,j.jsx)(`input`,{value:r,onChange:e=>d(e.target.value),placeholder:`Filter this page by ID or name…`,"aria-label":`Filter by job ID or name`,name:`jobs-id-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),i>0&&(0,j.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`mr-1 text-muted`,children:N(a,i)}),o?(0,j.jsx)(h,{size:`sm`,disabled:c,onClick:f,children:`Promote selected`}):(0,j.jsx)(`span`,{className:`text-xs text-faint`,children:a===0?`The selected jobs are hidden by the filter — clear it to act on them.`:`No actions apply to the selected job states.`})]})]})}function ie({queue:e,rows:t,selected:n,setSelected:r,refetch:i}){let[a,s]=(0,A.useState)(new Set),[c,l]=(0,A.useState)(!1),[u,d]=(0,A.useState)(null),f=D(`jobs:${e}`);return(0,A.useEffect)(()=>{s(new Set),l(!1),d(null)},[f.scopeKey]),{actionMsg:u,bulkBusy:c,busyIds:a,runBulk:async(e,a,s,c)=>{let u=t.filter(e=>n.has(e.id)&&s(e));if(u.length===0||c&&!window.confirm(c(u.length)))return;let p=f.begin([`bulk`,...u.map(e=>`job:${e.id}`)]);if(p){l(!0),d(null);try{let t=await Promise.allSettled(u.map(async t=>{O(await a(t),`${e} ${t.id}`)}));if(!p.isCurrent())return;let n=t.filter(e=>e.status===`fulfilled`).length,s=t.length-n,c=`${e}: ${n} succeeded${s?`, ${s} failed`:``}`;d({ok:s===0,text:c}),s===0?o.success(c):o.error(c),r(e=>P(e,u.map(e=>e.id))),i()}finally{p.finish()&&l(!1)}}},runOne:async(e,t,n,r)=>{if(r&&!window.confirm(r))return;let a=f.begin(`job:${e.id}`);if(a){s(t=>new Set(t).add(e.id)),d(null);try{if(O(await n(),t),!a.isCurrent())return;d({ok:!0,text:`${t} ✓`}),o.success(`${t} ✓`,e.id),i()}catch(e){if(!a.isCurrent())return;d({ok:!1,text:`${t} failed: ${e.message}`}),o.error(`${t} failed`,e.message)}finally{a.finish()&&s(t=>{let n=new Set(t);return n.delete(e.id),n})}}}}}function L(){let[e,n]=t(),[r,i]=(0,A.useState)(e.get(`queue`)??``),[s,l]=(0,A.useState)(()=>{let t=e.get(`status`);return t&&M.includes(t)?t:`all`}),[u,d]=(0,A.useState)(``),[f,m]=(0,A.useState)(0),[b,S]=(0,A.useState)(new Set),{data:w,error:T,loading:E,refetch:D}=p(()=>a.queuesSummary(),[],{intervalMs:3e4}),{data:O,error:N,refetch:P}=p(()=>a.stats(),[],{intervalMs:1e4});(0,A.useEffect)(()=>{!w||w.some(e=>e.name===r)||(i(w[0]?.name??``),m(0))},[w,r]);let F=`${r}|${s}|${f}`,{data:L,error:R,loading:z,refetch:B}=p((0,A.useCallback)(async()=>{if(!r)return{view:F,jobs:[]};let e=s===`all`?void 0:[s],t=await a.jobsList(r,e,25,f*25);return{view:F,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??r}))}},[r,s,f,F]),[r,s,f]),V=L?.view===F?L.jobs:null,ae=(V?.length??0)===25,H=(0,A.useMemo)(()=>{let e=u.trim().toLowerCase();return e?(V??[]).filter(t=>t.id.toLowerCase().includes(e)||t.name?.toLowerCase().includes(e)):V??[]},[V,u]),U=O?.stats,W=(0,A.useMemo)(()=>w?.reduce((e,t)=>e+(t.counts?.failed??0),0)??null,[w]),G=U&&W!=null?ee(U.completed,W):null,K=e=>U?C(e):`—`,q=()=>m(0),J=(e,t)=>{let r={};e&&(r.queue=e),t!==`all`&&(r.status=t),n(r,{replace:!0})};(0,A.useEffect)(()=>{S(new Set)},[r,s,f]);let oe=e=>S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Y=H.length>0&&H.every(e=>b.has(e.id)),se=()=>S(()=>Y?new Set:new Set(H.map(e=>e.id))),{actionMsg:X,bulkBusy:Z,busyIds:ce,runBulk:le,runOne:ue}=ie({queue:r,rows:H,selected:b,setSelected:S,refetch:B}),Q={promote:e=>k(e.state).promote},$=H.filter(e=>b.has(e.id)),de={promote:$.some(Q.promote)};return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(y,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!r&&V!=null&&!R&&!T&&!N,actions:(0,j.jsxs)(h,{size:`sm`,disabled:!V||H.length===0,onClick:()=>{if(H.length===0){o.info(`No jobs to export on this page`);return}let e=H.map(e=>({id:e.id,name:e.name??`default`,queue:e.queue??r,state:e.state??``,priority:e.priority??0,attempts:e.attempts??0,maxAttempts:e.maxAttempts??``,createdAt:e.createdAt?new Date(e.createdAt).toISOString():``,durationMs:e.startedAt&&e.completedAt?e.completedAt-e.startedAt:``}));te(`jobs-${r}-${s}`,e,[`id`,`name`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])},children:[(0,j.jsx)(c,{className:`size-3.5`}),` Export CSV`]})}),T&&(0,j.jsx)(g,{onRetry:D,message:w?`Queue inventory refresh failed — showing the last successful queue totals. ${T.message}`:`Could not discover queues — ${T.message}. Select an existing queue from the URL or retry.`}),N&&(0,j.jsx)(g,{onRetry:P,message:O?`Server-wide totals refresh failed — showing the last successful totals. ${N.message}`:`Server-wide job totals are unavailable — ${N.message}. The selected queue page may still be current.`}),(0,j.jsx)(ne,{total:U&&W!=null?C(U.completed+W+U.waiting+U.prioritized+U.active+U.delayed+U[`waiting-children`]):`—`,waiting:K(U?.waiting),prioritized:K(U?.prioritized),active:K(U?.active),flowBlocked:K(U?.[`waiting-children`]),completed:K(U?.completed),failed:W==null?`—`:C(W),failedCount:W,errorRate:G==null?`—`:x(G),errorRateTone:G==null?`default`:G>.05?`red`:`green`}),(0,j.jsx)(I,{queue:r,summary:w??[],status:s,search:u,selectedTotal:b.size,selectedVisible:$.length,canPromote:de.promote,bulkBusy:Z,onQueue:e=>{i(e),q(),J(e,s)},onStatus:e=>{l(e),q(),J(r,e)},onSearch:d,onPromote:()=>le(`Promote`,e=>a.promoteJob(e.id),Q.promote)}),X&&(0,j.jsx)(`div`,{role:`status`,className:`mb-3 text-sm ${X.ok?`text-success`:`text-danger`}`,children:X.text}),R&&V&&(0,j.jsx)(g,{message:`Job refresh failed — showing the last successful page.`,onRetry:B}),R&&!V?(0,j.jsx)(_,{error:R,onRetry:B}):E&&!w&&!r&&!T?(0,j.jsx)(v,{label:`Discovering queues…`}):z&&!V?(0,j.jsx)(v,{label:`Loading jobs…`}):(0,j.jsx)(re,{queue:r,rows:H,search:u,discoveryError:!!T,selected:b,allSelected:Y,bulkBusy:Z,busyIds:ce,page:f,hasNext:ae,onToggleAll:se,onToggle:oe,onRun:(e,t,n)=>void ue(e,t,n),onPage:m})]})}export{L as JobsPro};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t,g as n,r,t as i}from"./react-vendor-CFL9l8LK.js";import{t as a}from"./bq-DR2BTISO.js";import{t as o}from"./toastStore-XmMX7A5W.js";import{T as s,d as c,f as l,x as u}from"./icons-DH9SS1DA.js";import{r as d,t as f}from"./StatusBadge-DereLzOj.js";import{n as p}from"./usePolledData-CEyyLRYa.js";import{n as m,t as h}from"./Button-_aSJvRoW.js";import{i as g,n as _,r as v}from"./feedback-CtGN_kqB.js";import{t as y}from"./PageHeader-CQzNsw8r.js";import{a as b,c as x,i as S,s as C,t as ee}from"./format-Cg7VCIZW.js";import{r as w}from"./index-DZFZr0Mi.js";import{a as T}from"./form-DG3X6cLL.js";import{t as E}from"./Pagination-CSkzhNW6.js";import{r as D,t as O}from"./useServerActionGuard-CUx8TOAC.js";import{t as te}from"./exportFile-C7xhE8Yh.js";import{t as k}from"./flowOperationPolicy-B2Etcb3f.js";var A=e(n(),1),j=i();function ne(e){return(0,j.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4 xl:grid-cols-8`,children:[(0,j.jsx)(w,{label:`Total`,value:e.total,hint:`all queues`,compact:!0}),(0,j.jsx)(w,{label:`Waiting`,value:e.waiting,tone:`amber`,hint:`standard priority`,compact:!0}),(0,j.jsx)(w,{label:`Prioritized`,value:e.prioritized,tone:`amber`,compact:!0}),(0,j.jsx)(w,{label:`Active`,value:e.active,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Flow-blocked`,value:e.flowBlocked,tone:`blue`,compact:!0}),(0,j.jsx)(w,{label:`Completed`,value:e.completed,tone:`green`,compact:!0}),(0,j.jsx)(w,{label:`Failed`,value:e.failed,tone:e.failedCount!=null&&e.failedCount>0?`red`:`default`,compact:!0}),(0,j.jsx)(w,{label:`Error Rate`,value:e.errorRate,tone:e.errorRateTone,compact:!0})]})}var M=[`all`,`waiting`,`prioritized`,`active`,`delayed`,`waiting-children`,`paused`,`completed`,`failed`];function N(e,t){return e===t?`${t} selected`:`${e} of ${t} selected match this filter`}function P(e,t){let n=new Set(e);for(let e of t)n.delete(e);return n}function F(e=0){return e>=10?{text:`HIGH`,className:`text-warning`}:e>=1?{text:`MEDIUM`,className:`text-blue-400`}:{text:`LOW`,className:`text-faint`}}function re({queue:e,rows:t,search:n,discoveryError:i,selected:o,allSelected:s,bulkBusy:c,busyIds:p,page:h,hasNext:g,onToggleAll:_,onToggle:v,onRun:y,onPage:x}){return(0,j.jsxs)(j.Fragment,{children:[e&&(0,j.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`text-faint`,children:`Jobs in queue`}),(0,j.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-fg`,children:e})]}),(0,j.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,j.jsx)(`th`,{className:`w-10 px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:s,ref:e=>{e&&(e.indeterminate=o.size>0&&!s)},"aria-checked":o.size>0&&!s?`mixed`:s,onChange:_,"aria-label":`Select all jobs on page`,className:`accent-accent`})}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,j.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Priority`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,j.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,j.jsx)(`th`,{className:`w-28 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,j.jsx)(`tbody`,{children:t.length===0?(0,j.jsx)(`tr`,{children:(0,j.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:n.trim()?`No jobs on this page match your ID or name filter.`:e?`No jobs found.`:i?`Queue discovery failed. Retry above.`:`Select a queue.`})}):t.map(e=>{let t=F(e.priority),n=k(e.state),i=c||p.has(e.id);return(0,j.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(`input`,{type:`checkbox`,checked:o.has(e.id),onChange:()=>v(e.id),"aria-label":`Select job ${e.id}`,className:`accent-accent`})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent/90`,children:(0,j.jsx)(`span`,{className:`block max-w-[16rem] truncate`,title:e.id,children:e.id})}),(0,j.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsx)(f,{status:String(e.state??`waiting`)})}),(0,j.jsx)(`td`,{className:d(`px-5 py-3 text-xs font-semibold`,t.className),children:t.text}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:S(e.createdAt)}),(0,j.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)}),(0,j.jsx)(`td`,{className:`px-5 py-3`,children:(0,j.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,j.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect job ${e.id}`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,j.jsx)(l,{className:`size-3.5`})}),n.promote&&(0,j.jsx)(m,{"aria-label":`Promote job`,disabled:i,onClick:()=>y(e,`Promote`,()=>a.promoteJob(e.id)),children:(0,j.jsx)(u,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,j.jsx)(E,{page:h,pageSize:25,hasNext:g,onPageChange:x,label:`jobs`})]})}function I({queue:e,summary:t,status:n,search:r,selectedTotal:i,selectedVisible:a,canPromote:o,bulkBusy:c,onQueue:l,onStatus:u,onSearch:d,onPromote:f}){return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{value:e,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>l(e.target.value),children:t.map(e=>(0,j.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),(0,j.jsx)(`div`,{className:`w-48`,children:(0,j.jsx)(T,{"aria-label":`Job state`,name:`jobs-state`,value:n,onChange:e=>u(e.target.value),children:M.map(e=>(0,j.jsx)(`option`,{value:e,children:e===`all`?`All states`:e},e))})}),(0,j.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,j.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,j.jsx)(`input`,{value:r,onChange:e=>d(e.target.value),placeholder:`Filter this page by ID or name…`,"aria-label":`Filter by job ID or name`,name:`jobs-id-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),i>0&&(0,j.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm`,children:[(0,j.jsx)(`span`,{className:`mr-1 text-muted`,children:N(a,i)}),o?(0,j.jsx)(h,{size:`sm`,disabled:c,onClick:f,children:`Promote selected`}):(0,j.jsx)(`span`,{className:`text-xs text-faint`,children:a===0?`The selected jobs are hidden by the filter — clear it to act on them.`:`No actions apply to the selected job states.`})]})]})}function ie({queue:e,rows:t,selected:n,setSelected:r,refetch:i}){let[a,s]=(0,A.useState)(new Set),[c,l]=(0,A.useState)(!1),[u,d]=(0,A.useState)(null),f=D(`jobs:${e}`);return(0,A.useEffect)(()=>{s(new Set),l(!1),d(null)},[f.scopeKey]),{actionMsg:u,bulkBusy:c,busyIds:a,runBulk:async(e,a,s,c)=>{let u=t.filter(e=>n.has(e.id)&&s(e));if(u.length===0||c&&!window.confirm(c(u.length)))return;let p=f.begin([`bulk`,...u.map(e=>`job:${e.id}`)]);if(p){l(!0),d(null);try{let t=await Promise.allSettled(u.map(async t=>{O(await a(t),`${e} ${t.id}`)}));if(!p.isCurrent())return;let n=t.filter(e=>e.status===`fulfilled`).length,s=t.length-n,c=`${e}: ${n} succeeded${s?`, ${s} failed`:``}`;d({ok:s===0,text:c}),s===0?o.success(c):o.error(c),r(e=>P(e,u.map(e=>e.id))),i()}finally{p.finish()&&l(!1)}}},runOne:async(e,t,n,r)=>{if(r&&!window.confirm(r))return;let a=f.begin(`job:${e.id}`);if(a){s(t=>new Set(t).add(e.id)),d(null);try{if(O(await n(),t),!a.isCurrent())return;d({ok:!0,text:`${t} ✓`}),o.success(`${t} ✓`,e.id),i()}catch(e){if(!a.isCurrent())return;d({ok:!1,text:`${t} failed: ${e.message}`}),o.error(`${t} failed`,e.message)}finally{a.finish()&&s(t=>{let n=new Set(t);return n.delete(e.id),n})}}}}}function L(){let[e,n]=t(),[r,i]=(0,A.useState)(e.get(`queue`)??``),[s,l]=(0,A.useState)(()=>{let t=e.get(`status`);return t&&M.includes(t)?t:`all`}),[u,d]=(0,A.useState)(``),[f,m]=(0,A.useState)(0),[b,S]=(0,A.useState)(new Set),{data:w,error:T,loading:E,refetch:D}=p(()=>a.queuesSummary(),[],{intervalMs:3e4}),{data:O,error:N,refetch:P}=p(()=>a.stats(),[],{intervalMs:1e4});(0,A.useEffect)(()=>{!w||w.some(e=>e.name===r)||(i(w[0]?.name??``),m(0))},[w,r]);let F=`${r}|${s}|${f}`,{data:L,error:R,loading:z,refetch:B}=p((0,A.useCallback)(async()=>{if(!r)return{view:F,jobs:[]};let e=s===`all`?void 0:[s],t=await a.jobsList(r,e,25,f*25);return{view:F,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??r}))}},[r,s,f,F]),[r,s,f]),V=L?.view===F?L.jobs:null,ae=(V?.length??0)===25,H=(0,A.useMemo)(()=>{let e=u.trim().toLowerCase();return e?(V??[]).filter(t=>t.id.toLowerCase().includes(e)||t.name?.toLowerCase().includes(e)):V??[]},[V,u]),U=O?.stats,W=(0,A.useMemo)(()=>w?.reduce((e,t)=>e+(t.counts?.failed??0),0)??null,[w]),G=U&&W!=null?ee(U.completed,W):null,K=e=>U?C(e):`—`,q=()=>m(0),J=(e,t)=>{let r={};e&&(r.queue=e),t!==`all`&&(r.status=t),n(r,{replace:!0})};(0,A.useEffect)(()=>{S(new Set)},[r,s,f]);let oe=e=>S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Y=H.length>0&&H.every(e=>b.has(e.id)),se=()=>S(()=>Y?new Set:new Set(H.map(e=>e.id))),{actionMsg:X,bulkBusy:Z,busyIds:ce,runBulk:le,runOne:ue}=ie({queue:r,rows:H,selected:b,setSelected:S,refetch:B}),Q={promote:e=>k(e.state).promote},$=H.filter(e=>b.has(e.id)),de={promote:$.some(Q.promote)};return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(y,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!r&&V!=null&&!R&&!T&&!N,actions:(0,j.jsxs)(h,{size:`sm`,disabled:!V||H.length===0,onClick:()=>{if(H.length===0){o.info(`No jobs to export on this page`);return}let e=H.map(e=>({id:e.id,name:e.name??`default`,queue:e.queue??r,state:e.state??``,priority:e.priority??0,attempts:e.attempts??0,maxAttempts:e.maxAttempts??``,createdAt:e.createdAt?new Date(e.createdAt).toISOString():``,durationMs:e.startedAt&&e.completedAt?e.completedAt-e.startedAt:``}));te(`jobs-${r}-${s}`,e,[`id`,`name`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])},children:[(0,j.jsx)(c,{className:`size-3.5`}),` Export CSV`]})}),T&&(0,j.jsx)(g,{onRetry:D,message:w?`Queue inventory refresh failed — showing the last successful queue totals. ${T.message}`:`Could not discover queues — ${T.message}. Select an existing queue from the URL or retry.`}),N&&(0,j.jsx)(g,{onRetry:P,message:O?`Server-wide totals refresh failed — showing the last successful totals. ${N.message}`:`Server-wide job totals are unavailable — ${N.message}. The selected queue page may still be current.`}),(0,j.jsx)(ne,{total:U&&W!=null?C(U.completed+W+U.waiting+U.prioritized+U.active+U.delayed+U[`waiting-children`]):`—`,waiting:K(U?.waiting),prioritized:K(U?.prioritized),active:K(U?.active),flowBlocked:K(U?.[`waiting-children`]),completed:K(U?.completed),failed:W==null?`—`:C(W),failedCount:W,errorRate:G==null?`—`:x(G),errorRateTone:G==null?`default`:G>.05?`red`:`green`}),(0,j.jsx)(I,{queue:r,summary:w??[],status:s,search:u,selectedTotal:b.size,selectedVisible:$.length,canPromote:de.promote,bulkBusy:Z,onQueue:e=>{i(e),q(),J(e,s)},onStatus:e=>{l(e),q(),J(r,e)},onSearch:d,onPromote:()=>le(`Promote`,e=>a.promoteJob(e.id),Q.promote)}),X&&(0,j.jsx)(`div`,{role:`status`,className:`mb-3 text-sm ${X.ok?`text-success`:`text-danger`}`,children:X.text}),R&&V&&(0,j.jsx)(g,{message:`Job refresh failed — showing the last successful page.`,onRetry:B}),R&&!V?(0,j.jsx)(_,{error:R,onRetry:B}):E&&!w&&!r&&!T?(0,j.jsx)(v,{label:`Discovering queues…`}):z&&!V?(0,j.jsx)(v,{label:`Loading jobs…`}):(0,j.jsx)(re,{queue:r,rows:H,search:u,discoveryError:!!T,selected:b,allSelected:Y,bulkBusy:Z,busyIds:ce,page:f,hasNext:ae,onToggleAll:se,onToggle:oe,onRun:(e,t,n)=>void ue(e,t,n),onPage:m})]})}export{L as JobsPro};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{T as r,h as i}from"./icons-DH9SS1DA.js";import{t as a}from"./StatusBadge-DereLzOj.js";import{n as o}from"./usePolledData-CEyyLRYa.js";import{i as s,t as c}from"./feedback-CtGN_kqB.js";import{t as l}from"./PageHeader-CQzNsw8r.js";import{l as u,s as d}from"./format-Cg7VCIZW.js";import{r as f,t as p}from"./index-Bat1DN5U.js";import{a as m,i as h}from"./form-DG3X6cLL.js";import{t as g}from"./Pagination-CSkzhNW6.js";import{r as _}from"./classicJobsData-Csj4iihY.js";import"./Jobs-IrlneOy6.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;async function C(){let e=await _();if(!Number.isFinite(e.timestamp)||e.queues.some(e=>!Number.isSafeInteger(e.waiting)||e.waiting<0||!Number.isSafeInteger(e.delayed)||e.delayed<0||!Number.isSafeInteger(e.active)||e.active<0||!Number.isSafeInteger(e.dlq)||e.dlq<0||typeof e.paused!=`boolean`))throw Error(`Queue discovery returned malformed queue summaries`);return e}function w(){let[e,t]=(0,v.useState)(b),[n,_]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O,error:k,refetch:A}=o(C,[],{intervalMs:3e4}),{events:j,counters:M,throughput:N,connected:P,error:F}=p(e===b?void 0:e),I=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return j.filter(t=>n!==`all`&&t.status!==n?!1:!e||(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e))},[j,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let L=Math.max(1,Math.ceil(I.length/S)),R=Math.min(E,L-1);return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:P}),k&&(0,y.jsx)(s,{onRetry:A,message:`Could not discover queues — ${k.message}. The current stream can still be used.`}),F&&(0,y.jsx)(s,{message:`Event stream unavailable — ${F.message}. Retrying…`}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(f,{label:`Total Events`,value:d(M.total),compact:!0}),(0,y.jsx)(f,{label:`Completed`,value:d(M.completed),tone:`green`,compact:!0}),(0,y.jsx)(f,{label:`Failed`,value:d(M.failed),tone:M.failed?`red`:`default`,compact:!0}),(0,y.jsx)(f,{label:`Waiting`,value:d(M.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(f,{label:`Active`,value:d(M.active),tone:`blue`,compact:!0}),(0,y.jsx)(f,{label:`Throughput`,value:`${N.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(m,{value:e,"aria-label":`Filter by queue`,name:`classic-activity-queue-filter`,autoComplete:`off`,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(h,{options:x,value:n,onChange:_}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(r,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{"aria-label":`Search by job name or ID`,name:`classic-activity-search`,autoComplete:`off`,value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),I.length===0?(0,y.jsx)(c,{icon:(0,y.jsx)(i,{}),title:F?`Event stream unavailable`:P?`Waiting for activity…`:`Connecting to the event stream…`,hint:F?`${F.message}. The dashboard is retrying automatically.`:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:I.slice(R*S,R*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(a,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.event||`job event`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(g,{page:R,pageSize:S,total:I.length,onPageChange:D,label:`events`})]})}export{w as Logs};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{T as r,h as i}from"./icons-DH9SS1DA.js";import{t as a}from"./StatusBadge-DereLzOj.js";import{n as o}from"./usePolledData-CEyyLRYa.js";import{i as s,t as c}from"./feedback-CtGN_kqB.js";import{t as l}from"./PageHeader-CQzNsw8r.js";import{l as u,s as d}from"./format-Cg7VCIZW.js";import{r as f,t as p}from"./index-DZFZr0Mi.js";import{a as m,i as h}from"./form-DG3X6cLL.js";import{t as g}from"./Pagination-CSkzhNW6.js";import{r as _}from"./classicJobsData-Csj4iihY.js";import"./Jobs-CKzKpQ7i.js";var v=e(t(),1),y=n(),b=`__all__`,x=[`all`,`waiting`,`active`,`completed`,`failed`],S=10;async function C(){let e=await _();if(!Number.isFinite(e.timestamp)||e.queues.some(e=>!Number.isSafeInteger(e.waiting)||e.waiting<0||!Number.isSafeInteger(e.delayed)||e.delayed<0||!Number.isSafeInteger(e.active)||e.active<0||!Number.isSafeInteger(e.dlq)||e.dlq<0||typeof e.paused!=`boolean`))throw Error(`Queue discovery returned malformed queue summaries`);return e}function w(){let[e,t]=(0,v.useState)(b),[n,_]=(0,v.useState)(`all`),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(0),{data:O,error:k,refetch:A}=o(C,[],{intervalMs:3e4}),{events:j,counters:M,throughput:N,connected:P,error:F}=p(e===b?void 0:e),I=(0,v.useMemo)(()=>{let e=w.trim().toLowerCase();return j.filter(t=>n!==`all`&&t.status!==n?!1:!e||(t.jobId??``).toLowerCase().includes(e)||(t.name??``).toLowerCase().includes(e)||(t.queue??``).toLowerCase().includes(e))},[j,n,w]);(0,v.useEffect)(()=>D(0),[e,n,w]);let L=Math.max(1,Math.ceil(I.length/S)),R=Math.min(E,L-1);return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:P}),k&&(0,y.jsx)(s,{onRetry:A,message:`Could not discover queues — ${k.message}. The current stream can still be used.`}),F&&(0,y.jsx)(s,{message:`Event stream unavailable — ${F.message}. Retrying…`}),(0,y.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,y.jsx)(f,{label:`Total Events`,value:d(M.total),compact:!0}),(0,y.jsx)(f,{label:`Completed`,value:d(M.completed),tone:`green`,compact:!0}),(0,y.jsx)(f,{label:`Failed`,value:d(M.failed),tone:M.failed?`red`:`default`,compact:!0}),(0,y.jsx)(f,{label:`Waiting`,value:d(M.waiting),tone:`amber`,compact:!0}),(0,y.jsx)(f,{label:`Active`,value:d(M.active),tone:`blue`,compact:!0}),(0,y.jsx)(f,{label:`Throughput`,value:`${N.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,y.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`w-48`,children:(0,y.jsxs)(m,{value:e,"aria-label":`Filter by queue`,name:`classic-activity-queue-filter`,autoComplete:`off`,onChange:e=>t(e.target.value),children:[(0,y.jsx)(`option`,{value:b,children:`All Queues`}),(O?.queues??[]).map(e=>(0,y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,y.jsx)(h,{options:x,value:n,onChange:_}),(0,y.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,y.jsx)(r,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,y.jsx)(`input`,{"aria-label":`Search by job name or ID`,name:`classic-activity-search`,autoComplete:`off`,value:w,onChange:e=>T(e.target.value),placeholder:`Search by job name or ID…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),I.length===0?(0,y.jsx)(c,{icon:(0,y.jsx)(i,{}),title:F?`Event stream unavailable`:P?`Waiting for activity…`:`Connecting to the event stream…`,hint:F?`${F.message}. The dashboard is retrying automatically.`:`Job events stream in here live as they happen on the server.`}):(0,y.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,y.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,y.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,y.jsx)(`tbody`,{children:I.slice(R*S,R*S+S).map(e=>(0,y.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(a,{status:e.status})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.event||`job event`}),(0,y.jsx)(`td`,{className:`px-5 py-3`,children:(0,y.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:u(e.timestamp)}),(0,y.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId||`—`})]},e.seq))})]})}),(0,y.jsx)(g,{page:R,pageSize:S,total:I.length,onPageChange:D,label:`events`})]})}export{w as Logs};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-CFL9l8LK.js";import{o as i}from"./connectionStore-CVjQyIZv.js";import{T as a}from"./icons-DH9SS1DA.js";import{t as o}from"./StatusBadge-DereLzOj.js";import{n as s}from"./usePolledData-CEyyLRYa.js";import{t as c}from"./Button-_aSJvRoW.js";import{i as l}from"./feedback-CtGN_kqB.js";import{t as u}from"./PageHeader-CQzNsw8r.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{a as p,r as m,t as h}from"./index-Bat1DN5U.js";import{a as g,i as _}from"./form-DG3X6cLL.js";import{t as v}from"./Pagination-CSkzhNW6.js";import{t as y}from"./QueueControl-C01l6bBJ.js";var b=e(t(),1),x=r(),S=`__all__`,C=[`all`,`waiting`,`active`,`completed`,`failed`],w=10,T=250;function E(){let[e,t]=(0,b.useState)(S),[r,E]=(0,b.useState)(`all`),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(0),[j,M]=(0,b.useState)(null),N=j!==null,P=i(t=>JSON.stringify([t.baseUrl,t.token,e])),{data:F,error:I,refetch:L}=s(y,[],{intervalMs:3e4}),{events:R,counters:z,throughput:B,connected:V,error:H}=h(e===S?void 0:e),U=(0,b.useMemo)(()=>{let e=j??R,t=D.trim().toLowerCase();return e.filter(e=>r!==`all`&&e.status!==r?!1:!t||(e.jobId??``).toLowerCase().includes(t)||(e.queue??``).toLowerCase().includes(t))},[R,j,r,D]),W=N?Math.max(0,(R[0]?.seq??0)-(j[0]?.seq??0)):0;(0,b.useEffect)(()=>A(0),[e,r,D]),(0,b.useEffect)(()=>M(null),[P]);let G=k*w,K=U.slice(G,G+w);return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(u,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:V&&!N}),I&&(0,x.jsx)(l,{onRetry:L,message:`Could not discover queues — ${I.message}. The current stream can still be used.`}),H&&(0,x.jsx)(l,{message:`Event stream unavailable — ${H.message}. Retrying…`}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,x.jsx)(m,{label:`Total Events`,value:f(z.total),compact:!0}),(0,x.jsx)(m,{label:`Completed`,value:f(z.completed),tone:`green`,compact:!0}),(0,x.jsx)(m,{label:`Failed`,value:f(z.failed),tone:z.failed?`red`:`default`,compact:!0}),(0,x.jsx)(m,{label:`Waiting`,value:f(z.waiting),tone:`amber`,compact:!0}),(0,x.jsx)(m,{label:`Active`,value:f(z.active),tone:`blue`,compact:!0}),(0,x.jsx)(m,{label:`Throughput`,value:`${B.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`w-48`,children:(0,x.jsxs)(g,{"aria-label":`Filter by queue`,name:`activity-queue-filter`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),children:[(0,x.jsx)(`option`,{value:S,children:`All Queues`}),(F?.queues??[]).map(e=>(0,x.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,x.jsx)(_,{options:C,value:r,onChange:E}),(0,x.jsx)(c,{size:`sm`,variant:N?`warning`:`default`,onClick:()=>M(N?null:R),title:N?`Resume applying live events to the list`:`Freeze the visible list while the stream keeps buffering`,children:N?`Resume${W?` — ${f(W)} new`:``}`:`Following · Pause`}),(0,x.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,x.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,x.jsx)(`input`,{"aria-label":`Search by job ID or queue`,name:`activity-search`,autoComplete:`off`,value:D,onChange:e=>O(e.target.value),placeholder:`Search by job ID or queue…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),(0,x.jsxs)(`p`,{className:`-mt-2 mb-4 text-xs text-faint`,children:[`Search and filters cover the last `,T,` streamed events held in this browser.`]}),(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,x.jsx)(`tbody`,{children:K.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:H?`Event stream unavailable — ${H.message}. Retrying…`:V?R.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):K.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(o,{status:e.status})}),(0,x.jsxs)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:[e.event,e.status===`failed`&&e.error&&(0,x.jsx)(`div`,{className:`mt-0.5 max-w-64 truncate text-[11px] text-danger`,title:e.error,children:e.error})]}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,title:new Date(e.timestamp).toISOString(),children:d(e.timestamp)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,x.jsx)(n,{to:`/job?id=${encodeURIComponent(e.jobId)}`,className:`text-accent hover:underline`,children:e.jobId}),(0,x.jsx)(p,{value:e.jobId})]}):`—`})]},e.seq))})]})}),(0,x.jsx)(v,{page:k,pageSize:w,total:U.length,onPageChange:A,label:`events`})]})}export{E as LogsPro};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-CFL9l8LK.js";import{o as i}from"./connectionStore-CVjQyIZv.js";import{T as a}from"./icons-DH9SS1DA.js";import{t as o}from"./StatusBadge-DereLzOj.js";import{n as s}from"./usePolledData-CEyyLRYa.js";import{t as c}from"./Button-_aSJvRoW.js";import{i as l}from"./feedback-CtGN_kqB.js";import{t as u}from"./PageHeader-CQzNsw8r.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{a as p,r as m,t as h}from"./index-DZFZr0Mi.js";import{a as g,i as _}from"./form-DG3X6cLL.js";import{t as v}from"./Pagination-CSkzhNW6.js";import{t as y}from"./QueueControl-DaZjeZnw.js";var b=e(t(),1),x=r(),S=`__all__`,C=[`all`,`waiting`,`active`,`completed`,`failed`],w=10,T=250;function E(){let[e,t]=(0,b.useState)(S),[r,E]=(0,b.useState)(`all`),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(0),[j,M]=(0,b.useState)(null),N=j!==null,P=i(t=>JSON.stringify([t.baseUrl,t.token,e])),{data:F,error:I,refetch:L}=s(y,[],{intervalMs:3e4}),{events:R,counters:z,throughput:B,connected:V,error:H}=h(e===S?void 0:e),U=(0,b.useMemo)(()=>{let e=j??R,t=D.trim().toLowerCase();return e.filter(e=>r!==`all`&&e.status!==r?!1:!t||(e.jobId??``).toLowerCase().includes(t)||(e.queue??``).toLowerCase().includes(t))},[R,j,r,D]),W=N?Math.max(0,(R[0]?.seq??0)-(j[0]?.seq??0)):0;(0,b.useEffect)(()=>A(0),[e,r,D]),(0,b.useEffect)(()=>M(null),[P]);let G=k*w,K=U.slice(G,G+w);return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(u,{title:`Activity Logs`,description:`Real-time job activity across all queues.`,live:V&&!N}),I&&(0,x.jsx)(l,{onRetry:L,message:`Could not discover queues — ${I.message}. The current stream can still be used.`}),H&&(0,x.jsx)(l,{message:`Event stream unavailable — ${H.message}. Retrying…`}),(0,x.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,x.jsx)(m,{label:`Total Events`,value:f(z.total),compact:!0}),(0,x.jsx)(m,{label:`Completed`,value:f(z.completed),tone:`green`,compact:!0}),(0,x.jsx)(m,{label:`Failed`,value:f(z.failed),tone:z.failed?`red`:`default`,compact:!0}),(0,x.jsx)(m,{label:`Waiting`,value:f(z.waiting),tone:`amber`,compact:!0}),(0,x.jsx)(m,{label:`Active`,value:f(z.active),tone:`blue`,compact:!0}),(0,x.jsx)(m,{label:`Throughput`,value:`${B.toFixed(1)}/s`,tone:`accent`,compact:!0})]}),(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`w-48`,children:(0,x.jsxs)(g,{"aria-label":`Filter by queue`,name:`activity-queue-filter`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),children:[(0,x.jsx)(`option`,{value:S,children:`All Queues`}),(F?.queues??[]).map(e=>(0,x.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,x.jsx)(_,{options:C,value:r,onChange:E}),(0,x.jsx)(c,{size:`sm`,variant:N?`warning`:`default`,onClick:()=>M(N?null:R),title:N?`Resume applying live events to the list`:`Freeze the visible list while the stream keeps buffering`,children:N?`Resume${W?` — ${f(W)} new`:``}`:`Following · Pause`}),(0,x.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,x.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,x.jsx)(`input`,{"aria-label":`Search by job ID or queue`,name:`activity-search`,autoComplete:`off`,value:D,onChange:e=>O(e.target.value),placeholder:`Search by job ID or queue…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]})]}),(0,x.jsxs)(`p`,{className:`-mt-2 mb-4 text-xs text-faint`,children:[`Search and filters cover the last `,T,` streamed events held in this browser.`]}),(0,x.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,x.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Event`}),(0,x.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Timestamp`}),(0,x.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`ID`})]})}),(0,x.jsx)(`tbody`,{children:K.length===0?(0,x.jsx)(`tr`,{children:(0,x.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:H?`Event stream unavailable — ${H.message}. Retrying…`:V?R.length>0?`No events match the current filters.`:`Waiting for activity…`:`Connecting to the event stream…`})}):K.map(e=>(0,x.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(o,{status:e.status})}),(0,x.jsxs)(`td`,{className:`px-5 py-3 font-mono text-xs text-fg`,children:[e.event,e.status===`failed`&&e.error&&(0,x.jsx)(`div`,{className:`mt-0.5 max-w-64 truncate text-[11px] text-danger`,title:e.error,children:e.error})]}),(0,x.jsx)(`td`,{className:`px-5 py-3`,children:(0,x.jsx)(`span`,{className:`rounded-md bg-surface-2 px-2 py-0.5 font-mono text-xs text-muted`,children:e.queue||`—`})}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,title:new Date(e.timestamp).toISOString(),children:d(e.timestamp)}),(0,x.jsx)(`td`,{className:`px-5 py-3 text-right font-mono text-xs text-faint`,children:e.jobId?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,x.jsx)(n,{to:`/job?id=${encodeURIComponent(e.jobId)}`,className:`text-accent hover:underline`,children:e.jobId}),(0,x.jsx)(p,{value:e.jobId})]}):`—`})]},e.seq))})]})}),(0,x.jsx)(v,{page:k,pageSize:w,total:U.length,onPageChange:A,label:`events`})]})}export{E as LogsPro};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./react-vendor-CFL9l8LK.js";import{n as t,t as n}from"./Card-egIDLwVk.js";import{t as r}from"./PageHeader-CQzNsw8r.js";import{a as i,r as a}from"./index-Bat1DN5U.js";var o=`{
1
+ import{t as e}from"./react-vendor-CFL9l8LK.js";import{n as t,t as n}from"./Card-egIDLwVk.js";import{t as r}from"./PageHeader-CQzNsw8r.js";import{a as i,r as a}from"./index-DZFZr0Mi.js";var o=`{
2
2
  "mcpServers": {
3
3
  "bunqueue": {
4
4
  "command": "bun",
@@ -1 +1 @@
1
- import{t as e}from"./react-vendor-CFL9l8LK.js";import{t}from"./api-D9aT0ND7.js";import{n}from"./usePolledData-CEyyLRYa.js";import{n as r,t as i}from"./Card-egIDLwVk.js";import{i as a,n as o,r as s}from"./feedback-CtGN_kqB.js";import{t as c}from"./PageHeader-CQzNsw8r.js";import{n as l,s as u}from"./format-Cg7VCIZW.js";import{r as d}from"./index-Bat1DN5U.js";var f=e(),p={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function m(){let{data:e,error:m,loading:_,refetch:v}=n(()=>t.overview(),[]);if(_&&!e&&!m)return(0,f.jsx)(s,{label:`Loading metrics…`});if(m&&!e)return(0,f.jsxs)(`div`,{children:[(0,f.jsx)(c,{title:`Metrics`,description:`Throughput, latency, and resource internals.`}),(0,f.jsx)(o,{error:m,onRetry:v})]});let{stats:y,throughput:b,latency:x,memory:S,collections:C}=e??p,w={};for(let[e,t]of Object.entries(x.percentiles??{}))t&&typeof t==`object`&&(w[`${e} p50`]=t.p50,w[`${e} p95`]=t.p95,w[`${e} p99`]=t.p99);return(0,f.jsxs)(`div`,{children:[m&&(0,f.jsx)(a,{message:`Metrics refresh failed — showing the last successful snapshot.`,onRetry:v}),(0,f.jsx)(c,{title:`Metrics`,description:`Throughput, latency, and resource internals.`,live:!!e&&!m}),(0,f.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,f.jsx)(d,{label:`Pushed /s`,value:b.pushPerSec.toFixed(1),compact:!0}),(0,f.jsx)(d,{label:`Pulled /s`,value:b.pullPerSec.toFixed(1),tone:`blue`,compact:!0}),(0,f.jsx)(d,{label:`Completed /s`,value:b.completePerSec.toFixed(1),tone:`green`,compact:!0}),(0,f.jsx)(d,{label:`Failed /s`,value:b.failPerSec.toFixed(1),tone:`red`,compact:!0})]}),(0,f.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Totals`}),(0,f.jsx)(h,{rows:[[`Pushed`,u(y.totalPushed)],[`Pulled`,u(y.totalPulled)],[`Completed`,u(y.totalCompleted)],[`Failed`,u(y.totalFailed)]]})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Memory`}),(0,f.jsx)(h,{rows:[[`Heap Used`,l(S.heapUsed*1024*1024)],[`Heap Total`,l(S.heapTotal*1024*1024)],[`RSS`,l(S.rss*1024*1024)]]})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Latency — percentiles (ms)`}),(0,f.jsx)(g,{record:w,suffix:`ms`})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Latency — averages (ms)`}),(0,f.jsx)(g,{record:x.averages,suffix:`ms`})]})]}),(0,f.jsx)(`div`,{className:`mt-6`,children:(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`In-memory collections`}),(0,f.jsx)(g,{record:C})]})})]})}function h({rows:e}){return(0,f.jsx)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:e.map(([e,t])=>(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,f.jsx)(`div`,{className:`mt-1 text-xl font-semibold tnum text-fg`,children:t})]},e))})}function g({record:e,suffix:t}){let n=Object.entries(e??{});return n.length===0?(0,f.jsx)(`p`,{className:`py-4 text-sm text-faint`,children:`No data.`}):(0,f.jsx)(`dl`,{className:`divide-y divide-line`,children:n.map(([e,n])=>(0,f.jsxs)(`div`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,f.jsx)(`dt`,{className:`font-mono text-xs text-muted`,children:e}),(0,f.jsxs)(`dd`,{className:`tnum font-medium text-fg`,children:[typeof n==`number`?u(Math.round(n*100)/100):String(n),t&&(0,f.jsx)(`span`,{className:`ml-1 text-xs text-faint`,children:t})]})]},e))})}export{m as Metrics};
1
+ import{t as e}from"./react-vendor-CFL9l8LK.js";import{t}from"./api-D9aT0ND7.js";import{n}from"./usePolledData-CEyyLRYa.js";import{n as r,t as i}from"./Card-egIDLwVk.js";import{i as a,n as o,r as s}from"./feedback-CtGN_kqB.js";import{t as c}from"./PageHeader-CQzNsw8r.js";import{n as l,s as u}from"./format-Cg7VCIZW.js";import{r as d}from"./index-DZFZr0Mi.js";var f=e(),p={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function m(){let{data:e,error:m,loading:_,refetch:v}=n(()=>t.overview(),[]);if(_&&!e&&!m)return(0,f.jsx)(s,{label:`Loading metrics…`});if(m&&!e)return(0,f.jsxs)(`div`,{children:[(0,f.jsx)(c,{title:`Metrics`,description:`Throughput, latency, and resource internals.`}),(0,f.jsx)(o,{error:m,onRetry:v})]});let{stats:y,throughput:b,latency:x,memory:S,collections:C}=e??p,w={};for(let[e,t]of Object.entries(x.percentiles??{}))t&&typeof t==`object`&&(w[`${e} p50`]=t.p50,w[`${e} p95`]=t.p95,w[`${e} p99`]=t.p99);return(0,f.jsxs)(`div`,{children:[m&&(0,f.jsx)(a,{message:`Metrics refresh failed — showing the last successful snapshot.`,onRetry:v}),(0,f.jsx)(c,{title:`Metrics`,description:`Throughput, latency, and resource internals.`,live:!!e&&!m}),(0,f.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,f.jsx)(d,{label:`Pushed /s`,value:b.pushPerSec.toFixed(1),compact:!0}),(0,f.jsx)(d,{label:`Pulled /s`,value:b.pullPerSec.toFixed(1),tone:`blue`,compact:!0}),(0,f.jsx)(d,{label:`Completed /s`,value:b.completePerSec.toFixed(1),tone:`green`,compact:!0}),(0,f.jsx)(d,{label:`Failed /s`,value:b.failPerSec.toFixed(1),tone:`red`,compact:!0})]}),(0,f.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Totals`}),(0,f.jsx)(h,{rows:[[`Pushed`,u(y.totalPushed)],[`Pulled`,u(y.totalPulled)],[`Completed`,u(y.totalCompleted)],[`Failed`,u(y.totalFailed)]]})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Memory`}),(0,f.jsx)(h,{rows:[[`Heap Used`,l(S.heapUsed*1024*1024)],[`Heap Total`,l(S.heapTotal*1024*1024)],[`RSS`,l(S.rss*1024*1024)]]})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Latency — percentiles (ms)`}),(0,f.jsx)(g,{record:w,suffix:`ms`})]}),(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`Latency — averages (ms)`}),(0,f.jsx)(g,{record:x.averages,suffix:`ms`})]})]}),(0,f.jsx)(`div`,{className:`mt-6`,children:(0,f.jsxs)(i,{children:[(0,f.jsx)(r,{title:`In-memory collections`}),(0,f.jsx)(g,{record:C})]})})]})}function h({rows:e}){return(0,f.jsx)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:e.map(([e,t])=>(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,f.jsx)(`div`,{className:`mt-1 text-xl font-semibold tnum text-fg`,children:t})]},e))})}function g({record:e,suffix:t}){let n=Object.entries(e??{});return n.length===0?(0,f.jsx)(`p`,{className:`py-4 text-sm text-faint`,children:`No data.`}):(0,f.jsx)(`dl`,{className:`divide-y divide-line`,children:n.map(([e,n])=>(0,f.jsxs)(`div`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,f.jsx)(`dt`,{className:`font-mono text-xs text-muted`,children:e}),(0,f.jsxs)(`dd`,{className:`tnum font-medium text-fg`,children:[typeof n==`number`?u(Math.round(n*100)/100):String(n),t&&(0,f.jsx)(`span`,{className:`ml-1 text-xs text-faint`,children:t})]})]},e))})}export{m as Metrics};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{t as r}from"./bq-DR2BTISO.js";import{r as i}from"./StatusBadge-DereLzOj.js";import{n as a}from"./usePolledData-CEyyLRYa.js";import{n as o,t as s}from"./Card-egIDLwVk.js";import{i as c,r as l,t as u}from"./feedback-CtGN_kqB.js";import{t as d}from"./PageHeader-CQzNsw8r.js";import{c as f,r as p,s as m,t as h,u as g}from"./format-Cg7VCIZW.js";import{r as _}from"./index-Bat1DN5U.js";import{t as v}from"./Pagination-CSkzhNW6.js";import{t as y}from"./AreaChart-Db2UVnaK.js";import{n as b,t as x}from"./useThroughputSeries-CeFx-Mwq.js";var S=e(t(),1),C=n();function w({rate:e,stats:t}){return(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsx)(T,{value:e==null?`—`:f(e),label:`error rate`,danger:e!=null&&e>.05}),(0,C.jsx)(T,{value:e==null?`—`:f(1-e),label:`success rate`,success:e!=null})]}),e==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-e)*100}%`}})})]}),(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(E,{color:`bg-blue-400`,label:`Standard waiting`,value:t?m(t.waiting):`—`}),(0,C.jsx)(E,{color:`bg-accent`,label:`Processing`,value:t?m(t.active):`—`}),(0,C.jsx)(E,{color:`bg-amber-400`,label:`Delayed`,value:t?m(t.delayed):`—`}),(0,C.jsx)(E,{color:`bg-red-400`,label:`Dead Letter`,value:t?m(t.dlq):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:t?p(t.totalPushed):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:t?p(t.totalPulled):`—`}),(0,C.jsx)(E,{color:`bg-emerald-400`,label:`Uptime`,value:t?g(t.uptime/1e3):`—`})]})]})]})}function T({value:e,label:t,danger:n,success:r}){return(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:i(`text-3xl font-bold tnum`,n?`text-danger`:r?`text-success`:`text-fg`),children:e}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:t})]})}function E({color:e,label:t,value:n}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:i(`size-2 rounded-full`,e)}),t]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:n})]})}var D=[`push`,`pull`,`ack`],O=100;function k({latency:e}){return(0,C.jsxs)(s,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:D.map(t=>{let n=e?.percentiles?.[t],r=e?.averages?.[`${t}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:t}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(n?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(n?.p95)}),(0,C.jsx)(`td`,{className:i(`px-5 py-3 text-right tnum`,(n?.p99??0)>O?`text-warning`:`text-muted`),children:j(n?.p99)})]},t)})})]})})]})}function A({rows:e,total:t,page:n,pageSize:r,onPage:a,empty:o}){return(0,C.jsxs)(s,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Prioritized`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:e.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:o})}):e.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:m(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:m(e.counts.prioritized)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:m(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:m(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:m(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:n,pageSize:r,total:t,onPageChange:a,label:`queues`})})]})}function j(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}var M=[`-60s`,`-45s`,`-30s`,`-15s`,`now`];function N({series:e}){let t=e.latest?.throughput,n=x(e.depth),r=e.depth.length?e.depth[e.depth.length-1]:null,a=t=>e.error?(0,C.jsx)(u,{title:`${t} unavailable`,hint:e.error.message}):(0,C.jsx)(l,{label:`Connecting ${t.toLowerCase()}…`});return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),t&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(P,{color:`#ec4899`,label:`Pushed`,value:t.pushPerSec}),(0,C.jsx)(P,{color:`#34d399`,label:`Completed`,value:t.completePerSec}),(0,C.jsx)(P,{color:`#f87171`,label:`Failed`,value:t.failPerSec})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]}):a(`Live throughput`)]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`All non-terminal jobs over time (waiting + prioritized + active + delayed + waiting-children). The trend says whether you're draining or falling behind.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:r==null?`—`:m(r)}),(0,C.jsx)(`div`,{className:i(`text-xs font-medium`,n.label===`draining`?`text-success`:n.label===`accumulating`?`text-danger`:`text-faint`),children:r==null?`unavailable`:n.label===`steady`?`steady`:`${n.slope>0?`+`:``}${n.slope.toFixed(1)}/s · ${n.label}`})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:n.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]}):a(`Queue depth`)]})]})}function P({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}var F=15,I=[];function L(){let e=b(60),[t,n]=(0,S.useState)(0),{data:i,error:o,loading:s,refetch:l}=a(async()=>({details:await r.queuesSummary()}),[]),u=i?.details??I,f=Math.max(1,Math.ceil(u.length/F)),g=Math.min(t,f-1),v=(0,S.useMemo)(()=>u.slice(g*F,g*F+F),[u,g]),y=(0,S.useMemo)(()=>i?u.reduce((e,t)=>e+(t.counts?.failed??0),0):null,[i,u]),x=e.latest?.stats,T=e.latest?.throughput,E=e.latest?.latency,D=x&&y!=null?h(x.completed,y):null,O=s&&!i&&!o,j=!!e.latest&&!e.error&&!!i&&!o,M=o&&!i?`Queue metrics unavailable — ${o.message}`:O?`Loading queue metrics…`:`No queues yet.`;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(d,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:j}),o&&(0,C.jsx)(c,{message:`Queue metrics unavailable — ${o.message}`,onRetry:l}),e.error&&(0,C.jsx)(c,{message:`Live telemetry unavailable — ${e.error.message}. Reconnecting automatically.`}),O&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Loading per-queue metrics…`}),!e.latest&&!e.error&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Connecting live telemetry…`}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(_,{label:`Total Completed`,value:x?p(x.completed):`—`,tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Total Failed`,value:y==null?`—`:m(y),tone:y?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Push/sec`,value:T?T.pushPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(_,{label:`Pull/sec`,value:T?T.pullPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsx)(N,{series:e}),(0,C.jsx)(w,{rate:D,stats:x}),(0,C.jsx)(k,{latency:E}),(0,C.jsx)(A,{rows:v,total:u.length,page:g,pageSize:F,onPage:n,empty:M})]})}export{L as MetricsPro};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,t as n}from"./react-vendor-CFL9l8LK.js";import{t as r}from"./bq-DR2BTISO.js";import{r as i}from"./StatusBadge-DereLzOj.js";import{n as a}from"./usePolledData-CEyyLRYa.js";import{n as o,t as s}from"./Card-egIDLwVk.js";import{i as c,r as l,t as u}from"./feedback-CtGN_kqB.js";import{t as d}from"./PageHeader-CQzNsw8r.js";import{c as f,r as p,s as m,t as h,u as g}from"./format-Cg7VCIZW.js";import{r as _}from"./index-DZFZr0Mi.js";import{t as v}from"./Pagination-CSkzhNW6.js";import{t as y}from"./AreaChart-Db2UVnaK.js";import{n as b,t as x}from"./useThroughputSeries-CeFx-Mwq.js";var S=e(t(),1),C=n();function w({rate:e,stats:t}){return(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Error Rate`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Failed as percentage of total processed`}),(0,C.jsxs)(`div`,{className:`flex items-center justify-around`,children:[(0,C.jsx)(T,{value:e==null?`—`:f(e),label:`error rate`,danger:e!=null&&e>.05}),(0,C.jsx)(T,{value:e==null?`—`:f(1-e),label:`success rate`,success:e!=null})]}),e==null?(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-surface-2`}):(0,C.jsx)(`div`,{className:`mt-4 h-2 overflow-hidden rounded-full bg-red-500/40`,children:(0,C.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${(1-e)*100}%`}})})]}),(0,C.jsxs)(s,{children:[(0,C.jsx)(o,{title:`Server Overview`}),(0,C.jsx)(`p`,{className:`-mt-3 mb-4 text-xs text-faint`,children:`Current server-wide statistics`}),(0,C.jsxs)(`dl`,{className:`divide-y divide-line text-sm`,children:[(0,C.jsx)(E,{color:`bg-blue-400`,label:`Standard waiting`,value:t?m(t.waiting):`—`}),(0,C.jsx)(E,{color:`bg-accent`,label:`Processing`,value:t?m(t.active):`—`}),(0,C.jsx)(E,{color:`bg-amber-400`,label:`Delayed`,value:t?m(t.delayed):`—`}),(0,C.jsx)(E,{color:`bg-red-400`,label:`Dead Letter`,value:t?m(t.dlq):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pushed (since restart)`,value:t?p(t.totalPushed):`—`}),(0,C.jsx)(E,{color:`bg-zinc-500`,label:`Pulled (since restart)`,value:t?p(t.totalPulled):`—`}),(0,C.jsx)(E,{color:`bg-emerald-400`,label:`Uptime`,value:t?g(t.uptime/1e3):`—`})]})]})]})}function T({value:e,label:t,danger:n,success:r}){return(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:i(`text-3xl font-bold tnum`,n?`text-danger`:r?`text-success`:`text-fg`),children:e}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:t})]})}function E({color:e,label:t,value:n}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-between py-2.5`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2 text-muted`,children:[(0,C.jsx)(`span`,{className:i(`size-2 rounded-full`,e)}),t]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:n})]})}var D=[`push`,`pull`,`ack`],O=100;function k({latency:e}){return(0,C.jsxs)(s,{className:`mb-6`,padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Operation Latency`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`TCP round-trip per operation (p50 / p95 / p99, milliseconds)`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Operation`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Avg`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p50`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p95`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`p99`})]})}),(0,C.jsx)(`tbody`,{children:D.map(t=>{let n=e?.percentiles?.[t],r=e?.averages?.[`${t}Ms`];return(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-medium capitalize text-fg`,children:t}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(n?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(n?.p95)}),(0,C.jsx)(`td`,{className:i(`px-5 py-3 text-right tnum`,(n?.p99??0)>O?`text-warning`:`text-muted`),children:j(n?.p99)})]},t)})})]})})]})}function A({rows:e,total:t,page:n,pageSize:r,onPage:a,empty:o}){return(0,C.jsxs)(s,{padded:!1,children:[(0,C.jsxs)(`div`,{className:`border-b border-line px-5 py-4`,children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Per-Queue Metrics`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Job counts breakdown by queue`})]}),(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,C.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Prioritized`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Completed`}),(0,C.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Failed`})]})}),(0,C.jsx)(`tbody`,{children:e.length===0?(0,C.jsx)(`tr`,{children:(0,C.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:o})}):e.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-accent`,children:e.name}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:m(e.counts.waiting)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:m(e.counts.prioritized)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:m(e.counts.active)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:m(e.counts.completed)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-danger`,children:m(e.counts.failed)})]},e.name))})]})}),(0,C.jsx)(`div`,{className:`px-5 pb-4`,children:(0,C.jsx)(v,{page:n,pageSize:r,total:t,onPageChange:a,label:`queues`})})]})}function j(e){return e==null||!Number.isFinite(e)?`—`:`${e<10?e.toFixed(1):Math.round(e)}ms`}var M=[`-60s`,`-45s`,`-30s`,`-15s`,`now`];function N({series:e}){let t=e.latest?.throughput,n=x(e.depth),r=e.depth.length?e.depth[e.depth.length-1]:null,a=t=>e.error?(0,C.jsx)(u,{title:`${t} unavailable`,hint:e.error.message}):(0,C.jsx)(l,{label:`Connecting ${t.toLowerCase()}…`});return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Live Throughput`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`Real-time jobs per second (rolling 60s window)`})]}),t&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 font-mono text-[11px] text-faint`,children:[(0,C.jsx)(P,{color:`#ec4899`,label:`Pushed`,value:t.pushPerSec}),(0,C.jsx)(P,{color:`#34d399`,label:`Completed`,value:t.completePerSec}),(0,C.jsx)(P,{color:`#f87171`,label:`Failed`,value:t.failPerSec})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,series:[{label:`Pushed`,color:`#ec4899`,points:e.push,area:!0},{label:`Completed`,color:`#34d399`,points:e.complete},{label:`Failed`,color:`#f87171`,points:e.fail}]}):a(`Live throughput`)]}),(0,C.jsxs)(s,{className:`mb-6`,children:[(0,C.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Queue Depth`}),(0,C.jsx)(`p`,{className:`text-xs text-faint`,children:`All non-terminal jobs over time (waiting + prioritized + active + delayed + waiting-children). The trend says whether you're draining or falling behind.`})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`tnum text-2xl font-bold text-fg`,children:r==null?`—`:m(r)}),(0,C.jsx)(`div`,{className:i(`text-xs font-medium`,n.label===`draining`?`text-success`:n.label===`accumulating`?`text-danger`:`text-faint`),children:r==null?`unavailable`:n.label===`steady`?`steady`:`${n.slope>0?`+`:``}${n.slope.toFixed(1)}/s · ${n.label}`})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:n.draining?`#34d399`:`#f59e0b`,points:e.depth,area:!0}]}):a(`Queue depth`)]})]})}function P({color:e,label:t,value:n}){return(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e}}),t,` `,(0,C.jsxs)(`span`,{className:`text-fg`,children:[n.toFixed(1),`/s`]})]})}var F=15,I=[];function L(){let e=b(60),[t,n]=(0,S.useState)(0),{data:i,error:o,loading:s,refetch:l}=a(async()=>({details:await r.queuesSummary()}),[]),u=i?.details??I,f=Math.max(1,Math.ceil(u.length/F)),g=Math.min(t,f-1),v=(0,S.useMemo)(()=>u.slice(g*F,g*F+F),[u,g]),y=(0,S.useMemo)(()=>i?u.reduce((e,t)=>e+(t.counts?.failed??0),0):null,[i,u]),x=e.latest?.stats,T=e.latest?.throughput,E=e.latest?.latency,D=x&&y!=null?h(x.completed,y):null,O=s&&!i&&!o,j=!!e.latest&&!e.error&&!!i&&!o,M=o&&!i?`Queue metrics unavailable — ${o.message}`:O?`Loading queue metrics…`:`No queues yet.`;return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(d,{title:`Metrics`,description:`Real-time performance telemetry for your queues.`,live:j}),o&&(0,C.jsx)(c,{message:`Queue metrics unavailable — ${o.message}`,onRetry:l}),e.error&&(0,C.jsx)(c,{message:`Live telemetry unavailable — ${e.error.message}. Reconnecting automatically.`}),O&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Loading per-queue metrics…`}),!e.latest&&!e.error&&(0,C.jsx)(`div`,{role:`status`,className:`mb-4 text-sm text-muted`,children:`Connecting live telemetry…`}),(0,C.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,C.jsx)(_,{label:`Total Completed`,value:x?p(x.completed):`—`,tone:`green`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Total Failed`,value:y==null?`—`:m(y),tone:y?`red`:`default`,hint:`recorded jobs`}),(0,C.jsx)(_,{label:`Push/sec`,value:T?T.pushPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`}),(0,C.jsx)(_,{label:`Pull/sec`,value:T?T.pullPerSec.toFixed(1):`—`,tone:`accent`,hint:`jobs/sec`})]}),(0,C.jsx)(N,{series:e}),(0,C.jsx)(w,{rate:D,stats:x}),(0,C.jsx)(k,{latency:E}),(0,C.jsx)(A,{rows:v,total:u.length,page:g,pageSize:F,onPage:n,empty:M})]})}export{L as MetricsPro};
@@ -1 +1 @@
1
- import{t as e}from"./react-vendor-CFL9l8LK.js";import{A as t,c as n}from"./icons-DH9SS1DA.js";import{t as r}from"./api-D9aT0ND7.js";import{n as i}from"./usePolledData-CEyyLRYa.js";import{n as a,t as o}from"./Card-egIDLwVk.js";import{i as s,n as c,r as l}from"./feedback-CtGN_kqB.js";import{t as u}from"./PageHeader-CQzNsw8r.js";import{c as d,n as f,s as p,t as m,u as h}from"./format-Cg7VCIZW.js";import{r as g}from"./index-Bat1DN5U.js";var _=e(),v={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function y(){let{data:e,error:y,loading:S,refetch:C}=i(()=>r.overview(),[]);if(S&&!e&&!y)return(0,_.jsx)(l,{label:`Loading overview…`});if(y&&!e)return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{title:`Overview`,description:`Live health and throughput across all queues.`}),(0,_.jsx)(c,{error:y,onRetry:C})]});let{stats:w,throughput:T,memory:E,workers:D,crons:O,storage:k}=e??v,A=m(w.totalCompleted,w.totalFailed)??0,j=typeof k.diskFull==`boolean`;return(0,_.jsxs)(`div`,{children:[y&&(0,_.jsx)(s,{message:`Connection lost — showing the last successful overview snapshot.`,onRetry:C}),(0,_.jsx)(u,{title:`Overview`,description:`Live health and throughput across all queues.`,live:!!e&&!y&&j}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,_.jsx)(g,{label:`Waiting`,value:p(w.waiting),tone:`amber`}),(0,_.jsx)(g,{label:`Active`,value:p(w.active),tone:`blue`}),(0,_.jsx)(g,{label:`Completed`,value:p(w.totalCompleted),tone:`green`}),(0,_.jsx)(g,{label:`Failed`,value:p(w.totalFailed),tone:`red`}),(0,_.jsx)(g,{label:`DLQ`,value:p(w.dlq),tone:w.dlq>0?`red`:`default`}),(0,_.jsx)(g,{label:`Error Rate`,value:d(A),tone:A>.05?`red`:`green`})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Throughput`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(b,{label:`Pushed`,value:T.pushPerSec,tone:`text-fg`}),(0,_.jsx)(b,{label:`Pulled`,value:T.pullPerSec,tone:`text-blue-400`}),(0,_.jsx)(b,{label:`Completed`,value:T.completePerSec,tone:`text-emerald-400`}),(0,_.jsx)(b,{label:`Failed`,value:T.failPerSec,tone:`text-red-400`})]})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Resources`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(x,{label:`Uptime`,value:h(w.uptime/1e3)}),(0,_.jsx)(x,{label:`Heap`,value:f(E.heapUsed*1024*1024)}),(0,_.jsx)(x,{label:`RSS`,value:f(E.rss*1024*1024)}),(0,_.jsx)(x,{label:`Storage`,value:j?k.diskFull?`Disk full`:`Healthy`:`Unavailable`,tone:j?k.diskFull?`text-red-400`:`text-emerald-400`:`text-muted`})]})]})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Workers`,icon:(0,_.jsx)(t,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[(0,_.jsx)(`span`,{className:`font-semibold text-emerald-400`,children:D.active}),` /`,` `,D.total,` active`]})}),D.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No workers registered.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:D.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name||e.id}),(0,_.jsxs)(`span`,{className:`text-xs text-faint`,children:[e.queues.join(`, `)||`—`,` · `,p(e.processedJobs),` done`]})]},e.id))})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Cron Jobs`,icon:(0,_.jsx)(n,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[O.total,` scheduled`]})}),O.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No cron jobs.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:O.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),(0,_.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)})]},e.name))})]})]})]})}function b({label:e,value:t,tone:n}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsxs)(`div`,{className:`mt-1 text-2xl font-semibold tnum ${n}`,children:[t.toFixed(1),(0,_.jsx)(`span`,{className:`ml-0.5 text-sm font-normal text-faint`,children:`/s`})]})]})}function x({label:e,value:t,tone:n=`text-fg`}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsx)(`div`,{className:`mt-1 text-base font-semibold ${n}`,children:t})]})}export{y as Overview};
1
+ import{t as e}from"./react-vendor-CFL9l8LK.js";import{A as t,c as n}from"./icons-DH9SS1DA.js";import{t as r}from"./api-D9aT0ND7.js";import{n as i}from"./usePolledData-CEyyLRYa.js";import{n as a,t as o}from"./Card-egIDLwVk.js";import{i as s,n as c,r as l}from"./feedback-CtGN_kqB.js";import{t as u}from"./PageHeader-CQzNsw8r.js";import{c as d,n as f,s as p,t as m,u as h}from"./format-Cg7VCIZW.js";import{r as g}from"./index-DZFZr0Mi.js";var _=e(),v={ok:!1,stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},latency:{averages:{},percentiles:{}},memory:{heapUsed:0,heapTotal:0,rss:0},collections:{},workers:{total:0,active:0,list:[],truncated:!1},crons:{total:0,list:[],truncated:!1},storage:{},timestamp:0};function y(){let{data:e,error:y,loading:S,refetch:C}=i(()=>r.overview(),[]);if(S&&!e&&!y)return(0,_.jsx)(l,{label:`Loading overview…`});if(y&&!e)return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{title:`Overview`,description:`Live health and throughput across all queues.`}),(0,_.jsx)(c,{error:y,onRetry:C})]});let{stats:w,throughput:T,memory:E,workers:D,crons:O,storage:k}=e??v,A=m(w.totalCompleted,w.totalFailed)??0,j=typeof k.diskFull==`boolean`;return(0,_.jsxs)(`div`,{children:[y&&(0,_.jsx)(s,{message:`Connection lost — showing the last successful overview snapshot.`,onRetry:C}),(0,_.jsx)(u,{title:`Overview`,description:`Live health and throughput across all queues.`,live:!!e&&!y&&j}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,_.jsx)(g,{label:`Waiting`,value:p(w.waiting),tone:`amber`}),(0,_.jsx)(g,{label:`Active`,value:p(w.active),tone:`blue`}),(0,_.jsx)(g,{label:`Completed`,value:p(w.totalCompleted),tone:`green`}),(0,_.jsx)(g,{label:`Failed`,value:p(w.totalFailed),tone:`red`}),(0,_.jsx)(g,{label:`DLQ`,value:p(w.dlq),tone:w.dlq>0?`red`:`default`}),(0,_.jsx)(g,{label:`Error Rate`,value:d(A),tone:A>.05?`red`:`green`})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Throughput`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(b,{label:`Pushed`,value:T.pushPerSec,tone:`text-fg`}),(0,_.jsx)(b,{label:`Pulled`,value:T.pullPerSec,tone:`text-blue-400`}),(0,_.jsx)(b,{label:`Completed`,value:T.completePerSec,tone:`text-emerald-400`}),(0,_.jsx)(b,{label:`Failed`,value:T.failPerSec,tone:`text-red-400`})]})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Resources`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,_.jsx)(x,{label:`Uptime`,value:h(w.uptime/1e3)}),(0,_.jsx)(x,{label:`Heap`,value:f(E.heapUsed*1024*1024)}),(0,_.jsx)(x,{label:`RSS`,value:f(E.rss*1024*1024)}),(0,_.jsx)(x,{label:`Storage`,value:j?k.diskFull?`Disk full`:`Healthy`:`Unavailable`,tone:j?k.diskFull?`text-red-400`:`text-emerald-400`:`text-muted`})]})]})]}),(0,_.jsxs)(`div`,{className:`mt-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Workers`,icon:(0,_.jsx)(t,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[(0,_.jsx)(`span`,{className:`font-semibold text-emerald-400`,children:D.active}),` /`,` `,D.total,` active`]})}),D.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No workers registered.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:D.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name||e.id}),(0,_.jsxs)(`span`,{className:`text-xs text-faint`,children:[e.queues.join(`, `)||`—`,` · `,p(e.processedJobs),` done`]})]},e.id))})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(a,{title:`Cron Jobs`,icon:(0,_.jsx)(n,{className:`size-4 text-faint`}),action:(0,_.jsxs)(`span`,{className:`text-sm text-muted`,children:[O.total,` scheduled`]})}),O.list.length===0?(0,_.jsx)(`p`,{className:`py-6 text-center text-sm text-faint`,children:`No cron jobs.`}):(0,_.jsx)(`ul`,{className:`divide-y divide-line`,children:O.list.slice(0,6).map(e=>(0,_.jsxs)(`li`,{className:`flex items-center justify-between py-2 text-sm`,children:[(0,_.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),(0,_.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.schedule??(e.repeatEvery?`every ${e.repeatEvery}ms`:`—`)})]},e.name))})]})]})]})}function b({label:e,value:t,tone:n}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsxs)(`div`,{className:`mt-1 text-2xl font-semibold tnum ${n}`,children:[t.toFixed(1),(0,_.jsx)(`span`,{className:`ml-0.5 text-sm font-normal text-faint`,children:`/s`})]})]})}function x({label:e,value:t,tone:n=`text-fg`}){return(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,_.jsx)(`div`,{className:`mt-1 text-base font-semibold ${n}`,children:t})]})}export{y as Overview};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-CFL9l8LK.js";import{t as i}from"./bq-DR2BTISO.js";import{n as a}from"./StatusBadge-DereLzOj.js";import{n as o}from"./usePolledData-CEyyLRYa.js";import{t as s}from"./Button-_aSJvRoW.js";import{n as c,t as l}from"./Card-egIDLwVk.js";import{i as u,n as d,r as f}from"./feedback-CtGN_kqB.js";import{t as p}from"./PageHeader-CQzNsw8r.js";import{s as m}from"./format-Cg7VCIZW.js";import{r as h}from"./index-Bat1DN5U.js";import{a as g,n as _,t as v}from"./form-DG3X6cLL.js";import{r as y}from"./useServerActionGuard-CUx8TOAC.js";import{t as b}from"./controlConnectionEpoch-ChAeMMLk.js";import{t as x}from"./useControlActionGuard-1i7aFA7E.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./QueueActions-BBxRt-t0.js";var k=e(t(),1),A={limits:async(e,t)=>F(await i.queueOperations.limits(e,t)),group:async(e,t,n,r,a,o)=>j(await i.queueOperations.group(e,t,n,r,a,o)),pauseGroup:async(e,t)=>N(await i.queueOperations.pauseGroup(e,t)),resumeGroup:async(e,t)=>N(await i.queueOperations.resumeGroup(e,t)),setGroupRateLimit:async(e,t,n,r)=>{P(await i.queueOperations.setGroupRateLimit(e,t,n,r))},removeGroupRateLimit:async(e,t)=>L(await i.queueOperations.removeGroupRateLimit(e,t)),setGroupConcurrency:async(e,t,n)=>{P(await i.queueOperations.setGroupConcurrency(e,t,n))},removeGroupConcurrency:async(e,t)=>L(await i.queueOperations.removeGroupConcurrency(e,t)),deduplicationJobId:async(e,t)=>I(await i.queueOperations.deduplicationJobId(e,t)),removeDeduplicationKey:async(e,t)=>L(await i.queueOperations.removeDeduplicationKey(e,t)),metrics:async(e,t,n,r)=>ee(await i.queueOperations.metrics(e,t,n,r)),trimEvents:async(e,t)=>L(await i.queueOperations.trimEvents(e,t))};function j(e){let t=z(R(e,`Queue group`).group,`Queue group`),n=t.rateLimit,r=t.entries,i=t.priorityCounts;if(!H(t.jobs,0)||!H(t.active,0)||!H(t.totalGrouped,0)||typeof t.paused!=`boolean`||!Array.isArray(r)||r.length>100||!r.every(M)||!B(i)||!Object.entries(i).every(([e,t])=>/^\d+$/.test(e)&&Number(e)<=2097151&&H(t,0))||n!==null&&(!B(n)||!V(n.max)||!V(n.duration))||!H(t.rateLimitTtl,-2)||t.concurrency!==null&&!V(t.concurrency))throw U(`Queue group`);return t}function M(e){return B(e)?typeof e.id==`string`&&e.id.length>0&&typeof e.name==`string`&&e.name.length>0&&H(e.priority,0)&&e.priority<=2097151&&H(e.delay,0)&&H(e.timestamp,0):!1}function N(e){let t=R(e,`Queue group mutation`).changed;if(typeof t!=`boolean`)throw U(`Queue group mutation`);return t}function P(e){if(R(e,`Queue mutation`).applied!==!0)throw U(`Queue mutation`)}function F(e){let t=z(R(e,`Queue limits`).limits,`Queue limits`),n=t.rateLimit;if(n!==null&&(!B(n)||!V(n.max)||!V(n.duration))||t.concurrency!==null&&!V(t.concurrency)||!H(t.rateLimitTtl,-2)||typeof t.maxed!=`boolean`)throw U(`Queue limits`);return{rateLimit:n,concurrency:t.concurrency,rateLimitTtl:t.rateLimitTtl,maxed:t.maxed}}function I(e){let t=R(e,`deduplication lookup`).jobId;if(t!==null&&(typeof t!=`string`||!t))throw U(`deduplication lookup`);return t}function L(e){let t=R(e,`Queue mutation`).removed;if(!H(t,0))throw U(`Queue mutation`);return t}function ee(e){let t=z(R(e,`Queue metrics`).metrics,`Queue metrics`),n=z(t.meta,`Queue metrics`);if(!H(n.count,0)||!H(n.prevTS,0)||!H(n.prevCount,0)||!H(t.count,0)||!Array.isArray(t.data)||t.data.length>10001||!t.data.every(e=>H(e,0)))throw U(`Queue metrics`);return t}function R(e,t){let n=z(e,t);if(n.ok!==!0)throw U(t);return n}function z(e,t){if(!B(e))throw U(t);return e}function B(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var V=e=>H(e,1),H=(e,t)=>Number.isSafeInteger(e)&&e>=t,U=e=>Error(`Malformed ${e} response`),W=r();function te({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(``),[o,c]=(0,k.useState)(),[l,u]=(0,k.useState)(``),d=i.length>0&&i.length<=1024;return(0,W.jsxs)(`section`,{"aria-labelledby":`queue-dedup-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,W.jsx)(`h3`,{id:`queue-dedup-title`,className:`text-sm font-semibold text-fg`,children:`Deduplication registry`}),(0,W.jsx)(`p`,{className:`mt-1 mb-4 text-xs leading-5 text-faint`,children:`Resolve an official deduplication ID to its current job, or release only the registry key.`}),(0,W.jsx)(v,{label:`Deduplication ID`,children:(0,W.jsx)(_,{name:`queue-sdk-deduplication-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:i,onChange:e=>{a(e.target.value),c(void 0),u(``)}})}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,W.jsx)(s,{size:`sm`,disabled:!d||!!n,onClick:()=>r(`Looking up deduplication key`,()=>t.deduplicationJobId(e,i),c),children:`Find owner`}),(0,W.jsx)(s,{variant:`warning`,size:`sm`,disabled:!d||!!n,onClick:()=>{window.confirm(`Remove deduplication key "${i}" from queue "${e}"? The job is not deleted, but a later enqueue may reuse this key.`)&&r(`Removing deduplication key`,()=>t.removeDeduplicationKey(e,i),e=>{u(e?`Deduplication key removed.`:`No matching key was active.`),c(void 0)},!0)},children:`Remove key`})]}),o!==void 0&&(0,W.jsx)(`p`,{role:`status`,className:`mt-3 break-all text-xs text-muted`,children:o===null?`No active owner.`:`Current job: ${o}`}),l&&(0,W.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l})]})}function ne({snapshot:e}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{className:`mt-4 grid grid-cols-2 gap-3 rounded-lg border border-line p-3 text-xs sm:grid-cols-4 xl:grid-cols-7`,children:[(0,W.jsx)(G,{label:`Jobs`,value:e.jobs}),(0,W.jsx)(G,{label:`Active`,value:e.active}),(0,W.jsx)(G,{label:`All grouped`,value:e.totalGrouped}),(0,W.jsx)(G,{label:`Rate`,value:e.rateLimit?`${e.rateLimit.max}/${e.rateLimit.duration}ms`:`None`}),(0,W.jsx)(G,{label:`TTL`,value:`${e.rateLimitTtl} ms`}),(0,W.jsx)(G,{label:`Concurrency`,value:e.concurrency??`None`}),(0,W.jsx)(G,{label:`Paused`,value:e.paused?`Yes`:`No`}),(0,W.jsx)(G,{label:`Priority counts`,value:re(e.priorityCounts)})]}),(0,W.jsx)(`div`,{className:`mt-3 overflow-x-auto rounded-lg border border-line`,children:(0,W.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,W.jsx)(`thead`,{className:`border-b border-line text-faint`,children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Pending group job`}),(0,W.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Name`}),(0,W.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Priority`}),(0,W.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Delay`})]})}),(0,W.jsx)(`tbody`,{children:e.entries.length===0?(0,W.jsx)(`tr`,{children:(0,W.jsx)(`td`,{colSpan:4,className:`px-3 py-4 text-center text-faint`,children:`No pending jobs in this page.`})}):e.entries.map(e=>(0,W.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,W.jsx)(`td`,{className:`px-3 py-2 font-mono`,children:(0,W.jsx)(n,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect grouped job ${e.id}`,className:`text-accent hover:underline`,children:e.id})}),(0,W.jsx)(`td`,{className:`px-3 py-2 text-fg`,children:e.name}),(0,W.jsx)(`td`,{className:`px-3 py-2 text-right font-mono`,children:e.priority}),(0,W.jsxs)(`td`,{className:`px-3 py-2 text-right font-mono`,children:[e.delay,` ms`]})]},e.id))})]})})]})}function G({label:e,value:t}){return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-faint`,children:e}),(0,W.jsx)(`dd`,{className:`mt-1 font-mono text-fg`,children:t})]})}var re=e=>{let t=Object.entries(e).sort(([e],[t])=>Number(e)-Number(t));return t.length?t.map(([e,t])=>`${e}: ${t}`).join(` · `):`None`};function ie({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(`default`),[o,c]=(0,k.useState)(``),[l,u]=(0,k.useState)(`100`),[d,f]=(0,k.useState)(`0`),[p,m]=(0,k.useState)(`24`),[h,g]=(0,k.useState)(`100`),[y,b]=(0,k.useState)(`60000`),[x,S]=(0,k.useState)(`1`),[C,w]=(0,k.useState)(null),T=ae(i),E=C?.groupId===i?C.snapshot:null,D=e=>w({groupId:i,snapshot:e}),O=oe(d,p),A=K(h),j=K(y),M=A!==null&&j!==null,N=K(x),P=()=>{let n=q(o,0),i=q(l,1);!T||n===null||i===null||!O||r(`Reading group`,()=>t.group(e,T,n,i,O.start,O.end),D)},F=()=>{let n=K(h),i=K(y);!T||n===null||i===null||r(`Setting group rate limit`,async r=>{if(await t.setGroupRateLimit(e,T,n,i),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0)},I=()=>{let n=K(x);!T||n===null||r(`Setting group concurrency`,async r=>{if(await t.setGroupConcurrency(e,T,n),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0)},L=n=>{T&&r(n?`Pausing group`:`Resuming group`,async r=>{if(n?await t.pauseGroup(e,T):await t.resumeGroup(e,T),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0)};return(0,W.jsxs)(`section`,{className:`xl:col-span-2`,"aria-labelledby":`queue-groups-title`,children:[(0,W.jsx)(`h3`,{id:`queue-groups-title`,className:`mb-3 text-sm font-medium text-fg`,children:`Groups`}),(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-4 xl:grid-cols-8`,children:[(0,W.jsx)(v,{label:`Group ID`,children:(0,W.jsx)(_,{value:i,maxLength:256,onChange:e=>{a(e.target.value),w(null)}})}),(0,W.jsx)(v,{label:`TTL maxJobs`,hint:`Optional`,children:(0,W.jsx)(_,{type:`number`,min:0,value:o,onChange:e=>c(e.target.value)})}),(0,W.jsx)(v,{label:`Groups maxCount`,children:(0,W.jsx)(_,{type:`number`,min:1,value:l,onChange:e=>u(e.target.value)})}),(0,W.jsx)(v,{label:`Jobs start`,children:(0,W.jsx)(_,{type:`number`,min:0,max:1e6,value:d,onChange:e=>f(e.target.value)})}),(0,W.jsx)(v,{label:`Jobs end`,hint:`Inclusive; max 100`,children:(0,W.jsx)(_,{type:`number`,min:0,max:1e6,value:p,onChange:e=>m(e.target.value)})}),(0,W.jsx)(v,{label:`Rate max`,children:(0,W.jsx)(_,{type:`number`,min:1,value:h,onChange:e=>g(e.target.value)})}),(0,W.jsx)(v,{label:`Duration (ms)`,children:(0,W.jsx)(_,{type:`number`,min:1,value:y,onChange:e=>b(e.target.value)})}),(0,W.jsx)(v,{label:`Concurrency`,children:(0,W.jsx)(_,{type:`number`,min:1,value:x,onChange:e=>S(e.target.value)})})]}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||!O,onClick:P,children:`Read group`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||!M,onClick:F,children:`Set rate limit`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T,onClick:()=>r(`Clearing group rate limit`,async n=>{if(await t.removeGroupRateLimit(e,T),!n())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0),children:`Clear rate limit`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||N===null,onClick:I,children:`Set concurrency`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||E?.paused===!0,onClick:()=>L(!0),children:`Pause group`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||E?.paused===!1,onClick:()=>L(!1),children:`Resume group`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T,onClick:()=>r(`Clearing group concurrency`,async n=>{if(await t.removeGroupConcurrency(e,T),!n())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0),children:`Clear concurrency`})]}),!T&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Group ID must contain 1–256 characters and no NUL.`}),!O&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Group job range must be an inclusive page of 1–100 jobs with whole indexes from 0 to 1000000.`}),!M&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Rate max and duration must be positive whole numbers.`}),N===null&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Concurrency must be a positive whole number.`}),E&&(0,W.jsx)(ne,{snapshot:E})]})}var ae=e=>e.length>=1&&e.length<=256&&!e.includes(`\0`)?e:null,K=e=>{let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},q=(e,t)=>{if(!e.trim())return;let n=Number(e);return Number.isSafeInteger(n)&&n>=t?n:null},oe=(e,t)=>{let n=q(e,0),r=q(t,0);return n!=null&&n<=1e6&&r!=null&&r<=1e6&&r>=n&&r-n<100?{start:n,end:r}:null};function se({snapshot:e,loading:t,error:n}){if(t&&!e)return(0,W.jsx)(`p`,{className:`text-sm text-muted`,children:`Reading broker limit state...`});if(n&&!e)return(0,W.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n});if(!e)return null;let r=e.rateLimit;return(0,W.jsxs)(`div`,{children:[n&&(0,W.jsxs)(`p`,{role:`alert`,className:`mb-3 text-xs text-warning`,children:[`Refresh failed. Showing the last successful limit snapshot: `,n]}),(0,W.jsxs)(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,W.jsx)(J,{label:`Global rate limit`,value:r?`${r.max} / ${r.duration} ms`:`Not configured`}),(0,W.jsx)(J,{label:`Rate-limit TTL`,value:e.rateLimitTtl===-2?`No active limit`:`${e.rateLimitTtl} ms`}),(0,W.jsx)(J,{label:`Global concurrency`,value:e.concurrency===null?`Not configured`:String(e.concurrency)}),(0,W.jsx)(J,{label:`Capacity`,value:e.maxed?`Maxed`:`Available`})]})]})}function J({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`min-w-0 border-l-2 border-line pl-3`,children:[(0,W.jsx)(`dt`,{className:`text-[11px] font-medium text-faint`,children:e}),(0,W.jsx)(`dd`,{className:`mt-1 break-words font-mono text-sm text-fg`,children:t})]})}function ce({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(`completed`),[o,c]=(0,k.useState)(`0`),[l,u]=(0,k.useState)(`29`),[d,f]=(0,k.useState)(`1000`),[p,m]=(0,k.useState)(null),[h,y]=(0,k.useState)(``),b=ue(o,l),x=Y(d,0,1e6);return(0,W.jsxs)(`section`,{"aria-labelledby":`queue-telemetry-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,W.jsx)(`h3`,{id:`queue-telemetry-title`,className:`text-sm font-semibold text-fg`,children:`Durable queue telemetry`}),(0,W.jsx)(`p`,{className:`mt-1 mb-4 text-xs leading-5 text-faint`,children:`Read paged one-minute completion or failure buckets, and bound the lifecycle-event journal.`}),(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,W.jsx)(v,{label:`Metric`,children:(0,W.jsxs)(g,{name:`queue-sdk-metric-type`,value:i,onChange:e=>a(e.target.value),children:[(0,W.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,W.jsx)(`option`,{value:`failed`,children:`Failed`})]})}),(0,W.jsx)(v,{label:`Start bucket`,children:(0,W.jsx)(_,{name:`queue-sdk-metric-start`,type:`number`,min:0,max:1e4,value:o,onChange:e=>c(e.target.value)})}),(0,W.jsx)(v,{label:`End bucket`,hint:`Use -1 for all remaining buckets`,children:(0,W.jsx)(_,{name:`queue-sdk-metric-end`,type:`number`,min:-1,max:1e4,value:l,onChange:e=>u(e.target.value)})})]}),(0,W.jsx)(s,{className:`mt-3`,size:`sm`,disabled:!b||!!n,onClick:()=>{b&&r(`Reading ${i} metrics`,()=>t.metrics(e,i,b.start,b.end),m)},children:`Read metrics`}),!b&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:`Use integer buckets from 0 to 10000; end must be -1 or at least start.`}),p&&(0,W.jsx)(le,{metrics:p}),(0,W.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-end gap-3 border-t border-line pt-4`,children:[(0,W.jsx)(`div`,{className:`min-w-48 flex-1`,children:(0,W.jsx)(v,{label:`Retain lifecycle events`,hint:`0 clears the queue journal`,children:(0,W.jsx)(_,{name:`queue-sdk-event-retention`,type:`number`,min:0,max:1e6,value:d,onChange:e=>f(e.target.value)})})}),(0,W.jsx)(s,{variant:`warning`,size:`sm`,disabled:x===null||!!n,onClick:()=>{x!==null&&window.confirm(`Retain at most ${x} lifecycle events for queue "${e}"? Older journal events are permanently removed; metric buckets are unchanged.`)&&r(`Trimming lifecycle journal`,()=>t.trimEvents(e,x),e=>y(`${e} lifecycle events removed.`),!0)},children:`Trim journal`})]}),h&&(0,W.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:h})]})}function le({metrics:e}){let t=e.data.slice(0,120).map((t,n)=>({timestamp:e.meta.prevTS-n*6e4,value:t,offset:n})),n=Math.max(1,...t.map(e=>e.value));return(0,W.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-2 p-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-1 font-mono text-xs text-muted`,children:[(0,W.jsxs)(`span`,{children:[`Total terminal: `,e.meta.count]}),(0,W.jsxs)(`span`,{children:[`Available buckets: `,e.count]}),(0,W.jsxs)(`span`,{children:[`Latest bucket: `,e.meta.prevCount]})]}),t.length?(0,W.jsx)(`div`,{className:`mt-3 flex h-16 items-end gap-px overflow-hidden`,role:`img`,"aria-label":`${t.length} one-minute metric buckets, newest first`,children:t.map(e=>(0,W.jsx)(`span`,{title:`Bucket ${e.offset}: ${e.value}`,className:`min-w-px flex-1 bg-accent/70`,style:{height:`${Math.max(2,e.value/n*100)}%`}},e.timestamp))}):(0,W.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`No buckets in this range.`}),e.data.length>t.length&&(0,W.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Showing the first 120 returned buckets.`})]})}function ue(e,t){let n=Y(e,0,1e4),r=Y(t,-1,1e4);return n===null||r===null||r!==-1&&r<n?null:{start:n,end:r}}function Y(e,t,n){if(e.trim()===``)return null;let r=Number(e);return Number.isSafeInteger(r)&&r>=t&&r<=n?r:null}function de({queue:e,refreshKey:t=0,repository:n=A,onApplied:r}){let i=x(`queue-operations:${e}`),[a,o]=(0,k.useState)(``),[u,d]=(0,k.useState)(null),[f,p]=(0,k.useState)(``),[m,h]=(0,k.useState)(``),g=(0,k.useRef)(!1),y=(0,k.useRef)(0),S=(0,k.useRef)(!0),C=u?.queue===e?u:{queue:e,snapshot:null,loading:!0,error:``};(0,k.useEffect)(()=>(S.current=!0,()=>{S.current=!1,y.current+=1}),[]),(0,k.useEffect)(()=>{y.current+=1,g.current=!1,d(null),p(``),h(``)},[i.scopeKey]);let w=(0,k.useCallback)(async()=>{let t=fe(a);if(t===null){d(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!1,error:`maxJobs must be a whole number from 0 to 1000000.`}));return}let r=++y.current,i=b();d(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!0,error:``}));try{let a=await n.limits(e,t);S.current&&r===y.current&&i===b()&&d({queue:e,snapshot:a,loading:!1,error:``})}catch(t){S.current&&r===y.current&&i===b()&&d({queue:e,snapshot:null,loading:!1,error:pe(t)})}},[a,e,n]);(0,k.useEffect)(()=>void w(),[e,t]);let T=(e,t,n,a=!1)=>{if(g.current)return;let o=i.begin(`queue-sdk-command`);o&&(g.current=!0,p(e),h(``),t(o.isCurrent).then(e=>{!S.current||!o.isCurrent()||(n(e),a&&(r?.(),r||w()))}).catch(e=>{S.current&&o.isCurrent()&&h(pe(e))}).finally(()=>{let e=o.finish();S.current&&e&&(g.current=!1,p(``))}))};return(0,W.jsxs)(l,{className:`mb-6`,children:[(0,W.jsx)(c,{title:`Queue SDK operations`,action:f?(0,W.jsxs)(`span`,{className:`font-mono text-xs text-accent`,children:[f,`...`]}):void 0}),(0,W.jsx)(`p`,{className:`mb-5 max-w-3xl text-xs leading-5 text-faint`,children:`Live Bunqueue 2.9.3 limit, group, deduplication, metric, and event-journal contracts, including group pause, pending jobs, and priority counts. Requests are pinned to the server managed by this control agent.`}),(0,W.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-end gap-3 border-b border-line pb-5`,children:[(0,W.jsx)(`div`,{className:`w-48`,children:(0,W.jsx)(v,{label:`TTL threshold (maxJobs)`,hint:`Optional token-consumption threshold`,children:(0,W.jsx)(_,{name:`queue-sdk-max-jobs`,type:`number`,min:0,max:1e6,step:1,value:a,onChange:e=>o(e.target.value),placeholder:`Not set`})})}),(0,W.jsx)(s,{size:`sm`,disabled:C.loading||!!f,onClick:w,children:`Refresh limits`})]}),(0,W.jsx)(se,{snapshot:C.snapshot,loading:C.loading,error:C.error}),m&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:m}),(0,W.jsxs)(`div`,{className:`mt-6 grid gap-6 xl:grid-cols-[0.8fr_1.2fr]`,children:[(0,W.jsx)(ie,{queue:e,repository:n,busy:f,run:T},`${e}:groups`),(0,W.jsx)(te,{queue:e,repository:n,busy:f,run:T},`${e}:deduplication`),(0,W.jsx)(ce,{queue:e,repository:n,busy:f,run:T},`${e}:telemetry`)]})]})}function fe(e){if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0&&t<=1e6?t:null}var pe=e=>e instanceof Error?e.message:String(e),me=[`waiting`,`prioritized`,`active`,`completed`,`failed`,`delayed`,`waiting-children`,`paused`],X=500,Z=200,he=X*Z;function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ge(e){return Q(e)&&me.every(t=>$(e[t]))}function _e(e,t){if(!Q(e)||e.ok!==!0||!Array.isArray(e.queues)||!$(e.total)||!$(e.limit)||e.limit<1||!$(e.offset)||e.offset!==t||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp)||!e.queues.every(e=>Q(e)&&typeof e.name==`string`&&e.name.length>0&&$(e.waiting)&&$(e.delayed)&&$(e.active)&&$(e.dlq)&&typeof e.paused==`boolean`))throw Error(`Malformed /dashboard/queues response.`)}async function ve(){let e=await i.queues(X,0);_e(e,0);let t=e.total;if(t>he)throw Error(`Queue discovery reported ${t} queues, above the safe dashboard limit of ${he}.`);if(e.queues.length!==Math.min(X,t))throw Error(`Incomplete /dashboard/queues page at offset 0: expected ${Math.min(X,t)} queues, received ${e.queues.length}.`);let n=new Map,r=e=>{for(let t of e.queues){if(n.has(t.name))throw Error(`Overlapping /dashboard/queues pages: queue "${t.name}" appeared more than once.`);n.set(t.name,t)}};r(e);let a=e.queues.length,o=1;for(;a<t;){if(o>=Z)throw Error(`Queue discovery exceeded the safe limit of ${Z} pages.`);let e=await i.queues(X,a);if(_e(e,a),e.total!==t)throw Error(`Queue discovery changed during pagination: total moved from ${t} to ${e.total}. Retry the snapshot.`);let n=Math.min(X,t-a);if(e.queues.length!==n)throw Error(`Incomplete /dashboard/queues page at offset ${a}: expected ${n} queues, received ${e.queues.length}.`);r(e),a+=e.queues.length,o+=1}if(n.size!==t)throw Error(`Incomplete /dashboard/queues snapshot: expected ${t} unique queues, received ${n.size}.`);return{...e,queues:[...n.values()],total:t,limit:X,offset:0}}function ye(e,t){if(!Q(e)||e.ok!==!0||e.name!==t||typeof e.paused!=`boolean`||!ge(e.counts))throw Error(`Malformed queue detail response for "${t}".`)}function be(e){if(!Q(e)||e.ok!==!0||!D(e.config))throw Error(`Malformed /stall-config response.`);return e.config}function xe(e){if(!Q(e)||e.ok!==!0||!T(e.config))throw Error(`Malformed /dlq-config response.`);return e.config}function Se(e){if(!Q(e)||e.ok!==!0)throw Error(`Malformed queue action response: expected { ok: true }.`);if(e.count!==void 0){if(!$(e.count))throw Error(`Malformed queue action response: count must be a non-negative integer.`);return e.count}}function Ce(e,t){return t.some(t=>t.name===e)?e:t[0]?.name??``}function we(){let[e,t]=(0,k.useState)(``),[n,r]=(0,k.useState)(!1),[s,c]=(0,k.useState)(0),[l,_]=(0,k.useState)(null),v=y(`queue-control:${e}`);(0,k.useEffect)(()=>{r(!1),_(null)},[v.scopeKey]);let{data:b,error:x,loading:T,refetch:D}=o(ve,[],{intervalMs:3e4});(0,k.useEffect)(()=>{b&&t(e=>Ce(e,b.queues))},[b]);let{data:A,error:j,loading:M,refetch:N}=o((0,k.useCallback)(async()=>{if(!e)return null;let[t,n,r]=await Promise.all([i.queueDetail(e,!1),i.getStallConfig(e).then(be).catch(()=>null),i.getDlqConfig(e).then(xe).catch(()=>null)]);return ye(t,e),{queue:e,detail:t,stall:n,dlq:r}},[e]),[e]),P=!b||b.queues.some(t=>t.name===e),F=A?.queue===e&&P?A:null,I=(t,n,a,o)=>{let s=e;if(!s||a&&!window.confirm(a))return;let l=v.begin(`queue-write`);l&&(r(!0),_(null),(async()=>{try{let e=await i.queuesSummary();if(!l.isCurrent())return;if(!e.some(e=>e.name===s))throw Error(`Queue "${s}" no longer exists`);let r=Se(await n());if(!l.isCurrent())return;_({queue:s,ok:!0,text:`${t}${r==null?` ✓`:`: ${r}`}`}),o?.(),c(e=>e+1),await N()}catch(e){l.isCurrent()&&_({queue:s,ok:!1,text:e.message})}finally{l.finish()&&r(!1)}})())};return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(p,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!!e&&!!F?.detail&&!!F.stall&&!!F.dlq&&!j&&!x}),(0,W.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`w-56`,children:(0,W.jsx)(g,{value:e,"aria-label":`Queue`,name:`queue-control-queue`,autoComplete:`off`,onChange:e=>t(e.target.value),children:(b?.queues??[]).map(e=>(0,W.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),F?.detail&&(0,W.jsx)(a,{label:F.detail.paused?`Paused`:`Active`,tone:F.detail.paused?`amber`:`green`}),l?.queue===e&&(0,W.jsx)(`span`,{role:`status`,className:l.ok?`text-xs text-success`:`text-xs text-danger`,children:l.text})]}),x&&(0,W.jsx)(u,{onRetry:D,message:`Could not discover queues — ${x.message}. Retry to choose a queue.`}),j&&F&&(0,W.jsx)(u,{message:`Queue refresh failed — showing the last successful configuration.`,onRetry:N}),j&&!F?(0,W.jsx)(d,{error:j,onRetry:N}):T&&!b&&!e&&!x?(0,W.jsx)(f,{label:`Discovering queues…`}):M&&!F?(0,W.jsx)(f,{}):x&&!e?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:`Queue discovery failed. Retry the request above before choosing a queue.`}):F?.detail?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:me.map(e=>(0,W.jsx)(h,{label:e,value:m(F.detail.counts[e]),compact:!0},e))}),(0,W.jsx)(w,{queue:e,paused:F.detail.paused,busy:n,run:I},`${e}:lifecycle`),(0,W.jsx)(O,{queue:e,busy:n,run:I},`${e}:limits`),(0,W.jsx)(de,{queue:e,refreshKey:s,onApplied:()=>c(e=>e+1)},`${v.scopeKey}:${e}:sdk-operations`),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[F.stall?(0,W.jsx)(C,{queue:e,config:F.stall,onSaved:async()=>{_({queue:e,ok:!0,text:`Stall config saved ✓`}),await N()}},`${e}:stall`):(0,W.jsx)(E,{title:`Stall detection`,onRetry:N}),F.dlq?(0,W.jsx)(S,{queue:e,config:F.dlq,onSaved:async()=>{_({queue:e,ok:!0,text:`DLQ config saved ✓`}),await N()}},`${e}:dlq`):(0,W.jsx)(E,{title:`DLQ policy`,onRetry:N})]})]}):!j&&(0,W.jsx)(`p`,{className:`text-sm text-faint`,children:b?.queues.length===0?`No queues are available.`:`Select a queue.`})]})}export{we as QueueControl,ve as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-CFL9l8LK.js";import{t as i}from"./bq-DR2BTISO.js";import{n as a}from"./StatusBadge-DereLzOj.js";import{n as o}from"./usePolledData-CEyyLRYa.js";import{t as s}from"./Button-_aSJvRoW.js";import{n as c,t as l}from"./Card-egIDLwVk.js";import{i as u,n as d,r as f}from"./feedback-CtGN_kqB.js";import{t as p}from"./PageHeader-CQzNsw8r.js";import{s as m}from"./format-Cg7VCIZW.js";import{r as h}from"./index-DZFZr0Mi.js";import{a as g,n as _,t as v}from"./form-DG3X6cLL.js";import{r as y}from"./useServerActionGuard-CUx8TOAC.js";import{t as b}from"./controlConnectionEpoch-ChAeMMLk.js";import{t as x}from"./useControlActionGuard-1i7aFA7E.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./QueueActions-BBxRt-t0.js";var k=e(t(),1),A={limits:async(e,t)=>F(await i.queueOperations.limits(e,t)),group:async(e,t,n,r,a,o)=>j(await i.queueOperations.group(e,t,n,r,a,o)),pauseGroup:async(e,t)=>N(await i.queueOperations.pauseGroup(e,t)),resumeGroup:async(e,t)=>N(await i.queueOperations.resumeGroup(e,t)),setGroupRateLimit:async(e,t,n,r)=>{P(await i.queueOperations.setGroupRateLimit(e,t,n,r))},removeGroupRateLimit:async(e,t)=>L(await i.queueOperations.removeGroupRateLimit(e,t)),setGroupConcurrency:async(e,t,n)=>{P(await i.queueOperations.setGroupConcurrency(e,t,n))},removeGroupConcurrency:async(e,t)=>L(await i.queueOperations.removeGroupConcurrency(e,t)),deduplicationJobId:async(e,t)=>I(await i.queueOperations.deduplicationJobId(e,t)),removeDeduplicationKey:async(e,t)=>L(await i.queueOperations.removeDeduplicationKey(e,t)),metrics:async(e,t,n,r)=>ee(await i.queueOperations.metrics(e,t,n,r)),trimEvents:async(e,t)=>L(await i.queueOperations.trimEvents(e,t))};function j(e){let t=z(R(e,`Queue group`).group,`Queue group`),n=t.rateLimit,r=t.entries,i=t.priorityCounts;if(!H(t.jobs,0)||!H(t.active,0)||!H(t.totalGrouped,0)||typeof t.paused!=`boolean`||!Array.isArray(r)||r.length>100||!r.every(M)||!B(i)||!Object.entries(i).every(([e,t])=>/^\d+$/.test(e)&&Number(e)<=2097151&&H(t,0))||n!==null&&(!B(n)||!V(n.max)||!V(n.duration))||!H(t.rateLimitTtl,-2)||t.concurrency!==null&&!V(t.concurrency))throw U(`Queue group`);return t}function M(e){return B(e)?typeof e.id==`string`&&e.id.length>0&&typeof e.name==`string`&&e.name.length>0&&H(e.priority,0)&&e.priority<=2097151&&H(e.delay,0)&&H(e.timestamp,0):!1}function N(e){let t=R(e,`Queue group mutation`).changed;if(typeof t!=`boolean`)throw U(`Queue group mutation`);return t}function P(e){if(R(e,`Queue mutation`).applied!==!0)throw U(`Queue mutation`)}function F(e){let t=z(R(e,`Queue limits`).limits,`Queue limits`),n=t.rateLimit;if(n!==null&&(!B(n)||!V(n.max)||!V(n.duration))||t.concurrency!==null&&!V(t.concurrency)||!H(t.rateLimitTtl,-2)||typeof t.maxed!=`boolean`)throw U(`Queue limits`);return{rateLimit:n,concurrency:t.concurrency,rateLimitTtl:t.rateLimitTtl,maxed:t.maxed}}function I(e){let t=R(e,`deduplication lookup`).jobId;if(t!==null&&(typeof t!=`string`||!t))throw U(`deduplication lookup`);return t}function L(e){let t=R(e,`Queue mutation`).removed;if(!H(t,0))throw U(`Queue mutation`);return t}function ee(e){let t=z(R(e,`Queue metrics`).metrics,`Queue metrics`),n=z(t.meta,`Queue metrics`);if(!H(n.count,0)||!H(n.prevTS,0)||!H(n.prevCount,0)||!H(t.count,0)||!Array.isArray(t.data)||t.data.length>10001||!t.data.every(e=>H(e,0)))throw U(`Queue metrics`);return t}function R(e,t){let n=z(e,t);if(n.ok!==!0)throw U(t);return n}function z(e,t){if(!B(e))throw U(t);return e}function B(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var V=e=>H(e,1),H=(e,t)=>Number.isSafeInteger(e)&&e>=t,U=e=>Error(`Malformed ${e} response`),W=r();function te({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(``),[o,c]=(0,k.useState)(),[l,u]=(0,k.useState)(``),d=i.length>0&&i.length<=1024;return(0,W.jsxs)(`section`,{"aria-labelledby":`queue-dedup-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,W.jsx)(`h3`,{id:`queue-dedup-title`,className:`text-sm font-semibold text-fg`,children:`Deduplication registry`}),(0,W.jsx)(`p`,{className:`mt-1 mb-4 text-xs leading-5 text-faint`,children:`Resolve an official deduplication ID to its current job, or release only the registry key.`}),(0,W.jsx)(v,{label:`Deduplication ID`,children:(0,W.jsx)(_,{name:`queue-sdk-deduplication-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:i,onChange:e=>{a(e.target.value),c(void 0),u(``)}})}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,W.jsx)(s,{size:`sm`,disabled:!d||!!n,onClick:()=>r(`Looking up deduplication key`,()=>t.deduplicationJobId(e,i),c),children:`Find owner`}),(0,W.jsx)(s,{variant:`warning`,size:`sm`,disabled:!d||!!n,onClick:()=>{window.confirm(`Remove deduplication key "${i}" from queue "${e}"? The job is not deleted, but a later enqueue may reuse this key.`)&&r(`Removing deduplication key`,()=>t.removeDeduplicationKey(e,i),e=>{u(e?`Deduplication key removed.`:`No matching key was active.`),c(void 0)},!0)},children:`Remove key`})]}),o!==void 0&&(0,W.jsx)(`p`,{role:`status`,className:`mt-3 break-all text-xs text-muted`,children:o===null?`No active owner.`:`Current job: ${o}`}),l&&(0,W.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l})]})}function ne({snapshot:e}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{className:`mt-4 grid grid-cols-2 gap-3 rounded-lg border border-line p-3 text-xs sm:grid-cols-4 xl:grid-cols-7`,children:[(0,W.jsx)(G,{label:`Jobs`,value:e.jobs}),(0,W.jsx)(G,{label:`Active`,value:e.active}),(0,W.jsx)(G,{label:`All grouped`,value:e.totalGrouped}),(0,W.jsx)(G,{label:`Rate`,value:e.rateLimit?`${e.rateLimit.max}/${e.rateLimit.duration}ms`:`None`}),(0,W.jsx)(G,{label:`TTL`,value:`${e.rateLimitTtl} ms`}),(0,W.jsx)(G,{label:`Concurrency`,value:e.concurrency??`None`}),(0,W.jsx)(G,{label:`Paused`,value:e.paused?`Yes`:`No`}),(0,W.jsx)(G,{label:`Priority counts`,value:re(e.priorityCounts)})]}),(0,W.jsx)(`div`,{className:`mt-3 overflow-x-auto rounded-lg border border-line`,children:(0,W.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,W.jsx)(`thead`,{className:`border-b border-line text-faint`,children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Pending group job`}),(0,W.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Name`}),(0,W.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Priority`}),(0,W.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Delay`})]})}),(0,W.jsx)(`tbody`,{children:e.entries.length===0?(0,W.jsx)(`tr`,{children:(0,W.jsx)(`td`,{colSpan:4,className:`px-3 py-4 text-center text-faint`,children:`No pending jobs in this page.`})}):e.entries.map(e=>(0,W.jsxs)(`tr`,{className:`border-b border-line last:border-0`,children:[(0,W.jsx)(`td`,{className:`px-3 py-2 font-mono`,children:(0,W.jsx)(n,{to:`/job?id=${encodeURIComponent(e.id)}`,"aria-label":`Inspect grouped job ${e.id}`,className:`text-accent hover:underline`,children:e.id})}),(0,W.jsx)(`td`,{className:`px-3 py-2 text-fg`,children:e.name}),(0,W.jsx)(`td`,{className:`px-3 py-2 text-right font-mono`,children:e.priority}),(0,W.jsxs)(`td`,{className:`px-3 py-2 text-right font-mono`,children:[e.delay,` ms`]})]},e.id))})]})})]})}function G({label:e,value:t}){return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-faint`,children:e}),(0,W.jsx)(`dd`,{className:`mt-1 font-mono text-fg`,children:t})]})}var re=e=>{let t=Object.entries(e).sort(([e],[t])=>Number(e)-Number(t));return t.length?t.map(([e,t])=>`${e}: ${t}`).join(` · `):`None`};function ie({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(`default`),[o,c]=(0,k.useState)(``),[l,u]=(0,k.useState)(`100`),[d,f]=(0,k.useState)(`0`),[p,m]=(0,k.useState)(`24`),[h,g]=(0,k.useState)(`100`),[y,b]=(0,k.useState)(`60000`),[x,S]=(0,k.useState)(`1`),[C,w]=(0,k.useState)(null),T=ae(i),E=C?.groupId===i?C.snapshot:null,D=e=>w({groupId:i,snapshot:e}),O=oe(d,p),A=K(h),j=K(y),M=A!==null&&j!==null,N=K(x),P=()=>{let n=q(o,0),i=q(l,1);!T||n===null||i===null||!O||r(`Reading group`,()=>t.group(e,T,n,i,O.start,O.end),D)},F=()=>{let n=K(h),i=K(y);!T||n===null||i===null||r(`Setting group rate limit`,async r=>{if(await t.setGroupRateLimit(e,T,n,i),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0)},I=()=>{let n=K(x);!T||n===null||r(`Setting group concurrency`,async r=>{if(await t.setGroupConcurrency(e,T,n),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0)},L=n=>{T&&r(n?`Pausing group`:`Resuming group`,async r=>{if(n?await t.pauseGroup(e,T):await t.resumeGroup(e,T),!r())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0)};return(0,W.jsxs)(`section`,{className:`xl:col-span-2`,"aria-labelledby":`queue-groups-title`,children:[(0,W.jsx)(`h3`,{id:`queue-groups-title`,className:`mb-3 text-sm font-medium text-fg`,children:`Groups`}),(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-4 xl:grid-cols-8`,children:[(0,W.jsx)(v,{label:`Group ID`,children:(0,W.jsx)(_,{value:i,maxLength:256,onChange:e=>{a(e.target.value),w(null)}})}),(0,W.jsx)(v,{label:`TTL maxJobs`,hint:`Optional`,children:(0,W.jsx)(_,{type:`number`,min:0,value:o,onChange:e=>c(e.target.value)})}),(0,W.jsx)(v,{label:`Groups maxCount`,children:(0,W.jsx)(_,{type:`number`,min:1,value:l,onChange:e=>u(e.target.value)})}),(0,W.jsx)(v,{label:`Jobs start`,children:(0,W.jsx)(_,{type:`number`,min:0,max:1e6,value:d,onChange:e=>f(e.target.value)})}),(0,W.jsx)(v,{label:`Jobs end`,hint:`Inclusive; max 100`,children:(0,W.jsx)(_,{type:`number`,min:0,max:1e6,value:p,onChange:e=>m(e.target.value)})}),(0,W.jsx)(v,{label:`Rate max`,children:(0,W.jsx)(_,{type:`number`,min:1,value:h,onChange:e=>g(e.target.value)})}),(0,W.jsx)(v,{label:`Duration (ms)`,children:(0,W.jsx)(_,{type:`number`,min:1,value:y,onChange:e=>b(e.target.value)})}),(0,W.jsx)(v,{label:`Concurrency`,children:(0,W.jsx)(_,{type:`number`,min:1,value:x,onChange:e=>S(e.target.value)})})]}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||!O,onClick:P,children:`Read group`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||!M,onClick:F,children:`Set rate limit`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T,onClick:()=>r(`Clearing group rate limit`,async n=>{if(await t.removeGroupRateLimit(e,T),!n())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0),children:`Clear rate limit`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||N===null,onClick:I,children:`Set concurrency`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||E?.paused===!0,onClick:()=>L(!0),children:`Pause group`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T||E?.paused===!1,onClick:()=>L(!1),children:`Resume group`}),(0,W.jsx)(s,{size:`sm`,disabled:!!n||!T,onClick:()=>r(`Clearing group concurrency`,async n=>{if(await t.removeGroupConcurrency(e,T),!n())throw Error(`Queue operations target changed.`);return t.group(e,T)},D,!0),children:`Clear concurrency`})]}),!T&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Group ID must contain 1–256 characters and no NUL.`}),!O&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Group job range must be an inclusive page of 1–100 jobs with whole indexes from 0 to 1000000.`}),!M&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Rate max and duration must be positive whole numbers.`}),N===null&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Concurrency must be a positive whole number.`}),E&&(0,W.jsx)(ne,{snapshot:E})]})}var ae=e=>e.length>=1&&e.length<=256&&!e.includes(`\0`)?e:null,K=e=>{let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},q=(e,t)=>{if(!e.trim())return;let n=Number(e);return Number.isSafeInteger(n)&&n>=t?n:null},oe=(e,t)=>{let n=q(e,0),r=q(t,0);return n!=null&&n<=1e6&&r!=null&&r<=1e6&&r>=n&&r-n<100?{start:n,end:r}:null};function se({snapshot:e,loading:t,error:n}){if(t&&!e)return(0,W.jsx)(`p`,{className:`text-sm text-muted`,children:`Reading broker limit state...`});if(n&&!e)return(0,W.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n});if(!e)return null;let r=e.rateLimit;return(0,W.jsxs)(`div`,{children:[n&&(0,W.jsxs)(`p`,{role:`alert`,className:`mb-3 text-xs text-warning`,children:[`Refresh failed. Showing the last successful limit snapshot: `,n]}),(0,W.jsxs)(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,W.jsx)(J,{label:`Global rate limit`,value:r?`${r.max} / ${r.duration} ms`:`Not configured`}),(0,W.jsx)(J,{label:`Rate-limit TTL`,value:e.rateLimitTtl===-2?`No active limit`:`${e.rateLimitTtl} ms`}),(0,W.jsx)(J,{label:`Global concurrency`,value:e.concurrency===null?`Not configured`:String(e.concurrency)}),(0,W.jsx)(J,{label:`Capacity`,value:e.maxed?`Maxed`:`Available`})]})]})}function J({label:e,value:t}){return(0,W.jsxs)(`div`,{className:`min-w-0 border-l-2 border-line pl-3`,children:[(0,W.jsx)(`dt`,{className:`text-[11px] font-medium text-faint`,children:e}),(0,W.jsx)(`dd`,{className:`mt-1 break-words font-mono text-sm text-fg`,children:t})]})}function ce({queue:e,repository:t,busy:n,run:r}){let[i,a]=(0,k.useState)(`completed`),[o,c]=(0,k.useState)(`0`),[l,u]=(0,k.useState)(`29`),[d,f]=(0,k.useState)(`1000`),[p,m]=(0,k.useState)(null),[h,y]=(0,k.useState)(``),b=ue(o,l),x=Y(d,0,1e6);return(0,W.jsxs)(`section`,{"aria-labelledby":`queue-telemetry-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,W.jsx)(`h3`,{id:`queue-telemetry-title`,className:`text-sm font-semibold text-fg`,children:`Durable queue telemetry`}),(0,W.jsx)(`p`,{className:`mt-1 mb-4 text-xs leading-5 text-faint`,children:`Read paged one-minute completion or failure buckets, and bound the lifecycle-event journal.`}),(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,W.jsx)(v,{label:`Metric`,children:(0,W.jsxs)(g,{name:`queue-sdk-metric-type`,value:i,onChange:e=>a(e.target.value),children:[(0,W.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,W.jsx)(`option`,{value:`failed`,children:`Failed`})]})}),(0,W.jsx)(v,{label:`Start bucket`,children:(0,W.jsx)(_,{name:`queue-sdk-metric-start`,type:`number`,min:0,max:1e4,value:o,onChange:e=>c(e.target.value)})}),(0,W.jsx)(v,{label:`End bucket`,hint:`Use -1 for all remaining buckets`,children:(0,W.jsx)(_,{name:`queue-sdk-metric-end`,type:`number`,min:-1,max:1e4,value:l,onChange:e=>u(e.target.value)})})]}),(0,W.jsx)(s,{className:`mt-3`,size:`sm`,disabled:!b||!!n,onClick:()=>{b&&r(`Reading ${i} metrics`,()=>t.metrics(e,i,b.start,b.end),m)},children:`Read metrics`}),!b&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:`Use integer buckets from 0 to 10000; end must be -1 or at least start.`}),p&&(0,W.jsx)(le,{metrics:p}),(0,W.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-end gap-3 border-t border-line pt-4`,children:[(0,W.jsx)(`div`,{className:`min-w-48 flex-1`,children:(0,W.jsx)(v,{label:`Retain lifecycle events`,hint:`0 clears the queue journal`,children:(0,W.jsx)(_,{name:`queue-sdk-event-retention`,type:`number`,min:0,max:1e6,value:d,onChange:e=>f(e.target.value)})})}),(0,W.jsx)(s,{variant:`warning`,size:`sm`,disabled:x===null||!!n,onClick:()=>{x!==null&&window.confirm(`Retain at most ${x} lifecycle events for queue "${e}"? Older journal events are permanently removed; metric buckets are unchanged.`)&&r(`Trimming lifecycle journal`,()=>t.trimEvents(e,x),e=>y(`${e} lifecycle events removed.`),!0)},children:`Trim journal`})]}),h&&(0,W.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:h})]})}function le({metrics:e}){let t=e.data.slice(0,120).map((t,n)=>({timestamp:e.meta.prevTS-n*6e4,value:t,offset:n})),n=Math.max(1,...t.map(e=>e.value));return(0,W.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-2 p-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-1 font-mono text-xs text-muted`,children:[(0,W.jsxs)(`span`,{children:[`Total terminal: `,e.meta.count]}),(0,W.jsxs)(`span`,{children:[`Available buckets: `,e.count]}),(0,W.jsxs)(`span`,{children:[`Latest bucket: `,e.meta.prevCount]})]}),t.length?(0,W.jsx)(`div`,{className:`mt-3 flex h-16 items-end gap-px overflow-hidden`,role:`img`,"aria-label":`${t.length} one-minute metric buckets, newest first`,children:t.map(e=>(0,W.jsx)(`span`,{title:`Bucket ${e.offset}: ${e.value}`,className:`min-w-px flex-1 bg-accent/70`,style:{height:`${Math.max(2,e.value/n*100)}%`}},e.timestamp))}):(0,W.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`No buckets in this range.`}),e.data.length>t.length&&(0,W.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Showing the first 120 returned buckets.`})]})}function ue(e,t){let n=Y(e,0,1e4),r=Y(t,-1,1e4);return n===null||r===null||r!==-1&&r<n?null:{start:n,end:r}}function Y(e,t,n){if(e.trim()===``)return null;let r=Number(e);return Number.isSafeInteger(r)&&r>=t&&r<=n?r:null}function de({queue:e,refreshKey:t=0,repository:n=A,onApplied:r}){let i=x(`queue-operations:${e}`),[a,o]=(0,k.useState)(``),[u,d]=(0,k.useState)(null),[f,p]=(0,k.useState)(``),[m,h]=(0,k.useState)(``),g=(0,k.useRef)(!1),y=(0,k.useRef)(0),S=(0,k.useRef)(!0),C=u?.queue===e?u:{queue:e,snapshot:null,loading:!0,error:``};(0,k.useEffect)(()=>(S.current=!0,()=>{S.current=!1,y.current+=1}),[]),(0,k.useEffect)(()=>{y.current+=1,g.current=!1,d(null),p(``),h(``)},[i.scopeKey]);let w=(0,k.useCallback)(async()=>{let t=fe(a);if(t===null){d(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!1,error:`maxJobs must be a whole number from 0 to 1000000.`}));return}let r=++y.current,i=b();d(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!0,error:``}));try{let a=await n.limits(e,t);S.current&&r===y.current&&i===b()&&d({queue:e,snapshot:a,loading:!1,error:``})}catch(t){S.current&&r===y.current&&i===b()&&d({queue:e,snapshot:null,loading:!1,error:pe(t)})}},[a,e,n]);(0,k.useEffect)(()=>void w(),[e,t]);let T=(e,t,n,a=!1)=>{if(g.current)return;let o=i.begin(`queue-sdk-command`);o&&(g.current=!0,p(e),h(``),t(o.isCurrent).then(e=>{!S.current||!o.isCurrent()||(n(e),a&&(r?.(),r||w()))}).catch(e=>{S.current&&o.isCurrent()&&h(pe(e))}).finally(()=>{let e=o.finish();S.current&&e&&(g.current=!1,p(``))}))};return(0,W.jsxs)(l,{className:`mb-6`,children:[(0,W.jsx)(c,{title:`Queue SDK operations`,action:f?(0,W.jsxs)(`span`,{className:`font-mono text-xs text-accent`,children:[f,`...`]}):void 0}),(0,W.jsx)(`p`,{className:`mb-5 max-w-3xl text-xs leading-5 text-faint`,children:`Live Bunqueue 2.9.3 limit, group, deduplication, metric, and event-journal contracts, including group pause, pending jobs, and priority counts. Requests are pinned to the server managed by this control agent.`}),(0,W.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-end gap-3 border-b border-line pb-5`,children:[(0,W.jsx)(`div`,{className:`w-48`,children:(0,W.jsx)(v,{label:`TTL threshold (maxJobs)`,hint:`Optional token-consumption threshold`,children:(0,W.jsx)(_,{name:`queue-sdk-max-jobs`,type:`number`,min:0,max:1e6,step:1,value:a,onChange:e=>o(e.target.value),placeholder:`Not set`})})}),(0,W.jsx)(s,{size:`sm`,disabled:C.loading||!!f,onClick:w,children:`Refresh limits`})]}),(0,W.jsx)(se,{snapshot:C.snapshot,loading:C.loading,error:C.error}),m&&(0,W.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:m}),(0,W.jsxs)(`div`,{className:`mt-6 grid gap-6 xl:grid-cols-[0.8fr_1.2fr]`,children:[(0,W.jsx)(ie,{queue:e,repository:n,busy:f,run:T},`${e}:groups`),(0,W.jsx)(te,{queue:e,repository:n,busy:f,run:T},`${e}:deduplication`),(0,W.jsx)(ce,{queue:e,repository:n,busy:f,run:T},`${e}:telemetry`)]})]})}function fe(e){if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0&&t<=1e6?t:null}var pe=e=>e instanceof Error?e.message:String(e),me=[`waiting`,`prioritized`,`active`,`completed`,`failed`,`delayed`,`waiting-children`,`paused`],X=500,Z=200,he=X*Z;function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ge(e){return Q(e)&&me.every(t=>$(e[t]))}function _e(e,t){if(!Q(e)||e.ok!==!0||!Array.isArray(e.queues)||!$(e.total)||!$(e.limit)||e.limit<1||!$(e.offset)||e.offset!==t||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp)||!e.queues.every(e=>Q(e)&&typeof e.name==`string`&&e.name.length>0&&$(e.waiting)&&$(e.delayed)&&$(e.active)&&$(e.dlq)&&typeof e.paused==`boolean`))throw Error(`Malformed /dashboard/queues response.`)}async function ve(){let e=await i.queues(X,0);_e(e,0);let t=e.total;if(t>he)throw Error(`Queue discovery reported ${t} queues, above the safe dashboard limit of ${he}.`);if(e.queues.length!==Math.min(X,t))throw Error(`Incomplete /dashboard/queues page at offset 0: expected ${Math.min(X,t)} queues, received ${e.queues.length}.`);let n=new Map,r=e=>{for(let t of e.queues){if(n.has(t.name))throw Error(`Overlapping /dashboard/queues pages: queue "${t.name}" appeared more than once.`);n.set(t.name,t)}};r(e);let a=e.queues.length,o=1;for(;a<t;){if(o>=Z)throw Error(`Queue discovery exceeded the safe limit of ${Z} pages.`);let e=await i.queues(X,a);if(_e(e,a),e.total!==t)throw Error(`Queue discovery changed during pagination: total moved from ${t} to ${e.total}. Retry the snapshot.`);let n=Math.min(X,t-a);if(e.queues.length!==n)throw Error(`Incomplete /dashboard/queues page at offset ${a}: expected ${n} queues, received ${e.queues.length}.`);r(e),a+=e.queues.length,o+=1}if(n.size!==t)throw Error(`Incomplete /dashboard/queues snapshot: expected ${t} unique queues, received ${n.size}.`);return{...e,queues:[...n.values()],total:t,limit:X,offset:0}}function ye(e,t){if(!Q(e)||e.ok!==!0||e.name!==t||typeof e.paused!=`boolean`||!ge(e.counts))throw Error(`Malformed queue detail response for "${t}".`)}function be(e){if(!Q(e)||e.ok!==!0||!D(e.config))throw Error(`Malformed /stall-config response.`);return e.config}function xe(e){if(!Q(e)||e.ok!==!0||!T(e.config))throw Error(`Malformed /dlq-config response.`);return e.config}function Se(e){if(!Q(e)||e.ok!==!0)throw Error(`Malformed queue action response: expected { ok: true }.`);if(e.count!==void 0){if(!$(e.count))throw Error(`Malformed queue action response: count must be a non-negative integer.`);return e.count}}function Ce(e,t){return t.some(t=>t.name===e)?e:t[0]?.name??``}function we(){let[e,t]=(0,k.useState)(``),[n,r]=(0,k.useState)(!1),[s,c]=(0,k.useState)(0),[l,_]=(0,k.useState)(null),v=y(`queue-control:${e}`);(0,k.useEffect)(()=>{r(!1),_(null)},[v.scopeKey]);let{data:b,error:x,loading:T,refetch:D}=o(ve,[],{intervalMs:3e4});(0,k.useEffect)(()=>{b&&t(e=>Ce(e,b.queues))},[b]);let{data:A,error:j,loading:M,refetch:N}=o((0,k.useCallback)(async()=>{if(!e)return null;let[t,n,r]=await Promise.all([i.queueDetail(e,!1),i.getStallConfig(e).then(be).catch(()=>null),i.getDlqConfig(e).then(xe).catch(()=>null)]);return ye(t,e),{queue:e,detail:t,stall:n,dlq:r}},[e]),[e]),P=!b||b.queues.some(t=>t.name===e),F=A?.queue===e&&P?A:null,I=(t,n,a,o)=>{let s=e;if(!s||a&&!window.confirm(a))return;let l=v.begin(`queue-write`);l&&(r(!0),_(null),(async()=>{try{let e=await i.queuesSummary();if(!l.isCurrent())return;if(!e.some(e=>e.name===s))throw Error(`Queue "${s}" no longer exists`);let r=Se(await n());if(!l.isCurrent())return;_({queue:s,ok:!0,text:`${t}${r==null?` ✓`:`: ${r}`}`}),o?.(),c(e=>e+1),await N()}catch(e){l.isCurrent()&&_({queue:s,ok:!1,text:e.message})}finally{l.finish()&&r(!1)}})())};return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(p,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!!e&&!!F?.detail&&!!F.stall&&!!F.dlq&&!j&&!x}),(0,W.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,W.jsx)(`div`,{className:`w-56`,children:(0,W.jsx)(g,{value:e,"aria-label":`Queue`,name:`queue-control-queue`,autoComplete:`off`,onChange:e=>t(e.target.value),children:(b?.queues??[]).map(e=>(0,W.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),F?.detail&&(0,W.jsx)(a,{label:F.detail.paused?`Paused`:`Active`,tone:F.detail.paused?`amber`:`green`}),l?.queue===e&&(0,W.jsx)(`span`,{role:`status`,className:l.ok?`text-xs text-success`:`text-xs text-danger`,children:l.text})]}),x&&(0,W.jsx)(u,{onRetry:D,message:`Could not discover queues — ${x.message}. Retry to choose a queue.`}),j&&F&&(0,W.jsx)(u,{message:`Queue refresh failed — showing the last successful configuration.`,onRetry:N}),j&&!F?(0,W.jsx)(d,{error:j,onRetry:N}):T&&!b&&!e&&!x?(0,W.jsx)(f,{label:`Discovering queues…`}):M&&!F?(0,W.jsx)(f,{}):x&&!e?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:`Queue discovery failed. Retry the request above before choosing a queue.`}):F?.detail?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:me.map(e=>(0,W.jsx)(h,{label:e,value:m(F.detail.counts[e]),compact:!0},e))}),(0,W.jsx)(w,{queue:e,paused:F.detail.paused,busy:n,run:I},`${e}:lifecycle`),(0,W.jsx)(O,{queue:e,busy:n,run:I},`${e}:limits`),(0,W.jsx)(de,{queue:e,refreshKey:s,onApplied:()=>c(e=>e+1)},`${v.scopeKey}:${e}:sdk-operations`),(0,W.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[F.stall?(0,W.jsx)(C,{queue:e,config:F.stall,onSaved:async()=>{_({queue:e,ok:!0,text:`Stall config saved ✓`}),await N()}},`${e}:stall`):(0,W.jsx)(E,{title:`Stall detection`,onRetry:N}),F.dlq?(0,W.jsx)(S,{queue:e,config:F.dlq,onSaved:async()=>{_({queue:e,ok:!0,text:`DLQ config saved ✓`}),await N()}},`${e}:dlq`):(0,W.jsx)(E,{title:`DLQ policy`,onRetry:N})]})]}):!j&&(0,W.jsx)(`p`,{className:`text-sm text-faint`,children:b?.queues.length===0?`No queues are available.`:`Select a queue.`})]})}export{we as QueueControl,ve as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,g as n,r,t as i}from"./react-vendor-CFL9l8LK.js";import{t as a}from"./bq-DR2BTISO.js";import{A as o,b as s,i as c,m as l,n as u,x as d}from"./icons-DH9SS1DA.js";import{n as f,t as p}from"./StatusBadge-DereLzOj.js";import{t as m}from"./api-D9aT0ND7.js";import{n as h}from"./usePolledData-CEyyLRYa.js";import{t as g}from"./Button-_aSJvRoW.js";import{t as _}from"./Card-egIDLwVk.js";import{i as v,r as y,t as b}from"./feedback-CtGN_kqB.js";import{a as x,c as S,d as C,l as w,s as T,t as E}from"./format-Cg7VCIZW.js";import{r as D}from"./index-Bat1DN5U.js";import{a as O,n as k,t as A}from"./form-DG3X6cLL.js";import{r as j,t as M}from"./useServerActionGuard-CUx8TOAC.js";import{r as N}from"./flowMutationSafety-YKTHxqKv.js";import{i as P}from"./classicJobsData-Csj4iihY.js";var F=e(n(),1),I=i();function L({queue:e}){return(0,I.jsxs)(`div`,{className:`mt-8`,children:[(0,I.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,I.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:`Bunqueue v2.9.3 cannot read either current policy. Every command below is an explicit blind desired-state write; a receipt proves only what this dashboard applied at that time.`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,I.jsx)(B,{queue:e}),(0,I.jsx)(V,{queue:e})]})]})}function R(e){if(!e.trim())return null;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null}function z(e,t){let[n,r]=(0,F.useState)(!1),[i,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(null),l=j(`classic-queue-policy:${e}:${t}`);return(0,F.useEffect)(()=>{r(!1),o(null),c(null)},[l.scopeKey]),{busy:n,error:i,receipt:s,run:async(n,i,s)=>{if(!window.confirm(i))return;let u=l.begin(t);if(u){r(!0),o(null),c(null);try{let t=await a.queuesSummary();if(!u.isCurrent())return;if(!t.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await s(),n),!u.isCurrent())return;c(`${n} applied at ${new Date().toISOString()}. Current server state cannot be read.`)}catch(e){u.isCurrent()&&o(e.message)}finally{u.finish()&&r(!1)}}}}}function B({queue:e}){let[t,n]=(0,F.useState)(``),[r,i]=(0,F.useState)(``),[o,s]=(0,F.useState)(`permanent`),[c,u]=(0,F.useState)(``),[d,f]=(0,F.useState)(``),{busy:p,error:m,receipt:h,run:v}=z(e,`rate-limit`),y=R(t),b=R(r),x=o===`expires`?R(c):void 0,S=y!==null&&b!==null&&(o===`permanent`||x!=null);return(0,I.jsxs)(_,{children:[(0,I.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate-limit desired state`}),(0,I.jsx)(l,{className:`size-4 text-faint`})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,I.jsx)(A,{label:`Limit`,children:(0,I.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-limit`,value:t,"aria-invalid":t.trim()!==``&&y===null,onChange:e=>n(e.target.value),placeholder:`100`})}),(0,I.jsx)(A,{label:`Window (ms)`,children:(0,I.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-duration`,value:r,"aria-invalid":r.trim()!==``&&b===null,onChange:e=>i(e.target.value),placeholder:`60000`})}),(0,I.jsx)(A,{label:`TTL`,children:(0,I.jsxs)(O,{name:`classic-rate-ttl-mode`,value:o,onChange:e=>s(e.target.value),children:[(0,I.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,I.jsx)(`option`,{value:`expires`,children:`Expires after`})]})}),(0,I.jsx)(A,{label:`TTL (ms)`,hint:o===`permanent`?`Not sent`:void 0,children:(0,I.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-ttl`,disabled:o===`permanent`,value:c,"aria-invalid":o===`expires`&&c.trim()!==``&&x==null,onChange:e=>u(e.target.value),placeholder:`3600000`})})]}),(0,I.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:(0,I.jsx)(g,{variant:`accent`,size:`sm`,disabled:p||!S,onClick:()=>{if(y===null||b===null||o===`expires`&&x===null)return;let t=typeof x==`number`?x:void 0,n=o===`permanent`?`permanent`:`TTL ${x}ms`;v(`Rate-limit policy replaced`,`Replace the unknown rate-limit policy for "${e}" with limit ${y}, window ${b}ms, ${n}?`,()=>a.setRateLimit(e,y,b,t))},children:`Replace rate-limit policy`})}),(0,I.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,I.jsx)(A,{label:`Type ${e} to clear`,children:(0,I.jsx)(k,{name:`classic-rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:d,onChange:e=>f(e.target.value)})}),(0,I.jsx)(g,{className:`mt-2`,size:`sm`,disabled:p||d!==e,onClick:()=>void v(`No rate limit ensured`,`Ensure queue "${e}" has no rate-limit policy? The previous value is unavailable.`,()=>a.clearRateLimit(e)),children:`Ensure no rate limit`})]}),h&&(0,I.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:h}),m&&(0,I.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:m})]})}function V({queue:e}){let[t,n]=(0,F.useState)(``),[r,i]=(0,F.useState)(``),{busy:s,error:c,receipt:l,run:u}=z(e,`concurrency`),d=R(t);return(0,I.jsxs)(_,{children:[(0,I.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency desired state`}),(0,I.jsx)(o,{className:`size-4 text-faint`})]}),(0,I.jsx)(A,{label:`Maximum in-flight jobs`,children:(0,I.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-concurrency`,value:t,"aria-invalid":t.trim()!==``&&d===null,onChange:e=>n(e.target.value),placeholder:`5`})}),(0,I.jsx)(`div`,{className:`mt-4 flex items-center gap-2`,children:(0,I.jsx)(g,{variant:`accent`,size:`sm`,disabled:s||d===null,onClick:()=>{d!==null&&u(`Concurrency policy replaced`,`Replace the unknown concurrency policy for "${e}" with ${d} maximum in-flight jobs?`,()=>a.setConcurrency(e,d))},children:`Replace concurrency policy`})}),(0,I.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,I.jsx)(A,{label:`Type ${e} to clear`,children:(0,I.jsx)(k,{name:`classic-concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value)})}),(0,I.jsx)(g,{className:`mt-2`,size:`sm`,disabled:s||r!==e,onClick:()=>void u(`No concurrency limit ensured`,`Ensure queue "${e}" has no concurrency policy? The previous value is unavailable.`,()=>a.clearConcurrency(e)),children:`Ensure no concurrency limit`})]}),l&&(0,I.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l}),c&&(0,I.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c})]})}var H=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`,`paused`],U={detail:{ok:!1,name:``,counts:{waiting:0,active:0,completed:0,failed:0,delayed:0,prioritized:0,"waiting-children":0,paused:0},paused:!1,priorityCounts:{},dlqPreview:[],timestamp:0},jobs:[],recentJobsError:null};function W(){let{name:e=``}=t(),[n,i]=(0,F.useState)(null),[o,l]=(0,F.useState)(null),_=j(`classic-queue:${e}`);(0,F.useEffect)(()=>{i(null),l(null)},[_.scopeKey]);let{data:O,error:k,loading:A,refetch:R}=h((0,F.useCallback)(async()=>{if(!(await a.queuesSummary()).some(t=>t.name===e))return{exists:!1,detail:null,jobs:[],recentJobsError:null};let[t,n]=await Promise.all([m.queueDetail(e,!1),m.jobsList(e,{states:H,limit:12}).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);if(t.ok!==!0||t.name!==e)throw Error(`Malformed queue detail response for "${e}"`);return{exists:!0,detail:t,jobs:n.jobs,recentJobsError:n.error}},[e]),[e]),z=async(t,n,r)=>{if(r&&!window.confirm(r))return;let o=_.begin(t);if(o){i(t),l(null);try{let r=await a.queuesSummary();if(!o.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await n(),t),!o.isCurrent())return;await R()}catch(e){o.isCurrent()&&l(e.message)}finally{o.finish()&&i(null)}}};if(A&&!O&&!k)return(0,I.jsx)(y,{label:`Loading ${e}…`});if(k&&!O)return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,I.jsx)(v,{onRetry:R})]});if(O?.exists===!1)return(0,I.jsxs)(`div`,{children:[k&&(0,I.jsx)(v,{onRetry:R}),(0,I.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,I.jsx)(b,{title:`Queue not found`,hint:`No queue named "${e}" exists on the current Bunqueue server.`,action:(0,I.jsx)(r,{to:`/queues-classic`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to classic queues`})})]});let B=O?.exists===!0?O:U,{detail:V}=B,W=V.counts,G=E(W.completed??0,W.failed??0),K=[...B.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,I.jsxs)(`div`,{children:[k&&(0,I.jsx)(v,{onRetry:R}),(0,I.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(r,{to:`/queues-classic`,"aria-label":`Back to classic queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,I.jsx)(c,{className:`size-4`})}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,I.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,I.jsx)(f,{label:V.paused?`Paused`:`Active`,tone:V.paused?`amber`:`green`}),(0,I.jsx)(f,{label:k?`Stale`:`Live`,tone:k?`amber`:`green`})]})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[V.paused?(0,I.jsxs)(g,{variant:`success`,size:`sm`,disabled:n!=null,onClick:()=>z(`resume`,()=>m.resume(e)),children:[(0,I.jsx)(d,{className:`size-3.5`}),` Resume`]}):(0,I.jsxs)(g,{variant:`warning`,size:`sm`,disabled:n!=null,onClick:()=>z(`pause`,()=>m.pause(e)),children:[(0,I.jsx)(s,{className:`size-3.5`}),` Pause`]}),(0,I.jsx)(g,{size:`sm`,disabled:!0,title:N,children:`Drain`}),(0,I.jsx)(g,{variant:`danger`,size:`sm`,disabled:!0,title:N,children:`Obliterate`})]})]}),o&&(0,I.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-red-400`,children:o}),(0,I.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:N}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,I.jsx)(D,{label:`Waiting`,value:T(W.waiting),tone:`amber`}),(0,I.jsx)(D,{label:`Active`,value:T(W.active),tone:`blue`}),(0,I.jsx)(D,{label:`Completed`,value:T(W.completed),tone:`green`}),(0,I.jsx)(D,{label:`Failed`,value:T(W.failed),tone:W.failed?`red`:`default`}),(0,I.jsx)(D,{label:`Delayed`,value:T(W.delayed),tone:`default`}),(0,I.jsx)(D,{label:`Error Rate`,value:G==null?`—`:S(G),tone:G==null?`default`:G>.05?`red`:`green`})]}),(0,I.jsxs)(`div`,{className:`mt-8`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,I.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,I.jsxs)(r,{to:`/jobs-classic?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all jobs `,(0,I.jsx)(u,{className:`size-3.5`})]})]}),(0,I.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,I.jsxs)(`table`,{className:`w-full min-w-[44rem] text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,I.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,I.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,I.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,I.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,I.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,I.jsx)(`tbody`,{children:B.recentJobsError?(0,I.jsx)(`tr`,{children:(0,I.jsxs)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,B.recentJobsError,`. Retry the page.`]})}):K.length===0?(0,I.jsx)(`tr`,{children:(0,I.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):K.map(e=>(0,I.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,I.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,I.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`rounded text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:e.id})}),(0,I.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name??P(e.data)??`default`}),(0,I.jsx)(`td`,{className:`px-5 py-3`,children:(0,I.jsx)(p,{status:String(e.state??e.status??`waiting`)})}),(0,I.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:x(C(e.startedAt,e.completedAt))}),(0,I.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:w(e.createdAt)})]},e.id))})]})})]}),(0,I.jsx)(L,{queue:e})]})}export{W as QueueDetail};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,g as n,r,t as i}from"./react-vendor-CFL9l8LK.js";import{t as a}from"./bq-DR2BTISO.js";import{A as o,b as s,i as c,m as l,n as u,x as d}from"./icons-DH9SS1DA.js";import{n as f,t as p}from"./StatusBadge-DereLzOj.js";import{t as m}from"./api-D9aT0ND7.js";import{n as h}from"./usePolledData-CEyyLRYa.js";import{t as g}from"./Button-_aSJvRoW.js";import{t as _}from"./Card-egIDLwVk.js";import{i as v,r as y,t as b}from"./feedback-CtGN_kqB.js";import{a as x,c as S,d as C,l as w,s as T,t as E}from"./format-Cg7VCIZW.js";import{r as D}from"./index-DZFZr0Mi.js";import{a as O,n as k,t as A}from"./form-DG3X6cLL.js";import{r as j,t as M}from"./useServerActionGuard-CUx8TOAC.js";import{r as N}from"./flowMutationSafety-YKTHxqKv.js";import{i as P}from"./classicJobsData-Csj4iihY.js";var F=e(n(),1),I=i();function L({queue:e}){return(0,I.jsxs)(`div`,{className:`mt-8`,children:[(0,I.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,I.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:`Bunqueue v2.9.3 cannot read either current policy. Every command below is an explicit blind desired-state write; a receipt proves only what this dashboard applied at that time.`}),(0,I.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,I.jsx)(B,{queue:e}),(0,I.jsx)(V,{queue:e})]})]})}function R(e){if(!e.trim())return null;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null}function z(e,t){let[n,r]=(0,F.useState)(!1),[i,o]=(0,F.useState)(null),[s,c]=(0,F.useState)(null),l=j(`classic-queue-policy:${e}:${t}`);return(0,F.useEffect)(()=>{r(!1),o(null),c(null)},[l.scopeKey]),{busy:n,error:i,receipt:s,run:async(n,i,s)=>{if(!window.confirm(i))return;let u=l.begin(t);if(u){r(!0),o(null),c(null);try{let t=await a.queuesSummary();if(!u.isCurrent())return;if(!t.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await s(),n),!u.isCurrent())return;c(`${n} applied at ${new Date().toISOString()}. Current server state cannot be read.`)}catch(e){u.isCurrent()&&o(e.message)}finally{u.finish()&&r(!1)}}}}}function B({queue:e}){let[t,n]=(0,F.useState)(``),[r,i]=(0,F.useState)(``),[o,s]=(0,F.useState)(`permanent`),[c,u]=(0,F.useState)(``),[d,f]=(0,F.useState)(``),{busy:p,error:m,receipt:h,run:v}=z(e,`rate-limit`),y=R(t),b=R(r),x=o===`expires`?R(c):void 0,S=y!==null&&b!==null&&(o===`permanent`||x!=null);return(0,I.jsxs)(_,{children:[(0,I.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate-limit desired state`}),(0,I.jsx)(l,{className:`size-4 text-faint`})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,I.jsx)(A,{label:`Limit`,children:(0,I.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-limit`,value:t,"aria-invalid":t.trim()!==``&&y===null,onChange:e=>n(e.target.value),placeholder:`100`})}),(0,I.jsx)(A,{label:`Window (ms)`,children:(0,I.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-duration`,value:r,"aria-invalid":r.trim()!==``&&b===null,onChange:e=>i(e.target.value),placeholder:`60000`})}),(0,I.jsx)(A,{label:`TTL`,children:(0,I.jsxs)(O,{name:`classic-rate-ttl-mode`,value:o,onChange:e=>s(e.target.value),children:[(0,I.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,I.jsx)(`option`,{value:`expires`,children:`Expires after`})]})}),(0,I.jsx)(A,{label:`TTL (ms)`,hint:o===`permanent`?`Not sent`:void 0,children:(0,I.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-rate-ttl`,disabled:o===`permanent`,value:c,"aria-invalid":o===`expires`&&c.trim()!==``&&x==null,onChange:e=>u(e.target.value),placeholder:`3600000`})})]}),(0,I.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:(0,I.jsx)(g,{variant:`accent`,size:`sm`,disabled:p||!S,onClick:()=>{if(y===null||b===null||o===`expires`&&x===null)return;let t=typeof x==`number`?x:void 0,n=o===`permanent`?`permanent`:`TTL ${x}ms`;v(`Rate-limit policy replaced`,`Replace the unknown rate-limit policy for "${e}" with limit ${y}, window ${b}ms, ${n}?`,()=>a.setRateLimit(e,y,b,t))},children:`Replace rate-limit policy`})}),(0,I.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,I.jsx)(A,{label:`Type ${e} to clear`,children:(0,I.jsx)(k,{name:`classic-rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:d,onChange:e=>f(e.target.value)})}),(0,I.jsx)(g,{className:`mt-2`,size:`sm`,disabled:p||d!==e,onClick:()=>void v(`No rate limit ensured`,`Ensure queue "${e}" has no rate-limit policy? The previous value is unavailable.`,()=>a.clearRateLimit(e)),children:`Ensure no rate limit`})]}),h&&(0,I.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:h}),m&&(0,I.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:m})]})}function V({queue:e}){let[t,n]=(0,F.useState)(``),[r,i]=(0,F.useState)(``),{busy:s,error:c,receipt:l,run:u}=z(e,`concurrency`),d=R(t);return(0,I.jsxs)(_,{children:[(0,I.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,I.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency desired state`}),(0,I.jsx)(o,{className:`size-4 text-faint`})]}),(0,I.jsx)(A,{label:`Maximum in-flight jobs`,children:(0,I.jsx)(k,{type:`number`,min:1,max:2**53-1,step:1,inputMode:`numeric`,name:`classic-concurrency`,value:t,"aria-invalid":t.trim()!==``&&d===null,onChange:e=>n(e.target.value),placeholder:`5`})}),(0,I.jsx)(`div`,{className:`mt-4 flex items-center gap-2`,children:(0,I.jsx)(g,{variant:`accent`,size:`sm`,disabled:s||d===null,onClick:()=>{d!==null&&u(`Concurrency policy replaced`,`Replace the unknown concurrency policy for "${e}" with ${d} maximum in-flight jobs?`,()=>a.setConcurrency(e,d))},children:`Replace concurrency policy`})}),(0,I.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,I.jsx)(A,{label:`Type ${e} to clear`,children:(0,I.jsx)(k,{name:`classic-concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value)})}),(0,I.jsx)(g,{className:`mt-2`,size:`sm`,disabled:s||r!==e,onClick:()=>void u(`No concurrency limit ensured`,`Ensure queue "${e}" has no concurrency policy? The previous value is unavailable.`,()=>a.clearConcurrency(e)),children:`Ensure no concurrency limit`})]}),l&&(0,I.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l}),c&&(0,I.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c})]})}var H=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`,`paused`],U={detail:{ok:!1,name:``,counts:{waiting:0,active:0,completed:0,failed:0,delayed:0,prioritized:0,"waiting-children":0,paused:0},paused:!1,priorityCounts:{},dlqPreview:[],timestamp:0},jobs:[],recentJobsError:null};function W(){let{name:e=``}=t(),[n,i]=(0,F.useState)(null),[o,l]=(0,F.useState)(null),_=j(`classic-queue:${e}`);(0,F.useEffect)(()=>{i(null),l(null)},[_.scopeKey]);let{data:O,error:k,loading:A,refetch:R}=h((0,F.useCallback)(async()=>{if(!(await a.queuesSummary()).some(t=>t.name===e))return{exists:!1,detail:null,jobs:[],recentJobsError:null};let[t,n]=await Promise.all([m.queueDetail(e,!1),m.jobsList(e,{states:H,limit:12}).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);if(t.ok!==!0||t.name!==e)throw Error(`Malformed queue detail response for "${e}"`);return{exists:!0,detail:t,jobs:n.jobs,recentJobsError:n.error}},[e]),[e]),z=async(t,n,r)=>{if(r&&!window.confirm(r))return;let o=_.begin(t);if(o){i(t),l(null);try{let r=await a.queuesSummary();if(!o.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);if(M(await n(),t),!o.isCurrent())return;await R()}catch(e){o.isCurrent()&&l(e.message)}finally{o.finish()&&i(null)}}};if(A&&!O&&!k)return(0,I.jsx)(y,{label:`Loading ${e}…`});if(k&&!O)return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,I.jsx)(v,{onRetry:R})]});if(O?.exists===!1)return(0,I.jsxs)(`div`,{children:[k&&(0,I.jsx)(v,{onRetry:R}),(0,I.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,I.jsx)(b,{title:`Queue not found`,hint:`No queue named "${e}" exists on the current Bunqueue server.`,action:(0,I.jsx)(r,{to:`/queues-classic`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to classic queues`})})]});let B=O?.exists===!0?O:U,{detail:V}=B,W=V.counts,G=E(W.completed??0,W.failed??0),K=[...B.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,I.jsxs)(`div`,{children:[k&&(0,I.jsx)(v,{onRetry:R}),(0,I.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(r,{to:`/queues-classic`,"aria-label":`Back to classic queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,I.jsx)(c,{className:`size-4`})}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,I.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,I.jsx)(f,{label:V.paused?`Paused`:`Active`,tone:V.paused?`amber`:`green`}),(0,I.jsx)(f,{label:k?`Stale`:`Live`,tone:k?`amber`:`green`})]})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[V.paused?(0,I.jsxs)(g,{variant:`success`,size:`sm`,disabled:n!=null,onClick:()=>z(`resume`,()=>m.resume(e)),children:[(0,I.jsx)(d,{className:`size-3.5`}),` Resume`]}):(0,I.jsxs)(g,{variant:`warning`,size:`sm`,disabled:n!=null,onClick:()=>z(`pause`,()=>m.pause(e)),children:[(0,I.jsx)(s,{className:`size-3.5`}),` Pause`]}),(0,I.jsx)(g,{size:`sm`,disabled:!0,title:N,children:`Drain`}),(0,I.jsx)(g,{variant:`danger`,size:`sm`,disabled:!0,title:N,children:`Obliterate`})]})]}),o&&(0,I.jsx)(`div`,{className:`mb-4 rounded-lg border border-red-500/20 bg-red-500/5 px-4 py-2 text-sm text-red-400`,children:o}),(0,I.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:N}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,I.jsx)(D,{label:`Waiting`,value:T(W.waiting),tone:`amber`}),(0,I.jsx)(D,{label:`Active`,value:T(W.active),tone:`blue`}),(0,I.jsx)(D,{label:`Completed`,value:T(W.completed),tone:`green`}),(0,I.jsx)(D,{label:`Failed`,value:T(W.failed),tone:W.failed?`red`:`default`}),(0,I.jsx)(D,{label:`Delayed`,value:T(W.delayed),tone:`default`}),(0,I.jsx)(D,{label:`Error Rate`,value:G==null?`—`:S(G),tone:G==null?`default`:G>.05?`red`:`green`})]}),(0,I.jsxs)(`div`,{className:`mt-8`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,I.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,I.jsxs)(r,{to:`/jobs-classic?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all jobs `,(0,I.jsx)(u,{className:`size-3.5`})]})]}),(0,I.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,I.jsxs)(`table`,{className:`w-full min-w-[44rem] text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,I.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,I.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,I.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,I.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,I.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,I.jsx)(`tbody`,{children:B.recentJobsError?(0,I.jsx)(`tr`,{children:(0,I.jsxs)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,B.recentJobsError,`. Retry the page.`]})}):K.length===0?(0,I.jsx)(`tr`,{children:(0,I.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):K.map(e=>(0,I.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,I.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,I.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`rounded text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:e.id})}),(0,I.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name??P(e.data)??`default`}),(0,I.jsx)(`td`,{className:`px-5 py-3`,children:(0,I.jsx)(p,{status:String(e.state??e.status??`waiting`)})}),(0,I.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:x(C(e.startedAt,e.completedAt))}),(0,I.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:w(e.createdAt)})]},e.id))})]})})]}),(0,I.jsx)(L,{queue:e})]})}export{W as QueueDetail};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,g as n,r,t as i}from"./react-vendor-CFL9l8LK.js";import{t as a}from"./bq-DR2BTISO.js";import{t as o}from"./toastStore-XmMX7A5W.js";import{i as s,n as c}from"./icons-DH9SS1DA.js";import{n as l,r as u}from"./StatusBadge-DereLzOj.js";import{n as d}from"./usePolledData-CEyyLRYa.js";import{t as f}from"./Button-_aSJvRoW.js";import{n as p,t as m}from"./Card-egIDLwVk.js";import{i as h,n as g,r as _,t as v}from"./feedback-CtGN_kqB.js";import{t as y}from"./PageHeader-CQzNsw8r.js";import{a as b,c as x,s as S,t as C}from"./format-Cg7VCIZW.js";import{r as w}from"./index-Bat1DN5U.js";import{r as T,t as E}from"./useServerActionGuard-CUx8TOAC.js";import{r as D}from"./flowMutationSafety-YKTHxqKv.js";import{n as O}from"./controlConnectionEpoch-ChAeMMLk.js";import{t as k}from"./AreaChart-Db2UVnaK.js";import{a as A,i as j,n as M,r as N,t as P}from"./QueueActions-BBxRt-t0.js";import{t as F}from"./useThroughputSeries-CeFx-Mwq.js";var I=e(n(),1),L=[`waiting`,`prioritized`,`active`,`waiting-children`,`delayed`,`completed`,`failed`,`paused`],R=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`],z=2e3,B=i();function V({name:e,jobs:t,error:n}){return(0,B.jsxs)(m,{padded:!1,className:`mb-6`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,B.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Recent jobs`}),(0,B.jsxs)(r,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,B.jsx)(c,{className:`size-3.5`})]})]}),(0,B.jsx)(`div`,{className:`overflow-x-auto border-t border-line`,children:(0,B.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`State`}),(0,B.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,B.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`})]})}),(0,B.jsx)(`tbody`,{children:n?(0,B.jsx)(`tr`,{children:(0,B.jsxs)(`td`,{colSpan:5,className:`px-5 py-10 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,n,`. Retry the page.`]})}):t.length===0?(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:5,className:`px-5 py-10 text-center text-sm text-faint`,children:`No recent jobs.`})}):t.map(e=>(0,B.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,B.jsx)(`td`,{className:`px-5 py-3`,children:(0,B.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.id})}),(0,B.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,B.jsx)(`td`,{className:`px-5 py-3 text-muted`,children:e.state??`—`}),(0,B.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[e.attempts??0,` / `,e.maxAttempts??`?`]}),(0,B.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)})]},e.id))})]})})]})}function H({counts:e}){let t=Object.entries(e??{}).map(([e,t])=>[Number(e),t]).filter(([,e])=>e>0).sort((e,t)=>t[0]-e[0]);if(t.length===0)return null;let n=Math.max(...t.map(([,e])=>e));return(0,B.jsxs)(m,{className:`mb-6`,children:[(0,B.jsx)(p,{title:`Jobs by priority`}),(0,B.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(([e,t])=>(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsxs)(`span`,{className:`w-16 shrink-0 text-right font-mono text-xs text-muted`,children:[`p`,e]}),(0,B.jsx)(`div`,{className:`h-4 flex-1 overflow-hidden rounded bg-surface-2`,children:(0,B.jsx)(`div`,{className:`h-full rounded bg-accent`,style:{width:`${Math.max(2,t/n*100)}%`}})}),(0,B.jsx)(`span`,{className:`w-14 shrink-0 tnum text-xs text-fg`,children:S(t)})]},e))}),(0,B.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:`Higher p = higher priority. Waiting jobs only.`})]})}function U({name:e,depth:t,trend:n,rate:r}){return(0,B.jsxs)(m,{className:`mb-6`,children:[(0,B.jsx)(p,{title:`Backlog depth`,action:(0,B.jsx)(`span`,{className:u(`rounded-full px-2 py-0.5 text-[11px] font-medium`,n.draining?`bg-emerald-500/10 text-success`:n.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:n.label})}),t.length<2?(0,B.jsx)(`p`,{className:`py-6 text-center text-xs text-faint`,children:`Sampling… the backlog trend appears after a few polls.`}):(0,B.jsx)(k,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:t,area:!0}]}),(0,B.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-xs text-faint`,children:[(0,B.jsx)(`span`,{children:`waiting + prioritized + active + delayed + waiting-children`}),(0,B.jsxs)(`span`,{className:`tnum`,children:[`Error rate `,r==null?`—`:x(r)]})]})]})}function W(e,t){let n=`${O()}\u0000${e}`,[r,i]=(0,I.useState)(()=>({scope:n,values:[]})),a=(0,I.useRef)(null);(0,I.useEffect)(()=>{a.current=null,i({scope:n,values:[]});let e=setInterval(()=>{let e=a.current;e!=null&&i(t=>({scope:n,values:[...t.scope===n?t.values:[],e].slice(-40)}))},z);return()=>clearInterval(e)},[n]),(0,I.useEffect)(()=>{t&&(a.current=(t.waiting??0)+(t.prioritized??0)+(t.active??0)+(t.delayed??0)+(t[`waiting-children`]??0))},[t,n]);let o=r.scope===n?r.values:[];return{depth:o,trend:F(o,z)}}function G(){let{name:e=``}=t(),[n,i]=(0,I.useState)(!1),[u,p]=(0,I.useState)(null),m=T(`queue:${e}`);(0,I.useEffect)(()=>{i(!1),p(null)},[m.scopeKey]);let{data:b,error:x,loading:O,refetch:k}=d((0,I.useCallback)(async()=>{if(!e)return null;if(!(await a.queuesSummary()).some(t=>t.name===e))return{queue:e,exists:!1,detail:null,stall:null,dlq:null,jobs:[],recentJobsError:null};let[t,n,r,i]=await Promise.all([a.queueDetail(e,!1),a.getStallConfig(e).catch(()=>null),a.getDlqConfig(e).catch(()=>null),a.jobsList(e,R,12).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);return{queue:e,exists:!0,detail:t,stall:n?.config??null,dlq:r?.config??null,jobs:i.jobs,recentJobsError:i.error}},[e]),[e]),F=b?.queue===e?b:null,{depth:z,trend:G}=W(e,F?.detail?.counts),K=async(t,n,r,s)=>{if(r&&!window.confirm(r))return;let c=m.begin();if(c){i(!0),p(null);try{let r=await a.queuesSummary();if(!c.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);let i=await n();if(E(i,t),!c.isCurrent())return;let l=i.count;if(l!==void 0&&(!Number.isSafeInteger(l)||l<0))throw Error(`${t} returned an invalid count`);let u=`${t}${l==null?` ✓`:`: ${l}`}`;p({ok:!0,text:u}),o.success(u,e),s?.(),k()}catch(e){if(!c.isCurrent())return;let n=e.message;p({ok:!1,text:n}),o.error(`${t} failed`,n)}finally{c.finish()&&i(!1)}}},q=F?.detail,J=q?.counts,Y=J?C(J.completed??0,J.failed??0):null;return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(y,{title:(0,B.jsx)(`span`,{className:`font-mono`,children:e}),description:`Full per-queue operations and complete live non-terminal depth.`,live:F?.exists===!0&&!!F.detail&&!!F.stall&&!!F.dlq&&!F.recentJobsError&&!x,back:(0,B.jsx)(r,{to:`/queues`,"aria-label":`Back to queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,B.jsx)(s,{className:`size-4`})}),actions:F?.exists===!0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(r,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`Jobs `,(0,B.jsx)(c,{className:`size-3.5`})]}),(0,B.jsxs)(r,{to:`/dlq?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`DLQ `,(0,B.jsx)(c,{className:`size-3.5`})]}),(0,B.jsx)(f,{variant:`danger`,size:`sm`,disabled:!0,title:D,children:`Obliterate`})]}):void 0}),x&&F&&(0,B.jsx)(h,{message:`Queue refresh failed — showing the last successful snapshot.`,onRetry:k}),x&&!F?(0,B.jsx)(g,{error:x,onRetry:k}):O&&!F?(0,B.jsx)(_,{label:`Loading ${e}…`}):F?.exists===!1||!q||!J?!x&&(0,B.jsx)(v,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,B.jsx)(r,{to:`/queues`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to queues`})}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(l,{label:q.paused?`Paused`:`Active`,tone:q.paused?`amber`:`green`}),u&&(0,B.jsx)(`span`,{role:`status`,className:u.ok?`text-xs text-success`:`text-xs text-danger`,children:u.text}),(0,B.jsx)(`span`,{className:`text-xs text-warning`,children:D})]}),(0,B.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:L.map(e=>(0,B.jsx)(w,{label:e,value:S(J[e]),tone:e===`failed`&&J.failed?`red`:`default`,compact:!0},e))}),(0,B.jsx)(V,{name:e,jobs:F.jobs,error:F.recentJobsError}),(0,B.jsx)(H,{counts:q.priorityCounts}),(0,B.jsx)(U,{name:e,depth:z,trend:G,rate:Y}),(0,B.jsx)(M,{queue:e,paused:q.paused,busy:n,run:K}),(0,B.jsx)(P,{queue:e,busy:n,run:K},`${e}:limits`),(0,B.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[F.stall?(0,B.jsx)(j,{queue:e,config:F.stall,onSaved:()=>{p({ok:!0,text:`Stall config saved ✓`}),o.success(`Stall config saved`,e)}},`${e}:stall`):(0,B.jsx)(N,{title:`Stall detection`,onRetry:k}),F.dlq?(0,B.jsx)(A,{queue:e,config:F.dlq,onSaved:()=>{p({ok:!0,text:`DLQ config saved ✓`}),o.success(`DLQ config saved`,e)}},`${e}:dlq`):(0,B.jsx)(N,{title:`DLQ policy`,onRetry:k})]})]})]})}export{G as QueueDetailPro};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,g as n,r,t as i}from"./react-vendor-CFL9l8LK.js";import{t as a}from"./bq-DR2BTISO.js";import{t as o}from"./toastStore-XmMX7A5W.js";import{i as s,n as c}from"./icons-DH9SS1DA.js";import{n as l,r as u}from"./StatusBadge-DereLzOj.js";import{n as d}from"./usePolledData-CEyyLRYa.js";import{t as f}from"./Button-_aSJvRoW.js";import{n as p,t as m}from"./Card-egIDLwVk.js";import{i as h,n as g,r as _,t as v}from"./feedback-CtGN_kqB.js";import{t as y}from"./PageHeader-CQzNsw8r.js";import{a as b,c as x,s as S,t as C}from"./format-Cg7VCIZW.js";import{r as w}from"./index-DZFZr0Mi.js";import{r as T,t as E}from"./useServerActionGuard-CUx8TOAC.js";import{r as D}from"./flowMutationSafety-YKTHxqKv.js";import{n as O}from"./controlConnectionEpoch-ChAeMMLk.js";import{t as k}from"./AreaChart-Db2UVnaK.js";import{a as A,i as j,n as M,r as N,t as P}from"./QueueActions-BBxRt-t0.js";import{t as F}from"./useThroughputSeries-CeFx-Mwq.js";var I=e(n(),1),L=[`waiting`,`prioritized`,`active`,`waiting-children`,`delayed`,`completed`,`failed`,`paused`],R=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`],z=2e3,B=i();function V({name:e,jobs:t,error:n}){return(0,B.jsxs)(m,{padded:!1,className:`mb-6`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,B.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:`Recent jobs`}),(0,B.jsxs)(r,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,B.jsx)(c,{className:`size-3.5`})]})]}),(0,B.jsx)(`div`,{className:`overflow-x-auto border-t border-line`,children:(0,B.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,B.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`State`}),(0,B.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Attempts`}),(0,B.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`})]})}),(0,B.jsx)(`tbody`,{children:n?(0,B.jsx)(`tr`,{children:(0,B.jsxs)(`td`,{colSpan:5,className:`px-5 py-10 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,n,`. Retry the page.`]})}):t.length===0?(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:5,className:`px-5 py-10 text-center text-sm text-faint`,children:`No recent jobs.`})}):t.map(e=>(0,B.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,B.jsx)(`td`,{className:`px-5 py-3`,children:(0,B.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`font-mono text-xs text-accent hover:underline`,children:e.id})}),(0,B.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.name??`default`}),(0,B.jsx)(`td`,{className:`px-5 py-3 text-muted`,children:e.state??`—`}),(0,B.jsxs)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:[e.attempts??0,` / `,e.maxAttempts??`?`]}),(0,B.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:b(e.startedAt&&e.completedAt?e.completedAt-e.startedAt:void 0)})]},e.id))})]})})]})}function H({counts:e}){let t=Object.entries(e??{}).map(([e,t])=>[Number(e),t]).filter(([,e])=>e>0).sort((e,t)=>t[0]-e[0]);if(t.length===0)return null;let n=Math.max(...t.map(([,e])=>e));return(0,B.jsxs)(m,{className:`mb-6`,children:[(0,B.jsx)(p,{title:`Jobs by priority`}),(0,B.jsx)(`div`,{className:`flex flex-col gap-2`,children:t.map(([e,t])=>(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsxs)(`span`,{className:`w-16 shrink-0 text-right font-mono text-xs text-muted`,children:[`p`,e]}),(0,B.jsx)(`div`,{className:`h-4 flex-1 overflow-hidden rounded bg-surface-2`,children:(0,B.jsx)(`div`,{className:`h-full rounded bg-accent`,style:{width:`${Math.max(2,t/n*100)}%`}})}),(0,B.jsx)(`span`,{className:`w-14 shrink-0 tnum text-xs text-fg`,children:S(t)})]},e))}),(0,B.jsx)(`p`,{className:`mt-2 text-xs text-faint`,children:`Higher p = higher priority. Waiting jobs only.`})]})}function U({name:e,depth:t,trend:n,rate:r}){return(0,B.jsxs)(m,{className:`mb-6`,children:[(0,B.jsx)(p,{title:`Backlog depth`,action:(0,B.jsx)(`span`,{className:u(`rounded-full px-2 py-0.5 text-[11px] font-medium`,n.draining?`bg-emerald-500/10 text-success`:n.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:n.label})}),t.length<2?(0,B.jsx)(`p`,{className:`py-6 text-center text-xs text-faint`,children:`Sampling… the backlog trend appears after a few polls.`}):(0,B.jsx)(k,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:t,area:!0}]}),(0,B.jsxs)(`div`,{className:`mt-1 flex items-center justify-between text-xs text-faint`,children:[(0,B.jsx)(`span`,{children:`waiting + prioritized + active + delayed + waiting-children`}),(0,B.jsxs)(`span`,{className:`tnum`,children:[`Error rate `,r==null?`—`:x(r)]})]})]})}function W(e,t){let n=`${O()}\u0000${e}`,[r,i]=(0,I.useState)(()=>({scope:n,values:[]})),a=(0,I.useRef)(null);(0,I.useEffect)(()=>{a.current=null,i({scope:n,values:[]});let e=setInterval(()=>{let e=a.current;e!=null&&i(t=>({scope:n,values:[...t.scope===n?t.values:[],e].slice(-40)}))},z);return()=>clearInterval(e)},[n]),(0,I.useEffect)(()=>{t&&(a.current=(t.waiting??0)+(t.prioritized??0)+(t.active??0)+(t.delayed??0)+(t[`waiting-children`]??0))},[t,n]);let o=r.scope===n?r.values:[];return{depth:o,trend:F(o,z)}}function G(){let{name:e=``}=t(),[n,i]=(0,I.useState)(!1),[u,p]=(0,I.useState)(null),m=T(`queue:${e}`);(0,I.useEffect)(()=>{i(!1),p(null)},[m.scopeKey]);let{data:b,error:x,loading:O,refetch:k}=d((0,I.useCallback)(async()=>{if(!e)return null;if(!(await a.queuesSummary()).some(t=>t.name===e))return{queue:e,exists:!1,detail:null,stall:null,dlq:null,jobs:[],recentJobsError:null};let[t,n,r,i]=await Promise.all([a.queueDetail(e,!1),a.getStallConfig(e).catch(()=>null),a.getDlqConfig(e).catch(()=>null),a.jobsList(e,R,12).then(e=>({jobs:e.jobs??[],error:null})).catch(e=>({jobs:[],error:e.message||`Unknown error`}))]);return{queue:e,exists:!0,detail:t,stall:n?.config??null,dlq:r?.config??null,jobs:i.jobs,recentJobsError:i.error}},[e]),[e]),F=b?.queue===e?b:null,{depth:z,trend:G}=W(e,F?.detail?.counts),K=async(t,n,r,s)=>{if(r&&!window.confirm(r))return;let c=m.begin();if(c){i(!0),p(null);try{let r=await a.queuesSummary();if(!c.isCurrent())return;if(!r.some(t=>t.name===e))throw Error(`Queue "${e}" no longer exists`);let i=await n();if(E(i,t),!c.isCurrent())return;let l=i.count;if(l!==void 0&&(!Number.isSafeInteger(l)||l<0))throw Error(`${t} returned an invalid count`);let u=`${t}${l==null?` ✓`:`: ${l}`}`;p({ok:!0,text:u}),o.success(u,e),s?.(),k()}catch(e){if(!c.isCurrent())return;let n=e.message;p({ok:!1,text:n}),o.error(`${t} failed`,n)}finally{c.finish()&&i(!1)}}},q=F?.detail,J=q?.counts,Y=J?C(J.completed??0,J.failed??0):null;return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(y,{title:(0,B.jsx)(`span`,{className:`font-mono`,children:e}),description:`Full per-queue operations and complete live non-terminal depth.`,live:F?.exists===!0&&!!F.detail&&!!F.stall&&!!F.dlq&&!F.recentJobsError&&!x,back:(0,B.jsx)(r,{to:`/queues`,"aria-label":`Back to queues`,className:`inline-flex size-8 items-center justify-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,B.jsx)(s,{className:`size-4`})}),actions:F?.exists===!0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(r,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`Jobs `,(0,B.jsx)(c,{className:`size-3.5`})]}),(0,B.jsxs)(r,{to:`/dlq?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:[`DLQ `,(0,B.jsx)(c,{className:`size-3.5`})]}),(0,B.jsx)(f,{variant:`danger`,size:`sm`,disabled:!0,title:D,children:`Obliterate`})]}):void 0}),x&&F&&(0,B.jsx)(h,{message:`Queue refresh failed — showing the last successful snapshot.`,onRetry:k}),x&&!F?(0,B.jsx)(g,{error:x,onRetry:k}):O&&!F?(0,B.jsx)(_,{label:`Loading ${e}…`}):F?.exists===!1||!q||!J?!x&&(0,B.jsx)(v,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,B.jsx)(r,{to:`/queues`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Back to queues`})}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(l,{label:q.paused?`Paused`:`Active`,tone:q.paused?`amber`:`green`}),u&&(0,B.jsx)(`span`,{role:`status`,className:u.ok?`text-xs text-success`:`text-xs text-danger`,children:u.text}),(0,B.jsx)(`span`,{className:`text-xs text-warning`,children:D})]}),(0,B.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:L.map(e=>(0,B.jsx)(w,{label:e,value:S(J[e]),tone:e===`failed`&&J.failed?`red`:`default`,compact:!0},e))}),(0,B.jsx)(V,{name:e,jobs:F.jobs,error:F.recentJobsError}),(0,B.jsx)(H,{counts:q.priorityCounts}),(0,B.jsx)(U,{name:e,depth:z,trend:G,rate:Y}),(0,B.jsx)(M,{queue:e,paused:q.paused,busy:n,run:K}),(0,B.jsx)(P,{queue:e,busy:n,run:K},`${e}:limits`),(0,B.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[F.stall?(0,B.jsx)(j,{queue:e,config:F.stall,onSaved:()=>{p({ok:!0,text:`Stall config saved ✓`}),o.success(`Stall config saved`,e)}},`${e}:stall`):(0,B.jsx)(N,{title:`Stall detection`,onRetry:k}),F.dlq?(0,B.jsx)(A,{queue:e,config:F.dlq,onSaved:()=>{p({ok:!0,text:`DLQ config saved ✓`}),o.success(`DLQ config saved`,e)}},`${e}:dlq`):(0,B.jsx)(N,{title:`DLQ policy`,onRetry:k})]})]})]})}export{G as QueueDetailPro};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-CFL9l8LK.js";import{S as i,T as a,n as o}from"./icons-DH9SS1DA.js";import{r as s}from"./StatusBadge-DereLzOj.js";import{t as c}from"./api-D9aT0ND7.js";import{n as l}from"./usePolledData-CEyyLRYa.js";import{i as u,r as d}from"./feedback-CtGN_kqB.js";import{t as f}from"./PageHeader-CQzNsw8r.js";import{s as p}from"./format-Cg7VCIZW.js";import{r as m}from"./index-Bat1DN5U.js";import{t as h}from"./Pagination-CSkzhNW6.js";var g=e(t(),1),_=r(),v=20,y={ok:!1,queues:[],total:0,limit:v,offset:0,timestamp:0};function b(){let[e,t]=(0,g.useState)(``),[r,b]=(0,g.useState)(0),{data:x,error:S,loading:C,refetch:w}=l(()=>c.queues(v,r*v),[r]),{data:T}=l(()=>c.overview(),[]),E=x??y,D=(0,g.useMemo)(()=>{let t=E.queues,n=e.trim().toLowerCase();return n?t.filter(e=>e.name.toLowerCase().includes(n)):t},[E,e]);if(C&&!x&&!S)return(0,_.jsx)(d,{label:`Loading queues…`});let O=T?.stats;return(0,_.jsxs)(`div`,{children:[S&&(0,_.jsx)(u,{onRetry:w}),(0,_.jsx)(f,{title:`Queues`,description:x?`${E.total} queues`:`Queue inventory unavailable`,live:!!x&&!S}),(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,_.jsx)(m,{label:`Waiting`,value:O?p(O.waiting):`—`,tone:`amber`,compact:!0}),(0,_.jsx)(m,{label:`Active`,value:O?p(O.active):`—`,tone:`blue`,compact:!0}),(0,_.jsx)(m,{label:`Delayed`,value:O?p(O.delayed):`—`,tone:`default`,compact:!0}),(0,_.jsx)(m,{label:`DLQ`,value:O?p(O.dlq):`—`,tone:O?.dlq?`red`:`default`,compact:!0})]}),(0,_.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,_.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,_.jsx)(`input`,{"aria-label":`Filter queues`,name:`classic-queue-filter`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),placeholder:`Search queues…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full min-w-[52rem] text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Delayed`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`DLQ`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,_.jsx)(`th`,{className:`w-10 px-5 py-3`})]})}),(0,_.jsx)(`tbody`,{children:!x&&S?(0,_.jsx)(`tr`,{children:(0,_.jsxs)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,S.message,`. Retry above.`]})}):D.length===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:e?`No queues match on this page.`:`No queues yet.`})}):D.map(e=>(0,_.jsxs)(`tr`,{className:`group border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(n,{to:`/queues-classic/${encodeURIComponent(e.name)}`,className:`flex items-center gap-2 rounded font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,_.jsx)(i,{className:`size-4 text-faint`}),e.name]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(e.waiting)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:p(e.active)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(e.delayed)}),(0,_.jsx)(`td`,{className:s(`px-5 py-3 text-right tnum`,e.dlq?`text-red-400`:`text-muted`),children:p(e.dlq)}),(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(`span`,{className:s(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-emerald-400`),children:[(0,_.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e.paused?`Paused`:`Active`]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-faint`,children:(0,_.jsx)(o,{className:`size-4 opacity-0 transition-opacity group-hover:opacity-100`})})]},e.name))})]})}),x&&(0,_.jsx)(h,{page:r,pageSize:v,total:E.total,onPageChange:b,label:`queues`})]})}export{b as Queues};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-CFL9l8LK.js";import{S as i,T as a,n as o}from"./icons-DH9SS1DA.js";import{r as s}from"./StatusBadge-DereLzOj.js";import{t as c}from"./api-D9aT0ND7.js";import{n as l}from"./usePolledData-CEyyLRYa.js";import{i as u,r as d}from"./feedback-CtGN_kqB.js";import{t as f}from"./PageHeader-CQzNsw8r.js";import{s as p}from"./format-Cg7VCIZW.js";import{r as m}from"./index-DZFZr0Mi.js";import{t as h}from"./Pagination-CSkzhNW6.js";var g=e(t(),1),_=r(),v=20,y={ok:!1,queues:[],total:0,limit:v,offset:0,timestamp:0};function b(){let[e,t]=(0,g.useState)(``),[r,b]=(0,g.useState)(0),{data:x,error:S,loading:C,refetch:w}=l(()=>c.queues(v,r*v),[r]),{data:T}=l(()=>c.overview(),[]),E=x??y,D=(0,g.useMemo)(()=>{let t=E.queues,n=e.trim().toLowerCase();return n?t.filter(e=>e.name.toLowerCase().includes(n)):t},[E,e]);if(C&&!x&&!S)return(0,_.jsx)(d,{label:`Loading queues…`});let O=T?.stats;return(0,_.jsxs)(`div`,{children:[S&&(0,_.jsx)(u,{onRetry:w}),(0,_.jsx)(f,{title:`Queues`,description:x?`${E.total} queues`:`Queue inventory unavailable`,live:!!x&&!S}),(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-4`,children:[(0,_.jsx)(m,{label:`Waiting`,value:O?p(O.waiting):`—`,tone:`amber`,compact:!0}),(0,_.jsx)(m,{label:`Active`,value:O?p(O.active):`—`,tone:`blue`,compact:!0}),(0,_.jsx)(m,{label:`Delayed`,value:O?p(O.delayed):`—`,tone:`default`,compact:!0}),(0,_.jsx)(m,{label:`DLQ`,value:O?p(O.dlq):`—`,tone:O?.dlq?`red`:`default`,compact:!0})]}),(0,_.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,_.jsx)(a,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,_.jsx)(`input`,{"aria-label":`Filter queues`,name:`classic-queue-filter`,autoComplete:`off`,value:e,onChange:e=>t(e.target.value),placeholder:`Search queues…`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),(0,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,_.jsxs)(`table`,{className:`w-full min-w-[52rem] text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Waiting`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Delayed`}),(0,_.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`DLQ`}),(0,_.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,_.jsx)(`th`,{className:`w-10 px-5 py-3`})]})}),(0,_.jsx)(`tbody`,{children:!x&&S?(0,_.jsx)(`tr`,{children:(0,_.jsxs)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,S.message,`. Retry above.`]})}):D.length===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{colSpan:7,className:`px-5 py-12 text-center text-sm text-faint`,children:e?`No queues match on this page.`:`No queues yet.`})}):D.map(e=>(0,_.jsxs)(`tr`,{className:`group border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(n,{to:`/queues-classic/${encodeURIComponent(e.name)}`,className:`flex items-center gap-2 rounded font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,_.jsx)(i,{className:`size-4 text-faint`}),e.name]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(e.waiting)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:p(e.active)}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(e.delayed)}),(0,_.jsx)(`td`,{className:s(`px-5 py-3 text-right tnum`,e.dlq?`text-red-400`:`text-muted`),children:p(e.dlq)}),(0,_.jsx)(`td`,{className:`px-5 py-3`,children:(0,_.jsxs)(`span`,{className:s(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-emerald-400`),children:[(0,_.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e.paused?`Paused`:`Active`]})}),(0,_.jsx)(`td`,{className:`px-5 py-3 text-faint`,children:(0,_.jsx)(o,{className:`size-4 opacity-0 transition-opacity group-hover:opacity-100`})})]},e.name))})]})}),x&&(0,_.jsx)(h,{page:r,pageSize:v,total:E.total,onPageChange:b,label:`queues`})]})}export{b as Queues};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-CFL9l8LK.js";import{t as i}from"./bq-DR2BTISO.js";import{t as a}from"./toastStore-XmMX7A5W.js";import{S as o,T as s,b as c,n as l,x as u}from"./icons-DH9SS1DA.js";import{r as d}from"./StatusBadge-DereLzOj.js";import{n as f}from"./usePolledData-CEyyLRYa.js";import{n as p,t as m}from"./Button-_aSJvRoW.js";import{i as h,n as g,r as _}from"./feedback-CtGN_kqB.js";import{t as v}from"./PageHeader-CQzNsw8r.js";import{s as y}from"./format-Cg7VCIZW.js";import{r as b}from"./index-Bat1DN5U.js";import{t as x}from"./Pagination-CSkzhNW6.js";import{r as S,t as C}from"./useServerActionGuard-CUx8TOAC.js";import{t as w}from"./promisePool-BVfQ9n9Q.js";var T=e(t(),1),E=r(),D=[[`waiting`,`Waiting`],[`prioritized`,`Prioritized`],[`active`,`Active`],[`completed`,`Completed`],[`failed`,`Failed`],[`delayed`,`Delayed`]];function O({rows:e,hasData:t,error:r,search:i,sortCol:a,sortDir:s,bulkBusy:f,busy:m,onSort:h,onToggle:g}){return(0,E.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,E.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,E.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),D.map(([e,t])=>(0,E.jsx)(`th`,{"aria-sort":a===e?s===`desc`?`descending`:`ascending`:void 0,className:`px-5 py-3 text-right font-medium`,children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>h(e),className:`inline-flex items-center gap-1 rounded uppercase tracking-wider hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[t,a===e&&(0,E.jsx)(`span`,{"aria-hidden":`true`,children:s===`desc`?`↓`:`↑`})]})},e)),(0,E.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,E.jsx)(`th`,{className:`w-24 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,E.jsx)(`tbody`,{children:!t&&r?(0,E.jsx)(`tr`,{children:(0,E.jsxs)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,r.message,`. Retry above.`]})}):e.length===0?(0,E.jsx)(`tr`,{children:(0,E.jsx)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-faint`,children:i?`No queues match your search.`:`No queues yet.`})}):e.map(e=>{let t=f||m.has(e.name);return(0,E.jsxs)(`tr`,{className:`group border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(n,{to:`/queues/${encodeURIComponent(e.name)}`,className:`flex items-center gap-2 rounded font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,E.jsx)(o,{className:`size-4 text-faint`}),e.name]})}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:y(e.counts.waiting)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:y(e.counts.prioritized)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:y(e.counts.active)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:y(e.counts.completed)}),(0,E.jsx)(`td`,{className:d(`px-5 py-3 text-right tnum`,e.counts.failed?`text-danger`:`text-muted`),children:y(e.counts.failed)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:y(e.counts.delayed)}),(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(`span`,{className:d(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:[(0,E.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e.paused?`Paused`:`Active`]})}),(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,E.jsx)(p,{"aria-label":e.paused?`Resume queue`:`Pause queue`,disabled:t,onClick:t=>{t.stopPropagation(),g(e)},children:e.paused?(0,E.jsx)(u,{className:`size-3.5 text-success`}):(0,E.jsx)(c,{className:`size-3.5 text-warning`})}),(0,E.jsx)(l,{className:`size-4 text-faint opacity-0 transition-opacity group-hover:opacity-100`})]})})]},e.name)})})]})})}var k=6,A=15,j=[];function M(){let[e,t]=(0,T.useState)(``),[n,r]=(0,T.useState)(0),[o,l]=(0,T.useState)(new Set),[p,D]=(0,T.useState)(!1),[M,N]=(0,T.useState)(null),[P,F]=(0,T.useState)(null),[I,L]=(0,T.useState)(`desc`),R=S(`queues-overview`);(0,T.useEffect)(()=>{l(new Set),D(!1),N(null)},[R.scopeKey]);let{data:z,error:B,loading:V,refetch:H}=f(()=>i.queuesSummary(),[]),U=z??j,W=e=>{P===e?I===`desc`?L(`asc`):F(null):(F(e),L(`desc`)),r(0)},G=(0,T.useMemo)(()=>{let t=e.trim().toLowerCase(),n=[...t?U.filter(e=>e.name.toLowerCase().includes(t)):U].sort((e,t)=>e.name.localeCompare(t.name));if(P){let e=I===`desc`?-1:1;n.sort((t,n)=>e*(t.counts[P]-n.counts[P]))}return n},[U,e,P,I]),K=(0,T.useMemo)(()=>U.reduce((e,t)=>(e.waiting+=t.counts.waiting,e.prioritized+=t.counts.prioritized,e.active+=t.counts.active,e.failed+=t.counts.failed,e.paused+=+!!t.paused,e),{waiting:0,prioritized:0,active:0,failed:0,paused:0}),[U]),q=Math.max(1,Math.ceil(G.length/A)),J=Math.min(n,q-1),Y=G.slice(J*A,J*A+A),X=async e=>{let t=R.begin(`queue:${e.name}`);if(t){l(t=>new Set(t).add(e.name)),N(null);try{if(C(await(e.paused?i.resume(e.name):i.pause(e.name)),e.paused?`Resume queue`:`Pause queue`),!t.isCurrent())return;N({ok:!0,text:`${e.name} ${e.paused?`resumed`:`paused`} ✓`}),H()}catch(n){if(!t.isCurrent())return;N({ok:!1,text:n.message}),a.error(`Failed to ${e.paused?`resume`:`pause`} ${e.name}`,n.message)}finally{t.finish()&&l(t=>{let n=new Set(t);return n.delete(e.name),n})}}},Z=async e=>{let t=U.filter(t=>e===`pause`?!t.paused:t.paused);if(t.length===0){a.info(`No queues to ${e}`);return}if(!window.confirm(`${e===`pause`?`Pause`:`Resume`} ${t.length} queue(s)?`))return;let n=R.begin([`bulk`,...U.map(e=>`queue:${e.name}`)]);if(n){D(!0),N(null);try{let r=await w(t,k,async t=>{if(!n.isCurrent())throw Error(`Queue action target changed`);C(e===`pause`?await i.pause(t.name):await i.resume(t.name),`${e===`pause`?`Pause`:`Resume`} ${t.name}`)});if(!n.isCurrent())return;let o=r.filter(e=>e.status===`rejected`).length,s=`${e===`pause`?`Paused`:`Resumed`} ${t.length-o}/${t.length} queues${o?`, ${o} failed`:``}`;N({ok:o===0,text:s}),o===0?a.success(s):a.error(s),H()}finally{n.finish()&&D(!1)}}};return V&&!z&&!B?(0,E.jsx)(_,{label:`Loading queues…`}):B&&!z?(0,E.jsxs)(`div`,{children:[(0,E.jsx)(v,{title:`Queues`,description:`Queue inventory unavailable`}),(0,E.jsx)(g,{error:B,onRetry:H})]}):(0,E.jsxs)(`div`,{children:[(0,E.jsx)(v,{title:`Queues`,description:z?`${U.length} queues`:`Queue inventory unavailable`,live:!!z&&!B,actions:U.length>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m,{variant:`warning`,size:`sm`,disabled:p||o.size>0||K.paused>=U.length,onClick:()=>Z(`pause`),children:[(0,E.jsx)(c,{className:`size-3.5`}),` Pause all`]}),(0,E.jsxs)(m,{variant:`success`,size:`sm`,disabled:p||o.size>0||K.paused===0,onClick:()=>Z(`resume`),children:[(0,E.jsx)(u,{className:`size-3.5`}),` Resume all`]})]}):void 0}),B&&(0,E.jsx)(h,{message:`Queue refresh failed — showing the last successful inventory.`,onRetry:H}),(0,E.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,E.jsx)(b,{label:`Waiting`,value:y(K.waiting),tone:`amber`,compact:!0}),(0,E.jsx)(b,{label:`Prioritized`,value:y(K.prioritized),tone:`amber`,compact:!0}),(0,E.jsx)(b,{label:`Active`,value:y(K.active),tone:`blue`,compact:!0}),(0,E.jsx)(b,{label:`Failed`,value:y(K.failed),tone:K.failed?`red`:`default`,compact:!0}),(0,E.jsx)(b,{label:`Paused`,value:y(K.paused),tone:K.paused?`amber`:`default`,compact:!0})]}),(0,E.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,E.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,E.jsx)(`input`,{value:e,onChange:e=>{t(e.target.value),r(0)},placeholder:`Search queues…`,"aria-label":`Filter queues`,name:`queue-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),M&&(0,E.jsx)(`div`,{role:`status`,className:d(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),(0,E.jsx)(O,{rows:Y,hasData:!!z,error:B,search:e,sortCol:P,sortDir:I,bulkBusy:p,busy:o,onSort:W,onToggle:e=>void X(e)}),(0,E.jsx)(x,{page:J,pageSize:A,total:G.length,onPageChange:r,label:`queues`})]})}export{M as QueuesOverview};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{g as t,r as n,t as r}from"./react-vendor-CFL9l8LK.js";import{t as i}from"./bq-DR2BTISO.js";import{t as a}from"./toastStore-XmMX7A5W.js";import{S as o,T as s,b as c,n as l,x as u}from"./icons-DH9SS1DA.js";import{r as d}from"./StatusBadge-DereLzOj.js";import{n as f}from"./usePolledData-CEyyLRYa.js";import{n as p,t as m}from"./Button-_aSJvRoW.js";import{i as h,n as g,r as _}from"./feedback-CtGN_kqB.js";import{t as v}from"./PageHeader-CQzNsw8r.js";import{s as y}from"./format-Cg7VCIZW.js";import{r as b}from"./index-DZFZr0Mi.js";import{t as x}from"./Pagination-CSkzhNW6.js";import{r as S,t as C}from"./useServerActionGuard-CUx8TOAC.js";import{t as w}from"./promisePool-BVfQ9n9Q.js";var T=e(t(),1),E=r(),D=[[`waiting`,`Waiting`],[`prioritized`,`Prioritized`],[`active`,`Active`],[`completed`,`Completed`],[`failed`,`Failed`],[`delayed`,`Delayed`]];function O({rows:e,hasData:t,error:r,search:i,sortCol:a,sortDir:s,bulkBusy:f,busy:m,onSort:h,onToggle:g}){return(0,E.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,E.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,E.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),D.map(([e,t])=>(0,E.jsx)(`th`,{"aria-sort":a===e?s===`desc`?`descending`:`ascending`:void 0,className:`px-5 py-3 text-right font-medium`,children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>h(e),className:`inline-flex items-center gap-1 rounded uppercase tracking-wider hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[t,a===e&&(0,E.jsx)(`span`,{"aria-hidden":`true`,children:s===`desc`?`↓`:`↑`})]})},e)),(0,E.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,E.jsx)(`th`,{className:`w-24 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,E.jsx)(`tbody`,{children:!t&&r?(0,E.jsx)(`tr`,{children:(0,E.jsxs)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-warning`,children:[`Could not load queues — `,r.message,`. Retry above.`]})}):e.length===0?(0,E.jsx)(`tr`,{children:(0,E.jsx)(`td`,{colSpan:9,className:`px-5 py-12 text-center text-sm text-faint`,children:i?`No queues match your search.`:`No queues yet.`})}):e.map(e=>{let t=f||m.has(e.name);return(0,E.jsxs)(`tr`,{className:`group border-b border-line last:border-0 transition-colors hover:bg-surface-2/50`,children:[(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(n,{to:`/queues/${encodeURIComponent(e.name)}`,className:`flex items-center gap-2 rounded font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[(0,E.jsx)(o,{className:`size-4 text-faint`}),e.name]})}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-warning`,children:y(e.counts.waiting)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-orange-400`,children:y(e.counts.prioritized)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:y(e.counts.active)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-success`,children:y(e.counts.completed)}),(0,E.jsx)(`td`,{className:d(`px-5 py-3 text-right tnum`,e.counts.failed?`text-danger`:`text-muted`),children:y(e.counts.failed)}),(0,E.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:y(e.counts.delayed)}),(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(`span`,{className:d(`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:[(0,E.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`}),e.paused?`Paused`:`Active`]})}),(0,E.jsx)(`td`,{className:`px-5 py-3`,children:(0,E.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,E.jsx)(p,{"aria-label":e.paused?`Resume queue`:`Pause queue`,disabled:t,onClick:t=>{t.stopPropagation(),g(e)},children:e.paused?(0,E.jsx)(u,{className:`size-3.5 text-success`}):(0,E.jsx)(c,{className:`size-3.5 text-warning`})}),(0,E.jsx)(l,{className:`size-4 text-faint opacity-0 transition-opacity group-hover:opacity-100`})]})})]},e.name)})})]})})}var k=6,A=15,j=[];function M(){let[e,t]=(0,T.useState)(``),[n,r]=(0,T.useState)(0),[o,l]=(0,T.useState)(new Set),[p,D]=(0,T.useState)(!1),[M,N]=(0,T.useState)(null),[P,F]=(0,T.useState)(null),[I,L]=(0,T.useState)(`desc`),R=S(`queues-overview`);(0,T.useEffect)(()=>{l(new Set),D(!1),N(null)},[R.scopeKey]);let{data:z,error:B,loading:V,refetch:H}=f(()=>i.queuesSummary(),[]),U=z??j,W=e=>{P===e?I===`desc`?L(`asc`):F(null):(F(e),L(`desc`)),r(0)},G=(0,T.useMemo)(()=>{let t=e.trim().toLowerCase(),n=[...t?U.filter(e=>e.name.toLowerCase().includes(t)):U].sort((e,t)=>e.name.localeCompare(t.name));if(P){let e=I===`desc`?-1:1;n.sort((t,n)=>e*(t.counts[P]-n.counts[P]))}return n},[U,e,P,I]),K=(0,T.useMemo)(()=>U.reduce((e,t)=>(e.waiting+=t.counts.waiting,e.prioritized+=t.counts.prioritized,e.active+=t.counts.active,e.failed+=t.counts.failed,e.paused+=+!!t.paused,e),{waiting:0,prioritized:0,active:0,failed:0,paused:0}),[U]),q=Math.max(1,Math.ceil(G.length/A)),J=Math.min(n,q-1),Y=G.slice(J*A,J*A+A),X=async e=>{let t=R.begin(`queue:${e.name}`);if(t){l(t=>new Set(t).add(e.name)),N(null);try{if(C(await(e.paused?i.resume(e.name):i.pause(e.name)),e.paused?`Resume queue`:`Pause queue`),!t.isCurrent())return;N({ok:!0,text:`${e.name} ${e.paused?`resumed`:`paused`} ✓`}),H()}catch(n){if(!t.isCurrent())return;N({ok:!1,text:n.message}),a.error(`Failed to ${e.paused?`resume`:`pause`} ${e.name}`,n.message)}finally{t.finish()&&l(t=>{let n=new Set(t);return n.delete(e.name),n})}}},Z=async e=>{let t=U.filter(t=>e===`pause`?!t.paused:t.paused);if(t.length===0){a.info(`No queues to ${e}`);return}if(!window.confirm(`${e===`pause`?`Pause`:`Resume`} ${t.length} queue(s)?`))return;let n=R.begin([`bulk`,...U.map(e=>`queue:${e.name}`)]);if(n){D(!0),N(null);try{let r=await w(t,k,async t=>{if(!n.isCurrent())throw Error(`Queue action target changed`);C(e===`pause`?await i.pause(t.name):await i.resume(t.name),`${e===`pause`?`Pause`:`Resume`} ${t.name}`)});if(!n.isCurrent())return;let o=r.filter(e=>e.status===`rejected`).length,s=`${e===`pause`?`Paused`:`Resumed`} ${t.length-o}/${t.length} queues${o?`, ${o} failed`:``}`;N({ok:o===0,text:s}),o===0?a.success(s):a.error(s),H()}finally{n.finish()&&D(!1)}}};return V&&!z&&!B?(0,E.jsx)(_,{label:`Loading queues…`}):B&&!z?(0,E.jsxs)(`div`,{children:[(0,E.jsx)(v,{title:`Queues`,description:`Queue inventory unavailable`}),(0,E.jsx)(g,{error:B,onRetry:H})]}):(0,E.jsxs)(`div`,{children:[(0,E.jsx)(v,{title:`Queues`,description:z?`${U.length} queues`:`Queue inventory unavailable`,live:!!z&&!B,actions:U.length>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m,{variant:`warning`,size:`sm`,disabled:p||o.size>0||K.paused>=U.length,onClick:()=>Z(`pause`),children:[(0,E.jsx)(c,{className:`size-3.5`}),` Pause all`]}),(0,E.jsxs)(m,{variant:`success`,size:`sm`,disabled:p||o.size>0||K.paused===0,onClick:()=>Z(`resume`),children:[(0,E.jsx)(u,{className:`size-3.5`}),` Resume all`]})]}):void 0}),B&&(0,E.jsx)(h,{message:`Queue refresh failed — showing the last successful inventory.`,onRetry:H}),(0,E.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,E.jsx)(b,{label:`Waiting`,value:y(K.waiting),tone:`amber`,compact:!0}),(0,E.jsx)(b,{label:`Prioritized`,value:y(K.prioritized),tone:`amber`,compact:!0}),(0,E.jsx)(b,{label:`Active`,value:y(K.active),tone:`blue`,compact:!0}),(0,E.jsx)(b,{label:`Failed`,value:y(K.failed),tone:K.failed?`red`:`default`,compact:!0}),(0,E.jsx)(b,{label:`Paused`,value:y(K.paused),tone:K.paused?`amber`:`default`,compact:!0})]}),(0,E.jsxs)(`div`,{className:`relative mb-4 max-w-sm`,children:[(0,E.jsx)(s,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,E.jsx)(`input`,{value:e,onChange:e=>{t(e.target.value),r(0)},placeholder:`Search queues…`,"aria-label":`Filter queues`,name:`queue-filter`,autoComplete:`off`,className:`h-9 w-full rounded-lg border border-line bg-surface pl-9 pr-3 text-sm text-fg placeholder:text-faint focus:border-accent/60 focus:outline-none focus:ring-2 focus:ring-accent/30`})]}),M&&(0,E.jsx)(`div`,{role:`status`,className:d(`mb-3 text-sm`,M.ok?`text-success`:`text-danger`),children:M.text}),(0,E.jsx)(O,{rows:Y,hasData:!!z,error:B,search:e,sortCol:P,sortDir:I,bulkBusy:p,busy:o,onSort:W,onToggle:e=>void X(e)}),(0,E.jsx)(x,{page:J,pageSize:A,total:G.length,onPageChange:r,label:`queues`})]})}export{M as QueuesOverview};