bunqueue-dashboard 0.0.39 → 0.0.40

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 (69) hide show
  1. package/README.md +5 -5
  2. package/agent/backup/resultValidation.ts +1 -1
  3. package/agent/index.ts +3 -0
  4. package/agent/manager/config.ts +1 -1
  5. package/agent/manager/process.ts +2 -2
  6. package/agent/manager/storageMode.ts +20 -0
  7. package/agent/manager.ts +1 -1
  8. package/agent/queue/routes.ts +57 -2
  9. package/agent/queue/runtime.ts +62 -1
  10. package/agent/queue/types.ts +31 -0
  11. package/agent/queue/validation.ts +16 -0
  12. package/agent/server/controlRoutes.ts +2 -93
  13. package/agent/server/controlStatus.ts +115 -0
  14. package/agent/workflows.ts +1 -1
  15. package/dist/.vite/manifest.json +120 -120
  16. package/dist/assets/{AddJob-d5KBvmN8.js → AddJob-DkbI_J5p.js} +1 -1
  17. package/dist/assets/{Alerts-5I44QTnQ.js → Alerts-CFj-u0iV.js} +1 -1
  18. package/dist/assets/{Benchmark-S1afsQRd.js → Benchmark-Ey2sq57q.js} +1 -1
  19. package/dist/assets/{BulkAddJobs-BO8LWUHE.js → BulkAddJobs-BwPoeSB6.js} +1 -1
  20. package/dist/assets/{CopilotPanel-DDkRd35p.js → CopilotPanel-CniuIIPn.js} +1 -1
  21. package/dist/assets/{Cron-X3Y5uISO.js → Cron-B5XFBvU-.js} +1 -1
  22. package/dist/assets/{CronManager-ugmYEAwY.js → CronManager-Bdg2BECM.js} +1 -1
  23. package/dist/assets/{Database-koy8haPX.js → Database-CB0oOEFB.js} +1 -1
  24. package/dist/assets/{Diagnostics-D6oqvkOs.js → Diagnostics-BDRftXQy.js} +1 -1
  25. package/dist/assets/{Dlq-D70Lzmsa.js → Dlq-CJO9itzJ.js} +1 -1
  26. package/dist/assets/{DlqControl-nUT5Zzkl.js → DlqControl-DZL2lHOU.js} +1 -1
  27. package/dist/assets/{DlqPro-VMuBKgP-.js → DlqPro-OqBlzCnN.js} +1 -1
  28. package/dist/assets/{Flows-CAG0nDnt.js → Flows-BItJzbVQ.js} +2 -2
  29. package/dist/assets/{JobInspector-CiS5HOSQ.js → JobInspector-CJHX63p_.js} +2 -2
  30. package/dist/assets/{Jobs-CkyRvzOT.js → Jobs-BwmTsjJx.js} +1 -1
  31. package/dist/assets/{JobsPro-B4-CSoq3.js → JobsPro-eFVAZJ10.js} +1 -1
  32. package/dist/assets/{Logs-DBTz2PTz.js → Logs-CXIf58M4.js} +1 -1
  33. package/dist/assets/{LogsPro-BCFeegvr.js → LogsPro-Xm6rylAd.js} +1 -1
  34. package/dist/assets/{McpServer-BKlTR1qr.js → McpServer-Rf3i6lRn.js} +2 -2
  35. package/dist/assets/{Metrics-Du__9Lbn.js → Metrics-Cj3VYxzL.js} +1 -1
  36. package/dist/assets/{MetricsPro-CqnaO6YX.js → MetricsPro-C63eY00A.js} +1 -1
  37. package/dist/assets/{Overview-udSSt7ZB.js → Overview-CUM3XG7A.js} +1 -1
  38. package/dist/assets/{QueueActions-D7cQrGvJ.js → QueueActions-b19K0vCT.js} +1 -1
  39. package/dist/assets/QueueControl-DusMoa05.js +1 -0
  40. package/dist/assets/{QueueDetail-C-ms6bMe.js → QueueDetail-CpFIG1PU.js} +1 -1
  41. package/dist/assets/{QueueDetailPro-DXEdsZx_.js → QueueDetailPro-BNlBOj5s.js} +1 -1
  42. package/dist/assets/{Queues-BUMwTVAf.js → Queues-CZ2qc7FY.js} +1 -1
  43. package/dist/assets/{QueuesOverview-Du8XLgN0.js → QueuesOverview-CBFqQ3N_.js} +1 -1
  44. package/dist/assets/{S3Backup-CDICSzxM.js → S3Backup-x4mOV-AO.js} +1 -1
  45. package/dist/assets/{S3BackupPro-CBidbI-s.js → S3BackupPro-BtvbPVg-.js} +3 -3
  46. package/dist/assets/{ServerControl-CPT0LpsC.js → ServerControl-C5nQ7CCp.js} +2 -2
  47. package/dist/assets/{Settings-CmxfSX_8.js → Settings-B5kCRSBH.js} +1 -1
  48. package/dist/assets/{Usage-B895tSxi.js → Usage-UYovs3D-.js} +1 -1
  49. package/dist/assets/{UsagePro-CASN77iV.js → UsagePro-bT82DS-d.js} +1 -1
  50. package/dist/assets/{Webhooks-CXbZOFFw.js → Webhooks-BjsUMJAn.js} +1 -1
  51. package/dist/assets/{Workers-BceQlUhX.js → Workers-CD4YZpca.js} +1 -1
  52. package/dist/assets/{WorkersPro-Dtml89jB.js → WorkersPro-hCPhfb1Z.js} +1 -1
  53. package/dist/assets/{Workflows-B8wmQN2X.js → Workflows-DOpeo-TP.js} +1 -1
  54. package/dist/assets/{api-81m1TwB7.js → api-BxYPEynh.js} +1 -1
  55. package/dist/assets/bq-C7wdABtE.js +1 -0
  56. package/dist/assets/{flowMutationSafety-6cP-l4Pa.js → flowMutationSafety-DSd3JLAV.js} +1 -1
  57. package/dist/assets/{index-TploGF7u.js → index-AUHH2nTG.js} +3 -3
  58. package/dist/assets/{index-B-QjN7pA.css → index-BK7fjWKK.css} +1 -1
  59. package/dist/assets/{install-BPp8nydm.js → install-C5y2ohOo.js} +2 -2
  60. package/dist/assets/{responses-C9lP49qu.js → responses-DiIfPXXq.js} +1 -1
  61. package/dist/assets/{upstreamPaths-ZeijhPPb.js → upstreamPaths-B_cyinGI.js} +1 -1
  62. package/dist/assets/{useThroughputSeries-_J7gWbcI.js → useThroughputSeries-y7Yyi7Zh.js} +1 -1
  63. package/dist/index.html +5 -5
  64. package/package.json +10 -7
  65. package/scripts/bunVersion.ts +10 -0
  66. package/scripts/embedded.gen.ts +148 -148
  67. package/scripts/serve.ts +3 -0
  68. package/dist/assets/QueueControl-BF638r_0.js +0 -1
  69. package/dist/assets/bq-BOfwNIlJ.js +0 -1
@@ -1 +1 @@
1
- import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{t as a}from"./bq-BOfwNIlJ.js";import{T as o}from"./icons-BVzwsfbG.js";import{t as s}from"./api-81m1TwB7.js";import{n as c}from"./usePolledData-CNtNtd0a.js";import{i as l,r as u}from"./feedback-QDN1AsYt.js";import{t as d}from"./StatusBadge-BoOVTnKu.js";import{t as f}from"./PageHeader-CvIyaFOO.js";import{a as p,c as m,d as h,l as g,s as _,t as v}from"./format-Cg7VCIZW.js";import{n as y}from"./index-TploGF7u.js";import{a as b,i as x}from"./form-C4oby9pI.js";import{r as S}from"./flowMutationSafety-6cP-l4Pa.js";import{t as C}from"./promisePool-BVfQ9n9Q.js";var w=e(n(),1),T=`__all__`,E=[`all`,`waiting`,`active`,`completed`,`failed`],D=500,O=20,k=D*O;function A(e,t,n){if(typeof e!=`object`||!e||e.ok!==!0||!Array.isArray(e.queues)||!Number.isSafeInteger(e.total)||e.total<0||e.total>k||n!==null&&e.total!==n||e.offset!==t||e.limit!==D||e.queues.length!==Math.min(D,e.total-t)||e.queues.length>D||e.queues.some(e=>typeof e!=`object`||!e||typeof e.name!=`string`||e.name.length===0||e.name.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(e.name)))throw Error(`Queue discovery returned a malformed or unsafe page`)}async function j(){let e=await s.queues(D,0);A(e,0,null);let t=[...e.queues],n=new Set;for(let e of t){if(n.has(e.name))throw Error(`Queue discovery returned duplicate queue ${e.name}`);n.add(e.name)}let r=e.total,i=1;for(;t.length<r;){if(i>=O||t.length>=k)throw Error(`Queue discovery exceeds the safety limit of ${k}`);let e=t.length,a=await s.queues(D,e);A(a,e,r);for(let e of a.queues){if(n.has(e.name))throw Error(`Queue discovery pages overlap at queue ${e.name}`);n.add(e.name),t.push(e)}i+=1}return{...e,queues:t,total:r,limit:t.length,offset:0}}function M(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.name;return typeof t==`string`&&t.length>0?t:null}var N=i();function P({rows:e,emptyMessage:t}){return(0,N.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,N.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,N.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,N.jsx)(`tbody`,{children:e.length===0?(0,N.jsx)(`tr`,{children:(0,N.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:t})}):e.map(e=>(0,N.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,N.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,N.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`text-accent/90 hover:text-accent hover:underline`,title:`Inspect job ${e.id}`,children:e.id})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name??M(e.data)??`default`}),(0,N.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,N.jsx)(`td`,{className:`px-5 py-3`,children:(0,N.jsx)(d,{status:String(e.state??e.status??`waiting`)})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:g(e.createdAt)}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(h(e.startedAt??void 0,e.completedAt??void 0))}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,N.jsx)(`span`,{className:`text-xs text-faint`,title:S,children:`Delete unavailable`})})]},`${e.queue}:${e.id}`))})]})})}var F=8;function I(){let[e]=t(),[n,r]=(0,w.useState)(e.get(`queue`)??`__all__`),[i,d]=(0,w.useState)(`all`),[p,h]=(0,w.useState)(``),{data:g,error:S,refetch:D}=c(j,[],{intervalMs:3e4}),{data:O,error:k,refetch:A}=c(()=>s.overview(),[]),I=(0,w.useMemo)(()=>(g?.queues??[]).map(e=>e.name),[g]),L=`${n}\u0000${i}\u0000${JSON.stringify(I)}`,{data:R,error:z,loading:B,refetch:V}=c((0,w.useCallback)(async e=>{if(n===`__all__`&&!g)return null;let t=n===`__all__`?I:[n];if(n===`__all__`&&t.length>100)return{scopeKey:L,jobs:[],failures:[],queueCount:t.length,blockedReason:`All-queue job browsing is limited to 100 queues; ${_(t.length)} were discovered. Select one queue to avoid an unsafe request fan-out.`};let r=i===`all`?void 0:[i],o=a.createServerTargetClient(a.captureServerRequestTarget(),e),s=await C(t,F,async t=>(e.throwIfAborted(),(await o.jobsList(t,r,40)).jobs.map(e=>({...e,stacktrace:e.stacktrace??void 0,queue:e.queue??t}))),e);e.throwIfAborted();let c=[],l=[];return s.forEach((e,n)=>{e.status===`fulfilled`?c.push(...e.value):l.push({queue:t[n],message:e.reason instanceof Error?e.reason.message:String(e.reason)})}),{scopeKey:L,jobs:c.sort((e,t)=>(t.createdAt??0)-(e.createdAt??0)),failures:l,queueCount:t.length,blockedReason:null}},[n,i,g,I,L]),[L],{intervalMs:15e3}),H=R?.scopeKey===L?R:null,U=H?.blockedReason?null:H?.jobs??null,{rows:W,matchingCount:G}=(0,w.useMemo)(()=>{let e=U??[],t=p.trim().toLowerCase(),n=t?e.filter(e=>typeof e.id==`string`&&e.id.toLowerCase().includes(t)||(M(e.data)?.toLowerCase().includes(t)??!1)):e;return{rows:n.slice(0,100),matchingCount:n.length}},[U,p]),K=O?.stats,q=K?v(K.totalCompleted,K.totalFailed):null,J=e=>K?_(e):`—`,Y=!!H&&H.queueCount>0&&H.failures.length===H.queueCount,X=n===`__all__`&&!g&&!S||B&&!H&&!z,Z=`No jobs found.`;return H?.blockedReason?Z=H.blockedReason:n===`__all__`&&S&&!g?Z=`Queue discovery unavailable — ${S.message}`:z&&!H?Z=`Could not load jobs — ${z.message}`:Y?Z=`Could not load jobs from any of the ${H.queueCount} queues.`:p.trim()&&H?.failures.length?Z=`No matching jobs in the queue results that could be loaded.`:p.trim()&&(Z=`No jobs match this search.`),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(f,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!H&&!S&&!k&&!z&&!H.blockedReason&&H.failures.length===0}),S&&(0,N.jsx)(l,{message:`Queue discovery unavailable — ${S.message}`,onRetry:D}),k&&(0,N.jsx)(l,{message:`Job totals unavailable — ${k.message}`,onRetry:A}),z&&(0,N.jsx)(l,{message:`Could not load jobs — ${z.message}`,onRetry:V}),H?.blockedReason&&(0,N.jsx)(l,{message:H.blockedReason}),!!H?.failures.length&&(0,N.jsx)(l,{message:`Could not load jobs from ${H.failures.length} of ${H.queueCount} queues: ${H.failures.slice(0,3).map(e=>`${e.queue} (${e.message})`).join(`, `)}${H.failures.length>3?`, …`:``}`,onRetry:V}),(0,N.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,N.jsx)(y,{label:`Total`,value:K?_(K.totalCompleted+K.totalFailed+K.waiting+K.active):`—`,compact:!0}),(0,N.jsx)(y,{label:`Waiting`,value:J(K?.waiting),tone:`amber`,compact:!0}),(0,N.jsx)(y,{label:`Active`,value:J(K?.active),tone:`blue`,compact:!0}),(0,N.jsx)(y,{label:`Completed`,value:J(K?.totalCompleted),tone:`green`,compact:!0}),(0,N.jsx)(y,{label:`Failed`,value:J(K?.totalFailed),tone:K?.totalFailed?`red`:`default`,compact:!0}),(0,N.jsx)(y,{label:`Error Rate`,value:q==null?`—`:m(q),tone:q==null?`default`:q>.05?`red`:`green`,compact:!0})]}),(0,N.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,N.jsx)(`div`,{className:`w-48`,children:(0,N.jsxs)(b,{value:n,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>r(e.target.value),children:[(0,N.jsx)(`option`,{value:T,children:`All Queues`}),(g?.queues??[]).map(e=>(0,N.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,N.jsx)(x,{options:E,value:i,onChange:d}),(0,N.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,N.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,N.jsx)(`input`,{value:p,onChange:e=>h(e.target.value),"aria-label":`Search jobs`,name:`jobs-search`,autoComplete:`off`,placeholder:`Search by ID or name…`,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`})]})]}),H&&!H.blockedReason&&(0,N.jsxs)(`p`,{role:`status`,className:`mb-3 text-xs text-faint`,children:[n===`__all__`?`Queried all ${_(H.queueCount)} discovered queues`:`Queried ${n}`,` `,`· up to `,40,` recent jobs per queue`,G>100?` · showing the newest 100 of ${_(G)} matches`:``]}),X?(0,N.jsx)(u,{label:`Loading jobs…`}):(0,N.jsx)(P,{rows:W,emptyMessage:Z})]})}export{I as Jobs,j as t};
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{f as t,g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{t as a}from"./bq-C7wdABtE.js";import{T as o}from"./icons-BVzwsfbG.js";import{t as s}from"./api-BxYPEynh.js";import{n as c}from"./usePolledData-CNtNtd0a.js";import{i as l,r as u}from"./feedback-QDN1AsYt.js";import{t as d}from"./StatusBadge-BoOVTnKu.js";import{t as f}from"./PageHeader-CvIyaFOO.js";import{a as p,c as m,d as h,l as g,s as _,t as v}from"./format-Cg7VCIZW.js";import{n as y}from"./index-AUHH2nTG.js";import{a as b,i as x}from"./form-C4oby9pI.js";import{r as S}from"./flowMutationSafety-DSd3JLAV.js";import{t as C}from"./promisePool-BVfQ9n9Q.js";var w=e(n(),1),T=`__all__`,E=[`all`,`waiting`,`active`,`completed`,`failed`],D=500,O=20,k=D*O;function A(e,t,n){if(typeof e!=`object`||!e||e.ok!==!0||!Array.isArray(e.queues)||!Number.isSafeInteger(e.total)||e.total<0||e.total>k||n!==null&&e.total!==n||e.offset!==t||e.limit!==D||e.queues.length!==Math.min(D,e.total-t)||e.queues.length>D||e.queues.some(e=>typeof e!=`object`||!e||typeof e.name!=`string`||e.name.length===0||e.name.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(e.name)))throw Error(`Queue discovery returned a malformed or unsafe page`)}async function j(){let e=await s.queues(D,0);A(e,0,null);let t=[...e.queues],n=new Set;for(let e of t){if(n.has(e.name))throw Error(`Queue discovery returned duplicate queue ${e.name}`);n.add(e.name)}let r=e.total,i=1;for(;t.length<r;){if(i>=O||t.length>=k)throw Error(`Queue discovery exceeds the safety limit of ${k}`);let e=t.length,a=await s.queues(D,e);A(a,e,r);for(let e of a.queues){if(n.has(e.name))throw Error(`Queue discovery pages overlap at queue ${e.name}`);n.add(e.name),t.push(e)}i+=1}return{...e,queues:t,total:r,limit:t.length,offset:0}}function M(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e.name;return typeof t==`string`&&t.length>0?t:null}var N=i();function P({rows:e,emptyMessage:t}){return(0,N.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,N.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Job ID`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queue`}),(0,N.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Priority`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`}),(0,N.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,N.jsx)(`th`,{className:`w-12 px-5 py-3`})]})}),(0,N.jsx)(`tbody`,{children:e.length===0?(0,N.jsx)(`tr`,{children:(0,N.jsx)(`td`,{colSpan:8,className:`px-5 py-12 text-center text-sm text-faint`,children:t})}):e.map(e=>(0,N.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,N.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,N.jsx)(r,{to:`/job?id=${encodeURIComponent(e.id)}`,className:`text-accent/90 hover:text-accent hover:underline`,title:`Inspect job ${e.id}`,children:e.id})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.name??M(e.data)??`default`}),(0,N.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queue}),(0,N.jsx)(`td`,{className:`px-5 py-3`,children:(0,N.jsx)(d,{status:String(e.state??e.status??`waiting`)})}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:e.priority??0}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:g(e.createdAt)}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:p(h(e.startedAt??void 0,e.completedAt??void 0))}),(0,N.jsx)(`td`,{className:`px-5 py-3 text-right`,children:(0,N.jsx)(`span`,{className:`text-xs text-faint`,title:S,children:`Delete unavailable`})})]},`${e.queue}:${e.id}`))})]})})}var F=8;function I(){let[e]=t(),[n,r]=(0,w.useState)(e.get(`queue`)??`__all__`),[i,d]=(0,w.useState)(`all`),[p,h]=(0,w.useState)(``),{data:g,error:S,refetch:D}=c(j,[],{intervalMs:3e4}),{data:O,error:k,refetch:A}=c(()=>s.overview(),[]),I=(0,w.useMemo)(()=>(g?.queues??[]).map(e=>e.name),[g]),L=`${n}\u0000${i}\u0000${JSON.stringify(I)}`,{data:R,error:z,loading:B,refetch:V}=c((0,w.useCallback)(async e=>{if(n===`__all__`&&!g)return null;let t=n===`__all__`?I:[n];if(n===`__all__`&&t.length>100)return{scopeKey:L,jobs:[],failures:[],queueCount:t.length,blockedReason:`All-queue job browsing is limited to 100 queues; ${_(t.length)} were discovered. Select one queue to avoid an unsafe request fan-out.`};let r=i===`all`?void 0:[i],o=a.createServerTargetClient(a.captureServerRequestTarget(),e),s=await C(t,F,async t=>(e.throwIfAborted(),(await o.jobsList(t,r,40)).jobs.map(e=>({...e,stacktrace:e.stacktrace??void 0,queue:e.queue??t}))),e);e.throwIfAborted();let c=[],l=[];return s.forEach((e,n)=>{e.status===`fulfilled`?c.push(...e.value):l.push({queue:t[n],message:e.reason instanceof Error?e.reason.message:String(e.reason)})}),{scopeKey:L,jobs:c.sort((e,t)=>(t.createdAt??0)-(e.createdAt??0)),failures:l,queueCount:t.length,blockedReason:null}},[n,i,g,I,L]),[L],{intervalMs:15e3}),H=R?.scopeKey===L?R:null,U=H?.blockedReason?null:H?.jobs??null,{rows:W,matchingCount:G}=(0,w.useMemo)(()=>{let e=U??[],t=p.trim().toLowerCase(),n=t?e.filter(e=>typeof e.id==`string`&&e.id.toLowerCase().includes(t)||(M(e.data)?.toLowerCase().includes(t)??!1)):e;return{rows:n.slice(0,100),matchingCount:n.length}},[U,p]),K=O?.stats,q=K?v(K.totalCompleted,K.totalFailed):null,J=e=>K?_(e):`—`,Y=!!H&&H.queueCount>0&&H.failures.length===H.queueCount,X=n===`__all__`&&!g&&!S||B&&!H&&!z,Z=`No jobs found.`;return H?.blockedReason?Z=H.blockedReason:n===`__all__`&&S&&!g?Z=`Queue discovery unavailable — ${S.message}`:z&&!H?Z=`Could not load jobs — ${z.message}`:Y?Z=`Could not load jobs from any of the ${H.queueCount} queues.`:p.trim()&&H?.failures.length?Z=`No matching jobs in the queue results that could be loaded.`:p.trim()&&(Z=`No jobs match this search.`),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(f,{title:`Jobs Explorer`,description:`Browse, inspect, and manage individual jobs.`,live:!!H&&!S&&!k&&!z&&!H.blockedReason&&H.failures.length===0}),S&&(0,N.jsx)(l,{message:`Queue discovery unavailable — ${S.message}`,onRetry:D}),k&&(0,N.jsx)(l,{message:`Job totals unavailable — ${k.message}`,onRetry:A}),z&&(0,N.jsx)(l,{message:`Could not load jobs — ${z.message}`,onRetry:V}),H?.blockedReason&&(0,N.jsx)(l,{message:H.blockedReason}),!!H?.failures.length&&(0,N.jsx)(l,{message:`Could not load jobs from ${H.failures.length} of ${H.queueCount} queues: ${H.failures.slice(0,3).map(e=>`${e.queue} (${e.message})`).join(`, `)}${H.failures.length>3?`, …`:``}`,onRetry:V}),(0,N.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,N.jsx)(y,{label:`Total`,value:K?_(K.totalCompleted+K.totalFailed+K.waiting+K.active):`—`,compact:!0}),(0,N.jsx)(y,{label:`Waiting`,value:J(K?.waiting),tone:`amber`,compact:!0}),(0,N.jsx)(y,{label:`Active`,value:J(K?.active),tone:`blue`,compact:!0}),(0,N.jsx)(y,{label:`Completed`,value:J(K?.totalCompleted),tone:`green`,compact:!0}),(0,N.jsx)(y,{label:`Failed`,value:J(K?.totalFailed),tone:K?.totalFailed?`red`:`default`,compact:!0}),(0,N.jsx)(y,{label:`Error Rate`,value:q==null?`—`:m(q),tone:q==null?`default`:q>.05?`red`:`green`,compact:!0})]}),(0,N.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[(0,N.jsx)(`div`,{className:`w-48`,children:(0,N.jsxs)(b,{value:n,"aria-label":`Queue`,name:`jobs-queue`,autoComplete:`off`,onChange:e=>r(e.target.value),children:[(0,N.jsx)(`option`,{value:T,children:`All Queues`}),(g?.queues??[]).map(e=>(0,N.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}),(0,N.jsx)(x,{options:E,value:i,onChange:d}),(0,N.jsxs)(`div`,{className:`relative ml-auto min-w-56 flex-1 md:max-w-xs`,children:[(0,N.jsx)(o,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-faint`}),(0,N.jsx)(`input`,{value:p,onChange:e=>h(e.target.value),"aria-label":`Search jobs`,name:`jobs-search`,autoComplete:`off`,placeholder:`Search by ID or name…`,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`})]})]}),H&&!H.blockedReason&&(0,N.jsxs)(`p`,{role:`status`,className:`mb-3 text-xs text-faint`,children:[n===`__all__`?`Queried all ${_(H.queueCount)} discovered queues`:`Queried ${n}`,` `,`· up to `,40,` recent jobs per queue`,G>100?` · showing the newest 100 of ${_(G)} matches`:``]}),X?(0,N.jsx)(u,{label:`Loading jobs…`}):(0,N.jsx)(P,{rows:W,emptyMessage:Z})]})}export{I as Jobs,j as t};
@@ -1 +1 @@
1
- import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CvwrP0tU.js";import{t as o}from"./bq-BOfwNIlJ.js";import{t as s}from"./toastStore-B31o6Z5J.js";import{T as c,d as l,f as u,x as d}from"./icons-BVzwsfbG.js";import{n as f}from"./usePolledData-CNtNtd0a.js";import{n as p,t as m}from"./Button-Ch1W94fJ.js";import{i as h,n as g,r as _}from"./feedback-QDN1AsYt.js";import{t as v}from"./StatusBadge-BoOVTnKu.js";import{t as y}from"./PageHeader-CvIyaFOO.js";import{a as b,c as x,i as S,s as C,t as ee}from"./format-Cg7VCIZW.js";import{n as w}from"./index-TploGF7u.js";import{a as T}from"./form-C4oby9pI.js";import{t as E}from"./Pagination-x-Cwgrul.js";import{r as D,t as O}from"./useServerActionGuard-Db7PPgaI.js";import{t as te}from"./exportFile-C7xhE8Yh.js";import{t as k}from"./jobActions-LQD4KfCc.js";var A=e(r(),1),j=a();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:n,search:r,discoveryError:a,selected:s,allSelected:c,bulkBusy:l,busyIds:f,page:m,hasNext:h,onToggleAll:g,onToggle:_,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:c,ref:e=>{e&&(e.indeterminate=s.size>0&&!c)},"aria-checked":s.size>0&&!c?`mixed`:c,onChange:g,"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:n.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:r.trim()?`No jobs on this page match your ID or name filter.`:e?`No jobs found.`:a?`Queue discovery failed. Retry above.`:`Select a queue.`})}):n.map(e=>{let n=F(e.priority),r=k(e.state),a=l||f.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:s.has(e.id),onChange:()=>_(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)(v,{status:String(e.state??`waiting`)})}),(0,j.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.className),children:n.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)(i,{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)(u,{className:`size-3.5`})}),r.promote&&(0,j.jsx)(p,{"aria-label":`Promote job`,disabled:a,onClick:()=>y(e,`Promote`,()=>o.promoteJob(e.id)),children:(0,j.jsx)(d,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,j.jsx)(E,{page:m,pageSize:25,hasNext:h,onPageChange:x,label:`jobs`})]})}function I({queue:e,summary:t,status:n,search:r,selectedTotal:i,selectedVisible:a,canPromote:o,bulkBusy:s,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)(c,{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)(m,{size:`sm`,disabled:s,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,o]=(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)(()=>{o(new Set),l(!1),d(null)},[f.scopeKey]),{actionMsg:u,bulkBusy:c,busyIds:a,runBulk:async(e,a,o,c)=>{let u=t.filter(e=>n.has(e.id)&&o(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,o=t.length-n,c=`${e}: ${n} succeeded${o?`, ${o} failed`:``}`;d({ok:o===0,text:c}),o===0?s.success(c):s.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){o(t=>new Set(t).add(e.id)),d(null);try{if(O(await n(),t),!a.isCurrent())return;d({ok:!0,text:`${t} ✓`}),s.success(`${t} ✓`,e.id),i()}catch(e){if(!a.isCurrent())return;d({ok:!1,text:`${t} failed: ${e.message}`}),s.error(`${t} failed`,e.message)}finally{a.finish()&&o(t=>{let n=new Set(t);return n.delete(e.id),n})}}}}}function L(){let[e,t]=n(),[r,i]=(0,A.useState)(e.get(`queue`)??``),[a,c]=(0,A.useState)(()=>{let t=e.get(`status`);return t&&M.includes(t)?t:`all`}),[u,d]=(0,A.useState)(``),[p,v]=(0,A.useState)(0),[b,S]=(0,A.useState)(new Set),{data:w,error:T,loading:E,refetch:D}=f(()=>o.queuesSummary(),[],{intervalMs:3e4}),{data:O,error:N,refetch:P}=f(()=>o.stats(),[],{intervalMs:1e4});(0,A.useEffect)(()=>{!r&&w?.length&&i(w[0].name)},[w,r]);let F=`${r}|${a}|${p}`,{data:L,error:R,loading:z,refetch:B}=f((0,A.useCallback)(async()=>{if(!r)return{view:F,jobs:[]};let e=a===`all`?void 0:[a],t=await o.jobsList(r,e,25,p*25);return{view:F,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??r}))}},[r,a,p,F]),[r,a,p]),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=()=>v(0),J=(e,n)=>{let r={};e&&(r.queue=e),n!==`all`&&(r.status=n),t(r,{replace:!0})};(0,A.useEffect)(()=>{S(new Set)},[r,a,p]);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)(m,{size:`sm`,disabled:!V||H.length===0,onClick:()=>{if(H.length===0){s.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}-${a}`,e,[`id`,`name`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])},children:[(0,j.jsx)(l,{className:`size-3.5`}),` Export CSV`]})}),T&&(0,j.jsx)(h,{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)(h,{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:a,search:u,selectedTotal:b.size,selectedVisible:$.length,canPromote:de.promote,bulkBusy:Z,onQueue:e=>{i(e),q(),J(e,a)},onStatus:e=>{c(e),q(),J(r,e)},onSearch:d,onPromote:()=>le(`Promote`,e=>o.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)(h,{message:`Job refresh failed — showing the last successful page.`,onRetry:B}),R&&!V?(0,j.jsx)(g,{error:R,onRetry:B}):E&&!w&&!r&&!T?(0,j.jsx)(_,{label:`Discovering queues…`}):z&&!V?(0,j.jsx)(_,{label:`Loading jobs…`}):(0,j.jsx)(re,{queue:r,rows:H,search:u,discoveryError:!!T,selected:b,allSelected:Y,bulkBusy:Z,busyIds:ce,page:p,hasNext:ae,onToggleAll:se,onToggle:oe,onRun:(e,t,n)=>void ue(e,t,n),onPage:v})]})}export{L as JobsPro};
1
+ import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,r as i,t as a}from"./react-vendor-CvwrP0tU.js";import{t as o}from"./bq-C7wdABtE.js";import{t as s}from"./toastStore-B31o6Z5J.js";import{T as c,d as l,f as u,x as d}from"./icons-BVzwsfbG.js";import{n as f}from"./usePolledData-CNtNtd0a.js";import{n as p,t as m}from"./Button-Ch1W94fJ.js";import{i as h,n as g,r as _}from"./feedback-QDN1AsYt.js";import{t as v}from"./StatusBadge-BoOVTnKu.js";import{t as y}from"./PageHeader-CvIyaFOO.js";import{a as b,c as x,i as S,s as C,t as ee}from"./format-Cg7VCIZW.js";import{n as w}from"./index-AUHH2nTG.js";import{a as T}from"./form-C4oby9pI.js";import{t as E}from"./Pagination-x-Cwgrul.js";import{r as D,t as O}from"./useServerActionGuard-Db7PPgaI.js";import{t as te}from"./exportFile-C7xhE8Yh.js";import{t as k}from"./jobActions-LQD4KfCc.js";var A=e(r(),1),j=a();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:n,search:r,discoveryError:a,selected:s,allSelected:c,bulkBusy:l,busyIds:f,page:m,hasNext:h,onToggleAll:g,onToggle:_,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:c,ref:e=>{e&&(e.indeterminate=s.size>0&&!c)},"aria-checked":s.size>0&&!c?`mixed`:c,onChange:g,"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:n.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:r.trim()?`No jobs on this page match your ID or name filter.`:e?`No jobs found.`:a?`Queue discovery failed. Retry above.`:`Select a queue.`})}):n.map(e=>{let n=F(e.priority),r=k(e.state),a=l||f.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:s.has(e.id),onChange:()=>_(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)(v,{status:String(e.state??`waiting`)})}),(0,j.jsx)(`td`,{className:t(`px-5 py-3 text-xs font-semibold`,n.className),children:n.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)(i,{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)(u,{className:`size-3.5`})}),r.promote&&(0,j.jsx)(p,{"aria-label":`Promote job`,disabled:a,onClick:()=>y(e,`Promote`,()=>o.promoteJob(e.id)),children:(0,j.jsx)(d,{className:`size-3.5`})})]})})]},e.id)})})]})}),(0,j.jsx)(E,{page:m,pageSize:25,hasNext:h,onPageChange:x,label:`jobs`})]})}function I({queue:e,summary:t,status:n,search:r,selectedTotal:i,selectedVisible:a,canPromote:o,bulkBusy:s,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)(c,{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)(m,{size:`sm`,disabled:s,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,o]=(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)(()=>{o(new Set),l(!1),d(null)},[f.scopeKey]),{actionMsg:u,bulkBusy:c,busyIds:a,runBulk:async(e,a,o,c)=>{let u=t.filter(e=>n.has(e.id)&&o(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,o=t.length-n,c=`${e}: ${n} succeeded${o?`, ${o} failed`:``}`;d({ok:o===0,text:c}),o===0?s.success(c):s.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){o(t=>new Set(t).add(e.id)),d(null);try{if(O(await n(),t),!a.isCurrent())return;d({ok:!0,text:`${t} ✓`}),s.success(`${t} ✓`,e.id),i()}catch(e){if(!a.isCurrent())return;d({ok:!1,text:`${t} failed: ${e.message}`}),s.error(`${t} failed`,e.message)}finally{a.finish()&&o(t=>{let n=new Set(t);return n.delete(e.id),n})}}}}}function L(){let[e,t]=n(),[r,i]=(0,A.useState)(e.get(`queue`)??``),[a,c]=(0,A.useState)(()=>{let t=e.get(`status`);return t&&M.includes(t)?t:`all`}),[u,d]=(0,A.useState)(``),[p,v]=(0,A.useState)(0),[b,S]=(0,A.useState)(new Set),{data:w,error:T,loading:E,refetch:D}=f(()=>o.queuesSummary(),[],{intervalMs:3e4}),{data:O,error:N,refetch:P}=f(()=>o.stats(),[],{intervalMs:1e4});(0,A.useEffect)(()=>{!r&&w?.length&&i(w[0].name)},[w,r]);let F=`${r}|${a}|${p}`,{data:L,error:R,loading:z,refetch:B}=f((0,A.useCallback)(async()=>{if(!r)return{view:F,jobs:[]};let e=a===`all`?void 0:[a],t=await o.jobsList(r,e,25,p*25);return{view:F,jobs:(t.jobs??[]).map(e=>({...e,queue:e.queue??r}))}},[r,a,p,F]),[r,a,p]),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=()=>v(0),J=(e,n)=>{let r={};e&&(r.queue=e),n!==`all`&&(r.status=n),t(r,{replace:!0})};(0,A.useEffect)(()=>{S(new Set)},[r,a,p]);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)(m,{size:`sm`,disabled:!V||H.length===0,onClick:()=>{if(H.length===0){s.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}-${a}`,e,[`id`,`name`,`queue`,`state`,`priority`,`attempts`,`maxAttempts`,`createdAt`,`durationMs`])},children:[(0,j.jsx)(l,{className:`size-3.5`}),` Export CSV`]})}),T&&(0,j.jsx)(h,{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)(h,{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:a,search:u,selectedTotal:b.size,selectedVisible:$.length,canPromote:de.promote,bulkBusy:Z,onQueue:e=>{i(e),q(),J(e,a)},onStatus:e=>{c(e),q(),J(r,e)},onSearch:d,onPromote:()=>le(`Promote`,e=>o.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)(h,{message:`Job refresh failed — showing the last successful page.`,onRetry:B}),R&&!V?(0,j.jsx)(g,{error:R,onRetry:B}):E&&!w&&!r&&!T?(0,j.jsx)(_,{label:`Discovering queues…`}):z&&!V?(0,j.jsx)(_,{label:`Loading jobs…`}):(0,j.jsx)(re,{queue:r,rows:H,search:u,discoveryError:!!T,selected:b,allSelected:Y,bulkBusy:Z,busyIds:ce,page:p,hasNext:ae,onToggleAll:se,onToggle:oe,onRun:(e,t,n)=>void ue(e,t,n),onPage:v})]})}export{L as JobsPro};
@@ -1 +1 @@
1
- import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{T as r,h as i}from"./icons-BVzwsfbG.js";import{n as a}from"./usePolledData-CNtNtd0a.js";import{i as o,t as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./StatusBadge-BoOVTnKu.js";import{t as l}from"./PageHeader-CvIyaFOO.js";import{l as u,s as d}from"./format-Cg7VCIZW.js";import{n as f,t as p}from"./index-TploGF7u.js";import{a as m,i as h}from"./form-C4oby9pI.js";import{t as g}from"./Pagination-x-Cwgrul.js";import{t as _}from"./Jobs-CkyRvzOT.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}=a(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)(o,{onRetry:A,message:`Could not discover queues — ${k.message}. The current stream can still be used.`}),F&&(0,y.jsx)(o,{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)(s,{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)(c,{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{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{T as r,h as i}from"./icons-BVzwsfbG.js";import{n as a}from"./usePolledData-CNtNtd0a.js";import{i as o,t as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./StatusBadge-BoOVTnKu.js";import{t as l}from"./PageHeader-CvIyaFOO.js";import{l as u,s as d}from"./format-Cg7VCIZW.js";import{n as f,t as p}from"./index-AUHH2nTG.js";import{a as m,i as h}from"./form-C4oby9pI.js";import{t as g}from"./Pagination-x-Cwgrul.js";import{t as _}from"./Jobs-BwmTsjJx.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}=a(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)(o,{onRetry:A,message:`Could not discover queues — ${k.message}. The current stream can still be used.`}),F&&(0,y.jsx)(o,{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)(s,{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)(c,{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{i as e}from"./cn-zFEt5SO8.js";import{g as t,r as n,t as r}from"./react-vendor-CvwrP0tU.js";import{o as i}from"./connectionStore-CFuNYZ_8.js";import{T as a}from"./icons-BVzwsfbG.js";import{n as o}from"./usePolledData-CNtNtd0a.js";import{t as s}from"./Button-Ch1W94fJ.js";import{i as c}from"./feedback-QDN1AsYt.js";import{t as l}from"./StatusBadge-BoOVTnKu.js";import{t as u}from"./PageHeader-CvIyaFOO.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{a as p,n as m,t as h}from"./index-TploGF7u.js";import{a as g,i as _}from"./form-C4oby9pI.js";import{t as v}from"./Pagination-x-Cwgrul.js";import{t as y}from"./QueueControl-BF638r_0.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}=o(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)(c,{onRetry:L,message:`Could not discover queues — ${I.message}. The current stream can still be used.`}),H&&(0,x.jsx)(c,{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)(s,{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)(l,{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{i as e}from"./cn-zFEt5SO8.js";import{g as t,r as n,t as r}from"./react-vendor-CvwrP0tU.js";import{o as i}from"./connectionStore-CFuNYZ_8.js";import{T as a}from"./icons-BVzwsfbG.js";import{n as o}from"./usePolledData-CNtNtd0a.js";import{t as s}from"./Button-Ch1W94fJ.js";import{i as c}from"./feedback-QDN1AsYt.js";import{t as l}from"./StatusBadge-BoOVTnKu.js";import{t as u}from"./PageHeader-CvIyaFOO.js";import{l as d,s as f}from"./format-Cg7VCIZW.js";import{a as p,n as m,t as h}from"./index-AUHH2nTG.js";import{a as g,i as _}from"./form-C4oby9pI.js";import{t as v}from"./Pagination-x-Cwgrul.js";import{t as y}from"./QueueControl-DusMoa05.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}=o(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)(c,{onRetry:L,message:`Could not discover queues — ${I.message}. The current stream can still be used.`}),H&&(0,x.jsx)(c,{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)(s,{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)(l,{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-CvwrP0tU.js";import{n as t,t as n}from"./Card-CWxrC8OY.js";import{t as r}from"./PageHeader-CvIyaFOO.js";import{a as i,n as a}from"./index-TploGF7u.js";var o=e(),s=`{
1
+ import{t as e}from"./react-vendor-CvwrP0tU.js";import{n as t,t as n}from"./Card-CWxrC8OY.js";import{t as r}from"./PageHeader-CvIyaFOO.js";import{a as i,n as a}from"./index-AUHH2nTG.js";var o=e(),s=`{
2
2
  "mcpServers": {
3
3
  "bunqueue": {
4
4
  "command": "bunx",
@@ -19,4 +19,4 @@ import{t as e}from"./react-vendor-CvwrP0tU.js";import{n as t,t as n}from"./Card-
19
19
  }
20
20
  }
21
21
  }
22
- }`,l=`claude mcp add bunqueue -- bunx --package=bunqueue bunqueue-mcp`,u=[{name:`Jobs`,count:11,examples:[`add_job`,`get_job`,`get_jobs`,`get_job_result`,`wait_for_job`]},{name:`Job management`,count:6,examples:[`cancel_job`,`change_job_priority`,`promote_job`,`update_job_data`]},{name:`Consumption`,count:8,examples:[`pull_job`,`pull_job_batch`,`ack_job`,`fail_job`,`job_heartbeat`]},{name:`Queues`,count:11,examples:[`list_queues`,`pause_queue`,`resume_queue`,`drain_queue`,`obliterate_queue`]},{name:`Dead letter queue`,count:4,examples:[`get_dlq`,`retry_dlq`,`purge_dlq`]},{name:`Cron`,count:4,examples:[`add_cron`,`list_crons`,`get_cron`,`delete_cron`]},{name:`Flows`,count:4,examples:[`add_flow`,`add_flow_chain`,`get_flow`,`get_children_values`]},{name:`Rate limits`,count:4,examples:[`set_rate_limit`,`set_concurrency`,`clear_rate_limit`]},{name:`Webhooks`,count:4,examples:[`add_webhook`,`list_webhooks`,`remove_webhook`,`set_webhook_enabled`]},{name:`Workers`,count:3,examples:[`register_worker`,`list_workers`,`worker_heartbeat`]},{name:`Handlers`,count:3,examples:[`register_handler`,`list_handlers`,`unregister_handler`]},{name:`Monitoring`,count:11,examples:[`get_stats`,`get_queue_stats`,`get_memory_stats`,`get_prometheus_metrics`]}],d=[`bunqueue://queues`,`bunqueue://stats`,`bunqueue://workers`,`bunqueue://crons`,`bunqueue://webhooks`],f=[`bunqueue_debug_queue`,`bunqueue_health_report`,`bunqueue_incident_response`],p=u.reduce((e,t)=>e+t.count,0);function m({code:e}){return(0,o.jsxs)(`div`,{className:`relative min-w-0 max-w-full`,children:[(0,o.jsx)(`div`,{className:`absolute right-2 top-2`,children:(0,o.jsx)(i,{value:e})}),(0,o.jsx)(`pre`,{className:`max-w-full overflow-x-auto overscroll-x-contain rounded-lg border border-line bg-surface-2 p-4 pr-12 font-mono text-xs leading-relaxed text-fg`,children:e})]})}function h({children:e}){return(0,o.jsx)(`span`,{className:`max-w-full break-all rounded-md border border-line bg-surface-2 px-1.5 py-0.5 font-mono text-[11px] text-muted`,children:e})}function g(){return(0,o.jsxs)(`div`,{className:`min-w-0 overflow-x-hidden`,children:[(0,o.jsx)(r,{title:`MCP Server`,description:`Connect bunqueue to AI agents (Claude Desktop, Claude Code) over the Model Context Protocol.`,actions:(0,o.jsx)(`a`,{href:`https://egeominotti.github.io/bunqueue-dashboard/docs/guide/mcp`,target:`_blank`,rel:`noopener noreferrer`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Docs`})}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted`,children:[`bunqueue ships a Model Context Protocol server,`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`bunqueue-mcp`}),`, that lets an AI agent drive the queue with tools, resources, and prompts. It is a separate`,` `,(0,o.jsx)(`span`,{className:`text-fg`,children:`stdio`}),` process, launched by the MCP client (not by this dashboard, and not part of the HTTP API), so this page is a setup and reference guide rather than a live monitor. It needs the optional peer dependency`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`@modelcontextprotocol/sdk`}),`.`]}),(0,o.jsx)(`p`,{className:`mt-3 text-sm leading-relaxed text-warning`,children:`The upstream MCP includes destructive Cancel, Discard, Drain, Obliterate, DLQ Retry and DLQ Purge tools. They bypass this dashboard's v2.9.0 flow-safety gates and have no atomic reverse-dependency or job-generation precondition. Grant MCP write access only after independently proving the workload is not flow-linked.`})]}),(0,o.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,o.jsx)(a,{label:`Tools`,value:String(p)}),(0,o.jsx)(a,{label:`Categories`,value:String(u.length)}),(0,o.jsx)(a,{label:`Resources`,value:String(d.length)}),(0,o.jsx)(a,{label:`Prompts`,value:String(f.length)})]}),(0,o.jsxs)(`div`,{className:`mb-6 grid gap-4 lg:grid-cols-2`,children:[(0,o.jsxs)(n,{className:`min-w-0`,children:[(0,o.jsx)(t,{title:`Embedded mode (default)`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Direct SQLite access, no running server. Point `,(0,o.jsx)(h,{children:`DATA_PATH`}),` at the bunqueue database file. Best for a local agent on the same machine.`]}),(0,o.jsx)(m,{code:s})]}),(0,o.jsxs)(n,{className:`min-w-0`,children:[(0,o.jsx)(t,{title:`TCP mode (remote server)`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Connect to a running bunqueue server over its TCP protocol port (`,(0,o.jsx)(h,{children:`6789`}),`, distinct from the HTTP admin API on 6790). Use a `,(0,o.jsx)(h,{children:`BUNQUEUE_TOKEN`}),` if the server has one.`]}),(0,o.jsx)(m,{code:c})]})]}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsx)(t,{title:`Where to put it`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Add the JSON above to your MCP client config (for Claude Desktop, its`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`claude_desktop_config.json`}),`). For Claude Code, register it from the CLI:`]}),(0,o.jsx)(m,{code:l})]}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsx)(t,{title:`Tools`,action:(0,o.jsxs)(`span`,{className:`text-xs text-faint`,children:[p,` total`]})}),(0,o.jsx)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 lg:grid-cols-3`,children:u.map(e=>(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between gap-2`,children:[(0,o.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:e.count})]}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.examples.map(e=>(0,o.jsx)(h,{children:e},e))})]},e.name))}),(0,o.jsxs)(`p`,{className:`mt-4 text-xs text-faint`,children:[`Every tool name is prefixed `,(0,o.jsx)(`span`,{className:`font-mono`,children:`bunqueue_`}),` (examples above drop it). Counts total `,p,`.`]})]}),(0,o.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,o.jsxs)(n,{children:[(0,o.jsx)(t,{title:`Resources`,action:(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:d.length})}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:d.map(e=>(0,o.jsx)(h,{children:e},e))})]}),(0,o.jsxs)(n,{children:[(0,o.jsx)(t,{title:`Prompts`,action:(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:f.length})}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.map(e=>(0,o.jsx)(h,{children:e},e))})]})]})]})}export{g as McpServer};
22
+ }`,l=`claude mcp add bunqueue -- bunx --package=bunqueue bunqueue-mcp`,u=[{name:`Jobs`,count:11,examples:[`add_job`,`get_job`,`get_jobs`,`get_job_result`,`wait_for_job`]},{name:`Job management`,count:6,examples:[`cancel_job`,`change_job_priority`,`promote_job`,`update_job_data`]},{name:`Consumption`,count:8,examples:[`pull_job`,`pull_job_batch`,`ack_job`,`fail_job`,`job_heartbeat`]},{name:`Queues`,count:11,examples:[`list_queues`,`pause_queue`,`resume_queue`,`drain_queue`,`obliterate_queue`]},{name:`Dead letter queue`,count:4,examples:[`get_dlq`,`retry_dlq`,`purge_dlq`]},{name:`Cron`,count:4,examples:[`add_cron`,`list_crons`,`get_cron`,`delete_cron`]},{name:`Flows`,count:4,examples:[`add_flow`,`add_flow_chain`,`get_flow`,`get_children_values`]},{name:`Rate limits`,count:4,examples:[`set_rate_limit`,`set_concurrency`,`clear_rate_limit`]},{name:`Webhooks`,count:4,examples:[`add_webhook`,`list_webhooks`,`remove_webhook`,`set_webhook_enabled`]},{name:`Workers`,count:3,examples:[`register_worker`,`list_workers`,`worker_heartbeat`]},{name:`Handlers`,count:3,examples:[`register_handler`,`list_handlers`,`unregister_handler`]},{name:`Monitoring`,count:11,examples:[`get_stats`,`get_queue_stats`,`get_memory_stats`,`get_prometheus_metrics`]}],d=[`bunqueue://queues`,`bunqueue://stats`,`bunqueue://workers`,`bunqueue://crons`,`bunqueue://webhooks`],f=[`bunqueue_debug_queue`,`bunqueue_health_report`,`bunqueue_incident_response`],p=u.reduce((e,t)=>e+t.count,0);function m({code:e}){return(0,o.jsxs)(`div`,{className:`relative min-w-0 max-w-full`,children:[(0,o.jsx)(`div`,{className:`absolute right-2 top-2`,children:(0,o.jsx)(i,{value:e})}),(0,o.jsx)(`pre`,{className:`max-w-full overflow-x-auto overscroll-x-contain rounded-lg border border-line bg-surface-2 p-4 pr-12 font-mono text-xs leading-relaxed text-fg`,children:e})]})}function h({children:e}){return(0,o.jsx)(`span`,{className:`max-w-full break-all rounded-md border border-line bg-surface-2 px-1.5 py-0.5 font-mono text-[11px] text-muted`,children:e})}function g(){return(0,o.jsxs)(`div`,{className:`min-w-0 overflow-x-hidden`,children:[(0,o.jsx)(r,{title:`MCP Server`,description:`Connect bunqueue to AI agents (Claude Desktop, Claude Code) over the Model Context Protocol.`,actions:(0,o.jsx)(`a`,{href:`https://egeominotti.github.io/bunqueue-dashboard/docs/guide/mcp`,target:`_blank`,rel:`noopener noreferrer`,className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Docs`})}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted`,children:[`bunqueue ships a Model Context Protocol server,`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`bunqueue-mcp`}),`, that lets an AI agent drive the queue with tools, resources, and prompts. It is a separate`,` `,(0,o.jsx)(`span`,{className:`text-fg`,children:`stdio`}),` process, launched by the MCP client (not by this dashboard, and not part of the HTTP API), so this page is a setup and reference guide rather than a live monitor. It needs the optional peer dependency`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`@modelcontextprotocol/sdk`}),`.`]}),(0,o.jsx)(`p`,{className:`mt-3 text-sm leading-relaxed text-warning`,children:`The upstream MCP includes destructive Cancel, Discard, Drain, Obliterate, DLQ Retry and DLQ Purge tools. They bypass this dashboard's v2.9.2 flow-safety gates and have no atomic reverse-dependency or job-generation precondition. Grant MCP write access only after independently proving the workload is not flow-linked.`})]}),(0,o.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,o.jsx)(a,{label:`Tools`,value:String(p)}),(0,o.jsx)(a,{label:`Categories`,value:String(u.length)}),(0,o.jsx)(a,{label:`Resources`,value:String(d.length)}),(0,o.jsx)(a,{label:`Prompts`,value:String(f.length)})]}),(0,o.jsxs)(`div`,{className:`mb-6 grid gap-4 lg:grid-cols-2`,children:[(0,o.jsxs)(n,{className:`min-w-0`,children:[(0,o.jsx)(t,{title:`Embedded mode (default)`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Direct SQLite access, no running server. Point `,(0,o.jsx)(h,{children:`DATA_PATH`}),` at the bunqueue database file. Best for a local agent on the same machine.`]}),(0,o.jsx)(m,{code:s})]}),(0,o.jsxs)(n,{className:`min-w-0`,children:[(0,o.jsx)(t,{title:`TCP mode (remote server)`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Connect to a running bunqueue server over its TCP protocol port (`,(0,o.jsx)(h,{children:`6789`}),`, distinct from the HTTP admin API on 6790). Use a `,(0,o.jsx)(h,{children:`BUNQUEUE_TOKEN`}),` if the server has one.`]}),(0,o.jsx)(m,{code:c})]})]}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsx)(t,{title:`Where to put it`}),(0,o.jsxs)(`p`,{className:`mb-3 text-sm text-muted`,children:[`Add the JSON above to your MCP client config (for Claude Desktop, its`,` `,(0,o.jsx)(`span`,{className:`font-mono text-fg`,children:`claude_desktop_config.json`}),`). For Claude Code, register it from the CLI:`]}),(0,o.jsx)(m,{code:l})]}),(0,o.jsxs)(n,{className:`mb-6`,children:[(0,o.jsx)(t,{title:`Tools`,action:(0,o.jsxs)(`span`,{className:`text-xs text-faint`,children:[p,` total`]})}),(0,o.jsx)(`div`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 lg:grid-cols-3`,children:u.map(e=>(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between gap-2`,children:[(0,o.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:e.count})]}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.examples.map(e=>(0,o.jsx)(h,{children:e},e))})]},e.name))}),(0,o.jsxs)(`p`,{className:`mt-4 text-xs text-faint`,children:[`Every tool name is prefixed `,(0,o.jsx)(`span`,{className:`font-mono`,children:`bunqueue_`}),` (examples above drop it). Counts total `,p,`.`]})]}),(0,o.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,o.jsxs)(n,{children:[(0,o.jsx)(t,{title:`Resources`,action:(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:d.length})}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:d.map(e=>(0,o.jsx)(h,{children:e},e))})]}),(0,o.jsxs)(n,{children:[(0,o.jsx)(t,{title:`Prompts`,action:(0,o.jsx)(`span`,{className:`text-xs text-faint`,children:f.length})}),(0,o.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.map(e=>(0,o.jsx)(h,{children:e},e))})]})]})]})}export{g as McpServer};
@@ -1 +1 @@
1
- import{t as e}from"./react-vendor-CvwrP0tU.js";import{t}from"./api-81m1TwB7.js";import{n}from"./usePolledData-CNtNtd0a.js";import{n as r,t as i}from"./Card-CWxrC8OY.js";import{i as a,n as o,r as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./PageHeader-CvIyaFOO.js";import{n as l,s as u}from"./format-Cg7VCIZW.js";import{n as d}from"./index-TploGF7u.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-CvwrP0tU.js";import{t}from"./api-BxYPEynh.js";import{n}from"./usePolledData-CNtNtd0a.js";import{n as r,t as i}from"./Card-CWxrC8OY.js";import{i as a,n as o,r as s}from"./feedback-QDN1AsYt.js";import{t as c}from"./PageHeader-CvIyaFOO.js";import{n as l,s as u}from"./format-Cg7VCIZW.js";import{n as d}from"./index-AUHH2nTG.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{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CvwrP0tU.js";import{t as i}from"./bq-BOfwNIlJ.js";import{n as a}from"./usePolledData-CNtNtd0a.js";import{n as o,t as s}from"./Card-CWxrC8OY.js";import{i as c,r as l,t as u}from"./feedback-QDN1AsYt.js";import{t as d}from"./PageHeader-CvIyaFOO.js";import{c as f,r as p,s as m,t as h,u as g}from"./format-Cg7VCIZW.js";import{n as _}from"./index-TploGF7u.js";import{t as v}from"./Pagination-x-Cwgrul.js";import{t as y}from"./AreaChart-DEAalJ6P.js";import{n as b,t as x}from"./useThroughputSeries-_J7gWbcI.js";var S=e(n(),1),C=r();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:n,danger:r,success:i}){return(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,r?`text-danger`:i?`text-success`:`text-fg`),children:e}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:n})]})}function E({color:e,label:n,value:r}){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:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}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(n=>{let r=e?.percentiles?.[n],i=e?.averages?.[`${n}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:n}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(i)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p95)}),(0,C.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(r?.p99??0)>O?`text-warning`:`text-muted`),children:j(r?.p99)})]},n)})})]})})]})}function A({rows:e,total:n,page:r,pageSize:i,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:t(`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:r,pageSize:i,total:n,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 n=e.latest?.throughput,r=x(e.depth),i=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)`})]}),n&&(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:n.pushPerSec}),(0,C.jsx)(P,{color:`#34d399`,label:`Completed`,value:n.completePerSec}),(0,C.jsx)(P,{color:`#f87171`,label:`Failed`,value:n.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:i==null?`—`:m(i)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,r.label===`draining`?`text-success`:r.label===`accumulating`?`text-danger`:`text-faint`),children:i==null?`unavailable`:r.label===`steady`?`steady`:`${r.slope>0?`+`:``}${r.slope.toFixed(1)}/s · ${r.label}`})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:r.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;function I(){let e=b(60),[t,n]=(0,S.useState)(0),{data:r,error:o,loading:s,refetch:l}=a(async()=>({details:await i.queuesSummary()}),[]),u=r?.details??[],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)(()=>r?u.reduce((e,t)=>e+(t.counts?.failed??0),0):null,[r,u]),x=e.latest?.stats,T=e.latest?.throughput,E=e.latest?.latency,D=x&&y!=null?h(x.completed,y):null,O=s&&!r&&!o,j=!!e.latest&&!e.error&&!!r&&!o,M=o&&!r?`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{I as MetricsPro};
1
+ import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CvwrP0tU.js";import{t as i}from"./bq-C7wdABtE.js";import{n as a}from"./usePolledData-CNtNtd0a.js";import{n as o,t as s}from"./Card-CWxrC8OY.js";import{i as c,r as l,t as u}from"./feedback-QDN1AsYt.js";import{t as d}from"./PageHeader-CvIyaFOO.js";import{c as f,r as p,s as m,t as h,u as g}from"./format-Cg7VCIZW.js";import{n as _}from"./index-AUHH2nTG.js";import{t as v}from"./Pagination-x-Cwgrul.js";import{t as y}from"./AreaChart-DEAalJ6P.js";import{n as b,t as x}from"./useThroughputSeries-y7Yyi7Zh.js";var S=e(n(),1),C=r();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:n,danger:r,success:i}){return(0,C.jsxs)(`div`,{className:`text-center`,children:[(0,C.jsx)(`div`,{className:t(`text-3xl font-bold tnum`,r?`text-danger`:i?`text-success`:`text-fg`),children:e}),(0,C.jsx)(`div`,{className:`text-xs text-faint`,children:n})]})}function E({color:e,label:n,value:r}){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:t(`size-2 rounded-full`,e)}),n]}),(0,C.jsx)(`dd`,{className:`font-semibold tnum text-fg`,children:r})]})}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(n=>{let r=e?.percentiles?.[n],i=e?.averages?.[`${n}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:n}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(i)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p50)}),(0,C.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:j(r?.p95)}),(0,C.jsx)(`td`,{className:t(`px-5 py-3 text-right tnum`,(r?.p99??0)>O?`text-warning`:`text-muted`),children:j(r?.p99)})]},n)})})]})})]})}function A({rows:e,total:n,page:r,pageSize:i,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:t(`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:r,pageSize:i,total:n,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 n=e.latest?.throughput,r=x(e.depth),i=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)`})]}),n&&(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:n.pushPerSec}),(0,C.jsx)(P,{color:`#34d399`,label:`Completed`,value:n.completePerSec}),(0,C.jsx)(P,{color:`#f87171`,label:`Failed`,value:n.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:i==null?`—`:m(i)}),(0,C.jsx)(`div`,{className:t(`text-xs font-medium`,r.label===`draining`?`text-success`:r.label===`accumulating`?`text-danger`:`text-faint`),children:i==null?`unavailable`:r.label===`steady`?`steady`:`${r.slope>0?`+`:``}${r.slope.toFixed(1)}/s · ${r.label}`})]})]}),e.latest?(0,C.jsx)(y,{xLabels:M,ariaLabel:`queue depth chart`,series:[{label:`Depth`,color:r.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;function I(){let e=b(60),[t,n]=(0,S.useState)(0),{data:r,error:o,loading:s,refetch:l}=a(async()=>({details:await i.queuesSummary()}),[]),u=r?.details??[],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)(()=>r?u.reduce((e,t)=>e+(t.counts?.failed??0),0):null,[r,u]),x=e.latest?.stats,T=e.latest?.throughput,E=e.latest?.latency,D=x&&y!=null?h(x.completed,y):null,O=s&&!r&&!o,j=!!e.latest&&!e.error&&!!r&&!o,M=o&&!r?`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{I as MetricsPro};
@@ -1 +1 @@
1
- import{t as e}from"./react-vendor-CvwrP0tU.js";import{A as t,c as n}from"./icons-BVzwsfbG.js";import{t as r}from"./api-81m1TwB7.js";import{n as i}from"./usePolledData-CNtNtd0a.js";import{n as a,t as o}from"./Card-CWxrC8OY.js";import{i as s,n as c,r as l}from"./feedback-QDN1AsYt.js";import{t as u}from"./PageHeader-CvIyaFOO.js";import{c as d,n as f,s as p,t as m,u as h}from"./format-Cg7VCIZW.js";import{n as g}from"./index-TploGF7u.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-CvwrP0tU.js";import{A as t,c as n}from"./icons-BVzwsfbG.js";import{t as r}from"./api-BxYPEynh.js";import{n as i}from"./usePolledData-CNtNtd0a.js";import{n as a,t as o}from"./Card-CWxrC8OY.js";import{i as s,n as c,r as l}from"./feedback-QDN1AsYt.js";import{t as u}from"./PageHeader-CvIyaFOO.js";import{c as d,n as f,s as p,t as m,u as h}from"./format-Cg7VCIZW.js";import{n as g}from"./index-AUHH2nTG.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{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{o as r}from"./connectionStore-CFuNYZ_8.js";import{t as i}from"./bq-BOfwNIlJ.js";import{t as a}from"./Button-Ch1W94fJ.js";import{n as o,t as s}from"./Card-CWxrC8OY.js";import{a as c,n as l,o as u,t as d}from"./form-C4oby9pI.js";import{n as f,r as p}from"./useServerActionGuard-Db7PPgaI.js";import{i as m,n as h,r as g}from"./flowMutationSafety-6cP-l4Pa.js";var _=n();function v(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e;return JSON.stringify(Object.keys(t).sort().map(e=>[e,t[e]]))}return JSON.stringify(e)}function y(e,t){let n=String(e).trim();if(n===``)return null;let r=Number(n);return Number.isSafeInteger(r)&&r>=t?r:null}function b(e){let t=y(e.stallInterval,0),n=y(e.maxStalls,0),r=y(e.gracePeriod,0);return t===null||n===null||r===null?{ok:!1,error:`Stall interval, max stalls, and grace period must be non-negative whole numbers.`}:{ok:!0,value:{enabled:e.enabled,stallInterval:t,maxStalls:n,gracePeriod:r}}}function x(e){let t=y(e.autoRetryInterval,0),n=y(e.maxAutoRetries,0);return t===null||n===null?{ok:!1,error:`Retry interval and max auto-retries must be non-negative whole numbers.`}:{ok:!0,value:{autoRetry:e.autoRetry,autoRetryInterval:t,maxAutoRetries:n}}}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var C=e=>typeof e==`number`&&Number.isFinite(e);function w(e){return S(e)&&typeof e.enabled==`boolean`&&C(e.stallInterval)&&C(e.maxStalls)&&C(e.gracePeriod)}function T(e){return S(e)&&typeof e.autoRetry==`boolean`&&C(e.autoRetryInterval)&&C(e.maxAutoRetries)&&(e.maxAge===null||C(e.maxAge))&&C(e.maxEntries)}function E(e,t){if(!S(e)||e.ok!==!0)throw Error(`Malformed ${t} response: expected { ok: true }.`)}var D=e(t(),1);function O(e){let[t,n]=(0,D.useState)(e),r=(0,D.useRef)(v(e));return(0,D.useEffect)(()=>{let t=v(e);t!==r.current&&(r.current=t,n(e))},[e]),[t,n,()=>{let e=r.current;return t=>{r.current===e&&(r.current=v(t))}}]}function k(e){let{scopeKey:t,begin:n}=p(e),i=(0,D.useRef)(null),a=(0,D.useRef)(null),[o,s]=(0,D.useState)(!1),[c,l]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null);let e=f(),t=r.subscribe(()=>{let t=f();t!==e&&(e=t,i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null))});return()=>{i.current=null,a.current!==null&&window.clearTimeout(a.current),t()}},[t]),{scopeKey:t,saving:o,saved:c,start:()=>{let e=n(`save`);return e?(i.current=e,s(!0),l(!1),e):null},finish:e=>{e.finish(),i.current===e&&(i.current=null,s(!1))},showSaved:e=>{i.current!==e||!e.isCurrent()||(l(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{e.isCurrent()&&l(!1),a.current=null},2e3))}}}function A({queue:e,config:t,onSaved:n}){let[r,c,f]=O(t),[p,h]=(0,D.useState)(null),g=k(`dlq-config:${e}`);(0,D.useEffect)(()=>h(null),[g.scopeKey]);let v=x(r),y=v.ok&&v.value.autoRetry;return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`DLQ policy`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,_.jsx)(u,{checked:r.autoRetry,disabled:!r.autoRetry,onChange:e=>c({...r,autoRetry:e}),label:`auto-retry`}),(0,_.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`auto-retry`})]}),(0,_.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:`Auto-retry can only be disabled. Bunqueue v2.9.0 cannot prove that a DLQ entry has no hidden reverse flow dependents before a background retry.`}),(0,_.jsx)(d,{label:`Retry interval (ms)`,children:(0,_.jsx)(l,{name:`dlq-auto-retry-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.autoRetryInterval,onChange:e=>c({...r,autoRetryInterval:e.target.value})})}),(0,_.jsx)(d,{label:`Max auto-retries`,children:(0,_.jsx)(l,{name:`dlq-max-auto-retries`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxAutoRetries,onChange:e=>c({...r,maxAutoRetries:e.target.value})})}),(0,_.jsx)(d,{label:`Max age (ms)`,children:(0,_.jsx)(l,{name:`dlq-max-age-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxAge??``,readOnly:!0})}),(0,_.jsx)(d,{label:`Max entries`,children:(0,_.jsx)(l,{name:`dlq-max-entries`,autoComplete:`off`,type:`number`,min:1,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxEntries,readOnly:!0})}),(0,_.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:m})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:g.saving||!v.ok||y,onClick:async()=>{if(!v.ok)return;let t=g.start();if(t)try{h(null);let a=f();if(E(await i.setDlqConfig(e,v.value),`/dlq-config`),!t.isCurrent())return;a({...r,...v.value}),await n(),g.showSaved(t)}catch(e){t.isCurrent()&&h(e.message)}finally{g.finish(t)}},children:`Save`}),g.saved&&(0,_.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!v.ok&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:v.error}),y&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:`Disable auto-retry before saving this policy.`}),p&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function j({queue:e,config:t,onSaved:n}){let[r,c,f]=O(t),[p,m]=(0,D.useState)(null),h=k(`stall-config:${e}`);(0,D.useEffect)(()=>m(null),[h.scopeKey]);let g=b(r);return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Stall detection`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,_.jsx)(u,{checked:r.enabled,onChange:e=>c({...r,enabled:e}),label:`enabled`}),(0,_.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`enabled`})]}),(0,_.jsx)(d,{label:`Stall interval (ms)`,children:(0,_.jsx)(l,{name:`stall-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.stallInterval,onChange:e=>c({...r,stallInterval:e.target.value})})}),(0,_.jsx)(d,{label:`Max stalls`,children:(0,_.jsx)(l,{name:`stall-max-count`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxStalls,onChange:e=>c({...r,maxStalls:e.target.value})})}),(0,_.jsx)(d,{label:`Grace period (ms)`,children:(0,_.jsx)(l,{name:`stall-grace-period-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.gracePeriod,onChange:e=>c({...r,gracePeriod:e.target.value})})})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:h.saving||!g.ok,onClick:async()=>{if(!g.ok)return;let t=h.start();if(t)try{m(null);let r=f();if(E(await i.setStallConfig(e,g.value),`/stall-config`),!t.isCurrent())return;r(g.value),await n(),h.showSaved(t)}catch(e){t.isCurrent()&&m(e.message)}finally{h.finish(t)}},children:`Save`}),h.saved&&(0,_.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!g.ok&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:g.error}),p&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function M({title:e,onRetry:t}){return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:e}),(0,_.jsx)(`p`,{className:`mb-3 text-sm text-muted`,children:`Couldn't load this queue's config.`}),(0,_.jsx)(a,{size:`sm`,onClick:t,children:`Retry`})]})}function N(e,t){let n=Number(e),r=Number(t);return{grace:n,limit:r,valid:e.trim()!==``&&t.trim()!==``&&Number.isSafeInteger(n)&&Number.isSafeInteger(r)&&n>=0&&r>0}}function P(e){if(!e.trim())return{valid:!0};let t=Number(e);return Number.isSafeInteger(t)&&t>0?{count:t,valid:!0}:{valid:!1}}function F(e,t){return t===void 0?`Promote every delayed job in "${e}" and make it eligible to run now?`:`Promote up to ${t} delayed jobs in "${e}" and make them eligible to run now?`}function I(e,t,n){let r=e=>{if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},i=r(e),a=r(t),o=r(n);return{limit:typeof i==`number`?i:0,duration:typeof a==`number`?a:0,...typeof o==`number`?{ttl:o}:{},valid:typeof i==`number`&&typeof a==`number`&&o!==null}}function L(e){let t=Number(e);return{value:t,valid:e.trim()!==``&&Number.isSafeInteger(t)&&t>0}}function R({queue:e,paused:t,busy:n,run:r}){let[u,f]=(0,D.useState)(`0`),[p,m]=(0,D.useState)(`1000`),[v,y]=(0,D.useState)(`completed`),[b,x]=(0,D.useState)(``),S=N(u,p),C=P(b);return(0,_.jsxs)(s,{className:`mb-6`,children:[(0,_.jsx)(o,{title:`Lifecycle`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[t?(0,_.jsx)(a,{variant:`success`,size:`sm`,disabled:n,onClick:()=>r(`Resumed`,()=>i.resume(e)),children:`Resume`}):(0,_.jsx)(a,{variant:`warning`,size:`sm`,disabled:n,onClick:()=>r(`Paused`,()=>i.pause(e)),children:`Pause`}),(0,_.jsx)(a,{size:`sm`,disabled:!0,title:h,children:`Requeue completed`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Promote N`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`promote-count`,"aria-invalid":!C.valid,value:b,onChange:e=>x(e.target.value),placeholder:`all`})})}),(0,_.jsx)(a,{size:`sm`,disabled:n||!C.valid,onClick:()=>r(`Promoted`,()=>i.promoteJobs(e,C.count),F(e,C.count)),children:`Promote delayed`}),!C.valid&&(0,_.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Promote N must be a positive whole number, or blank for all.`})]})]}),(0,_.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:h}),(0,_.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3`,children:[(0,_.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Destructive — these permanently remove jobs`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,_.jsx)(a,{size:`sm`,disabled:!0,title:g,children:`Drain`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`w-40`,children:(0,_.jsx)(d,{label:`State`,children:(0,_.jsxs)(c,{name:`clean-state`,disabled:!0,value:v,onChange:e=>y(e.target.value),children:[(0,_.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,_.jsx)(`option`,{value:`failed`,children:`Failed / DLQ`}),(0,_.jsx)(`option`,{value:`waiting`,children:`Queued`})]})})}),(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Grace (ms)`,children:(0,_.jsx)(l,{type:`number`,min:0,max:2**53-1,step:1,name:`clean-grace`,disabled:!0,"aria-invalid":!S.valid,value:u,onChange:e=>f(e.target.value)})})}),(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Limit`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`clean-limit`,disabled:!0,"aria-invalid":!S.valid,value:p,onChange:e=>m(e.target.value)})})}),(0,_.jsx)(a,{variant:`danger`,size:`sm`,disabled:!0,title:g,children:`Clean`}),!S.valid&&(0,_.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Grace and limit must be whole numbers; limit must be positive.`})]})]}),(0,_.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:g})]})]})}function z({queue:e,busy:t,run:n}){let[r,u]=(0,D.useState)(``),[f,p]=(0,D.useState)(``),[m,h]=(0,D.useState)(`permanent`),[g,v]=(0,D.useState)(``),[y,b]=(0,D.useState)(``),[x,S]=(0,D.useState)(``),[C,w]=(0,D.useState)(``),[T,E]=(0,D.useState)(null),[O,k]=(0,D.useState)(null),A=I(r,f,m===`expires`?g:``),j=L(y);return(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Rate-limit policy`}),(0,_.jsx)(`p`,{className:`mb-3 text-xs text-faint`,children:`Live SDK readback is available in Queue Control. Applying a policy replaces the broker value for this queue.`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,_.jsx)(d,{label:`Limit`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-limit`,value:r,onChange:e=>u(e.target.value),placeholder:`max per window`})})}),(0,_.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,_.jsx)(d,{label:`Window (ms)`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-duration`,value:f,onChange:e=>p(e.target.value),placeholder:`60000`})})}),(0,_.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,_.jsx)(d,{label:`TTL`,children:(0,_.jsxs)(c,{name:`rate-ttl-mode`,value:m,onChange:e=>h(e.target.value),children:[(0,_.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,_.jsx)(`option`,{value:`expires`,children:`Expires after`})]})})}),(0,_.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,_.jsx)(d,{label:`TTL (ms)`,hint:m===`permanent`?`Not sent`:void 0,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-ttl`,disabled:m===`permanent`,value:g,onChange:e=>v(e.target.value),placeholder:`—`})})}),(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:t||!A.valid,onClick:()=>n(`Rate limit set`,()=>i.setRateLimit(e,A.limit,A.duration,A.ttl),`Replace the current rate-limit policy for "${e}" with limit ${A.limit}, window ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`}?`,()=>E(`Applied limit ${A.limit} per ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`} at ${new Date().toISOString()}.`)),children:`Replace policy`}),(0,_.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,_.jsx)(d,{label:`Type ${e} to clear`,children:(0,_.jsx)(l,{name:`rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:x,onChange:e=>S(e.target.value)})})}),(0,_.jsx)(a,{size:`sm`,disabled:t||x!==e,onClick:()=>n(`No rate limit ensured`,()=>i.clearRateLimit(e),`Remove the current rate-limit policy from queue "${e}"?`,()=>E(`Removed the rate-limit policy at ${new Date().toISOString()}.`)),children:`Ensure no rate limit`}),!A.valid&&(r.trim()||f.trim()||g.trim())&&(0,_.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-danger`,children:`Limit and window are required; all values must be positive whole numbers.`}),T&&(0,_.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:T})]})]}),(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Concurrency policy`}),(0,_.jsx)(`p`,{className:`mb-3 text-xs text-faint`,children:`Live SDK readback is available in Queue Control. Applying a value replaces the broker concurrency for this queue.`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,_.jsx)(d,{label:`Concurrency`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`concurrency`,value:y,onChange:e=>b(e.target.value),placeholder:`max in-flight`})})}),(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:t||!j.valid,onClick:()=>n(`Concurrency set`,()=>i.setConcurrency(e,j.value),`Replace the current concurrency policy for "${e}" with ${j.value} maximum in-flight jobs?`,()=>k(`Applied concurrency ${j.value} at ${new Date().toISOString()}.`)),children:`Replace policy`}),(0,_.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,_.jsx)(d,{label:`Type ${e} to clear`,children:(0,_.jsx)(l,{name:`concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:C,onChange:e=>w(e.target.value)})})}),(0,_.jsx)(a,{size:`sm`,disabled:t||C!==e,onClick:()=>n(`No concurrency limit ensured`,()=>i.clearConcurrency(e),`Remove the current concurrency policy from queue "${e}"?`,()=>k(`Removed the concurrency policy at ${new Date().toISOString()}.`)),children:`Ensure no concurrency limit`}),!j.valid&&y.trim()&&(0,_.jsx)(`span`,{role:`alert`,className:`self-center text-xs text-danger`,children:`Concurrency must be a positive whole number.`}),O&&(0,_.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:O})]})]})]})}export{A as a,j as i,R as n,T as o,M as r,w as s,z as t};
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{o as r}from"./connectionStore-CFuNYZ_8.js";import{t as i}from"./bq-C7wdABtE.js";import{t as a}from"./Button-Ch1W94fJ.js";import{n as o,t as s}from"./Card-CWxrC8OY.js";import{a as c,n as l,o as u,t as d}from"./form-C4oby9pI.js";import{n as f,r as p}from"./useServerActionGuard-Db7PPgaI.js";import{i as m,n as h,r as g}from"./flowMutationSafety-DSd3JLAV.js";var _=n();function v(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e;return JSON.stringify(Object.keys(t).sort().map(e=>[e,t[e]]))}return JSON.stringify(e)}function y(e,t){let n=String(e).trim();if(n===``)return null;let r=Number(n);return Number.isSafeInteger(r)&&r>=t?r:null}function b(e){let t=y(e.stallInterval,0),n=y(e.maxStalls,0),r=y(e.gracePeriod,0);return t===null||n===null||r===null?{ok:!1,error:`Stall interval, max stalls, and grace period must be non-negative whole numbers.`}:{ok:!0,value:{enabled:e.enabled,stallInterval:t,maxStalls:n,gracePeriod:r}}}function x(e){let t=y(e.autoRetryInterval,0),n=y(e.maxAutoRetries,0);return t===null||n===null?{ok:!1,error:`Retry interval and max auto-retries must be non-negative whole numbers.`}:{ok:!0,value:{autoRetry:e.autoRetry,autoRetryInterval:t,maxAutoRetries:n}}}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var C=e=>typeof e==`number`&&Number.isFinite(e);function w(e){return S(e)&&typeof e.enabled==`boolean`&&C(e.stallInterval)&&C(e.maxStalls)&&C(e.gracePeriod)}function T(e){return S(e)&&typeof e.autoRetry==`boolean`&&C(e.autoRetryInterval)&&C(e.maxAutoRetries)&&(e.maxAge===null||C(e.maxAge))&&C(e.maxEntries)}function E(e,t){if(!S(e)||e.ok!==!0)throw Error(`Malformed ${t} response: expected { ok: true }.`)}var D=e(t(),1);function O(e){let[t,n]=(0,D.useState)(e),r=(0,D.useRef)(v(e));return(0,D.useEffect)(()=>{let t=v(e);t!==r.current&&(r.current=t,n(e))},[e]),[t,n,()=>{let e=r.current;return t=>{r.current===e&&(r.current=v(t))}}]}function k(e){let{scopeKey:t,begin:n}=p(e),i=(0,D.useRef)(null),a=(0,D.useRef)(null),[o,s]=(0,D.useState)(!1),[c,l]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null);let e=f(),t=r.subscribe(()=>{let t=f();t!==e&&(e=t,i.current=null,s(!1),l(!1),a.current!==null&&(window.clearTimeout(a.current),a.current=null))});return()=>{i.current=null,a.current!==null&&window.clearTimeout(a.current),t()}},[t]),{scopeKey:t,saving:o,saved:c,start:()=>{let e=n(`save`);return e?(i.current=e,s(!0),l(!1),e):null},finish:e=>{e.finish(),i.current===e&&(i.current=null,s(!1))},showSaved:e=>{i.current!==e||!e.isCurrent()||(l(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{e.isCurrent()&&l(!1),a.current=null},2e3))}}}function A({queue:e,config:t,onSaved:n}){let[r,c,f]=O(t),[p,h]=(0,D.useState)(null),g=k(`dlq-config:${e}`);(0,D.useEffect)(()=>h(null),[g.scopeKey]);let v=x(r),y=v.ok&&v.value.autoRetry;return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`DLQ policy`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,_.jsx)(u,{checked:r.autoRetry,disabled:!r.autoRetry,onChange:e=>c({...r,autoRetry:e}),label:`auto-retry`}),(0,_.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`auto-retry`})]}),(0,_.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:`Auto-retry can only be disabled. Bunqueue v2.9.2 cannot prove that a DLQ entry has no hidden reverse flow dependents before a background retry.`}),(0,_.jsx)(d,{label:`Retry interval (ms)`,children:(0,_.jsx)(l,{name:`dlq-auto-retry-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.autoRetryInterval,onChange:e=>c({...r,autoRetryInterval:e.target.value})})}),(0,_.jsx)(d,{label:`Max auto-retries`,children:(0,_.jsx)(l,{name:`dlq-max-auto-retries`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxAutoRetries,onChange:e=>c({...r,maxAutoRetries:e.target.value})})}),(0,_.jsx)(d,{label:`Max age (ms)`,children:(0,_.jsx)(l,{name:`dlq-max-age-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxAge??``,readOnly:!0})}),(0,_.jsx)(d,{label:`Max entries`,children:(0,_.jsx)(l,{name:`dlq-max-entries`,autoComplete:`off`,type:`number`,min:1,max:2**53-1,step:1,disabled:!0,title:m,value:r.maxEntries,readOnly:!0})}),(0,_.jsx)(`p`,{className:`col-span-2 text-xs text-warning`,children:m})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:g.saving||!v.ok||y,onClick:async()=>{if(!v.ok)return;let t=g.start();if(t)try{h(null);let a=f();if(E(await i.setDlqConfig(e,v.value),`/dlq-config`),!t.isCurrent())return;a({...r,...v.value}),await n(),g.showSaved(t)}catch(e){t.isCurrent()&&h(e.message)}finally{g.finish(t)}},children:`Save`}),g.saved&&(0,_.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!v.ok&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:v.error}),y&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:`Disable auto-retry before saving this policy.`}),p&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function j({queue:e,config:t,onSaved:n}){let[r,c,f]=O(t),[p,m]=(0,D.useState)(null),h=k(`stall-config:${e}`);(0,D.useEffect)(()=>m(null),[h.scopeKey]);let g=b(r);return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Stall detection`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`col-span-2 flex items-center gap-2`,children:[(0,_.jsx)(u,{checked:r.enabled,onChange:e=>c({...r,enabled:e}),label:`enabled`}),(0,_.jsx)(`span`,{className:`text-sm text-muted`,"aria-hidden":`true`,children:`enabled`})]}),(0,_.jsx)(d,{label:`Stall interval (ms)`,children:(0,_.jsx)(l,{name:`stall-interval-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.stallInterval,onChange:e=>c({...r,stallInterval:e.target.value})})}),(0,_.jsx)(d,{label:`Max stalls`,children:(0,_.jsx)(l,{name:`stall-max-count`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.maxStalls,onChange:e=>c({...r,maxStalls:e.target.value})})}),(0,_.jsx)(d,{label:`Grace period (ms)`,children:(0,_.jsx)(l,{name:`stall-grace-period-ms`,autoComplete:`off`,type:`number`,min:0,max:2**53-1,step:1,value:r.gracePeriod,onChange:e=>c({...r,gracePeriod:e.target.value})})})]}),(0,_.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:h.saving||!g.ok,onClick:async()=>{if(!g.ok)return;let t=h.start();if(t)try{m(null);let r=f();if(E(await i.setStallConfig(e,g.value),`/stall-config`),!t.isCurrent())return;r(g.value),await n(),h.showSaved(t)}catch(e){t.isCurrent()&&m(e.message)}finally{h.finish(t)}},children:`Save`}),h.saved&&(0,_.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved ✓`}),!g.ok&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:g.error}),p&&(0,_.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:p})]})]})}function M({title:e,onRetry:t}){return(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:e}),(0,_.jsx)(`p`,{className:`mb-3 text-sm text-muted`,children:`Couldn't load this queue's config.`}),(0,_.jsx)(a,{size:`sm`,onClick:t,children:`Retry`})]})}function N(e,t){let n=Number(e),r=Number(t);return{grace:n,limit:r,valid:e.trim()!==``&&t.trim()!==``&&Number.isSafeInteger(n)&&Number.isSafeInteger(r)&&n>=0&&r>0}}function P(e){if(!e.trim())return{valid:!0};let t=Number(e);return Number.isSafeInteger(t)&&t>0?{count:t,valid:!0}:{valid:!1}}function F(e,t){return t===void 0?`Promote every delayed job in "${e}" and make it eligible to run now?`:`Promote up to ${t} delayed jobs in "${e}" and make them eligible to run now?`}function I(e,t,n){let r=e=>{if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},i=r(e),a=r(t),o=r(n);return{limit:typeof i==`number`?i:0,duration:typeof a==`number`?a:0,...typeof o==`number`?{ttl:o}:{},valid:typeof i==`number`&&typeof a==`number`&&o!==null}}function L(e){let t=Number(e);return{value:t,valid:e.trim()!==``&&Number.isSafeInteger(t)&&t>0}}function R({queue:e,paused:t,busy:n,run:r}){let[u,f]=(0,D.useState)(`0`),[p,m]=(0,D.useState)(`1000`),[v,y]=(0,D.useState)(`completed`),[b,x]=(0,D.useState)(``),S=N(u,p),C=P(b);return(0,_.jsxs)(s,{className:`mb-6`,children:[(0,_.jsx)(o,{title:`Lifecycle`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[t?(0,_.jsx)(a,{variant:`success`,size:`sm`,disabled:n,onClick:()=>r(`Resumed`,()=>i.resume(e)),children:`Resume`}):(0,_.jsx)(a,{variant:`warning`,size:`sm`,disabled:n,onClick:()=>r(`Paused`,()=>i.pause(e)),children:`Pause`}),(0,_.jsx)(a,{size:`sm`,disabled:!0,title:h,children:`Requeue completed`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Promote N`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`promote-count`,"aria-invalid":!C.valid,value:b,onChange:e=>x(e.target.value),placeholder:`all`})})}),(0,_.jsx)(a,{size:`sm`,disabled:n||!C.valid,onClick:()=>r(`Promoted`,()=>i.promoteJobs(e,C.count),F(e,C.count)),children:`Promote delayed`}),!C.valid&&(0,_.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Promote N must be a positive whole number, or blank for all.`})]})]}),(0,_.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:h}),(0,_.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3`,children:[(0,_.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wider text-faint`,children:`Destructive — these permanently remove jobs`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,_.jsx)(a,{size:`sm`,disabled:!0,title:g,children:`Drain`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`w-40`,children:(0,_.jsx)(d,{label:`State`,children:(0,_.jsxs)(c,{name:`clean-state`,disabled:!0,value:v,onChange:e=>y(e.target.value),children:[(0,_.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,_.jsx)(`option`,{value:`failed`,children:`Failed / DLQ`}),(0,_.jsx)(`option`,{value:`waiting`,children:`Queued`})]})})}),(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Grace (ms)`,children:(0,_.jsx)(l,{type:`number`,min:0,max:2**53-1,step:1,name:`clean-grace`,disabled:!0,"aria-invalid":!S.valid,value:u,onChange:e=>f(e.target.value)})})}),(0,_.jsx)(`div`,{className:`w-24`,children:(0,_.jsx)(d,{label:`Limit`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`clean-limit`,disabled:!0,"aria-invalid":!S.valid,value:p,onChange:e=>m(e.target.value)})})}),(0,_.jsx)(a,{variant:`danger`,size:`sm`,disabled:!0,title:g,children:`Clean`}),!S.valid&&(0,_.jsx)(`span`,{role:`alert`,className:`pb-2 text-xs text-danger`,children:`Grace and limit must be whole numbers; limit must be positive.`})]})]}),(0,_.jsx)(`p`,{className:`mt-3 text-xs text-warning`,children:g})]})]})}function z({queue:e,busy:t,run:n}){let[r,u]=(0,D.useState)(``),[f,p]=(0,D.useState)(``),[m,h]=(0,D.useState)(`permanent`),[g,v]=(0,D.useState)(``),[y,b]=(0,D.useState)(``),[x,S]=(0,D.useState)(``),[C,w]=(0,D.useState)(``),[T,E]=(0,D.useState)(null),[O,k]=(0,D.useState)(null),A=I(r,f,m===`expires`?g:``),j=L(y);return(0,_.jsxs)(`div`,{className:`mb-6 grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Rate-limit policy`}),(0,_.jsx)(`p`,{className:`mb-3 text-xs text-faint`,children:`Live SDK readback is available in Queue Control. Applying a policy replaces the broker value for this queue.`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,_.jsx)(d,{label:`Limit`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-limit`,value:r,onChange:e=>u(e.target.value),placeholder:`max per window`})})}),(0,_.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,_.jsx)(d,{label:`Window (ms)`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-duration`,value:f,onChange:e=>p(e.target.value),placeholder:`60000`})})}),(0,_.jsx)(`div`,{className:`min-w-28 flex-1`,children:(0,_.jsx)(d,{label:`TTL`,children:(0,_.jsxs)(c,{name:`rate-ttl-mode`,value:m,onChange:e=>h(e.target.value),children:[(0,_.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,_.jsx)(`option`,{value:`expires`,children:`Expires after`})]})})}),(0,_.jsx)(`div`,{className:`min-w-24 flex-1`,children:(0,_.jsx)(d,{label:`TTL (ms)`,hint:m===`permanent`?`Not sent`:void 0,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`rate-ttl`,disabled:m===`permanent`,value:g,onChange:e=>v(e.target.value),placeholder:`—`})})}),(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:t||!A.valid,onClick:()=>n(`Rate limit set`,()=>i.setRateLimit(e,A.limit,A.duration,A.ttl),`Replace the current rate-limit policy for "${e}" with limit ${A.limit}, window ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`}?`,()=>E(`Applied limit ${A.limit} per ${A.duration}ms${A.ttl===void 0?`, permanent`:`, TTL ${A.ttl}ms`} at ${new Date().toISOString()}.`)),children:`Replace policy`}),(0,_.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,_.jsx)(d,{label:`Type ${e} to clear`,children:(0,_.jsx)(l,{name:`rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:x,onChange:e=>S(e.target.value)})})}),(0,_.jsx)(a,{size:`sm`,disabled:t||x!==e,onClick:()=>n(`No rate limit ensured`,()=>i.clearRateLimit(e),`Remove the current rate-limit policy from queue "${e}"?`,()=>E(`Removed the rate-limit policy at ${new Date().toISOString()}.`)),children:`Ensure no rate limit`}),!A.valid&&(r.trim()||f.trim()||g.trim())&&(0,_.jsx)(`span`,{role:`alert`,className:`w-full text-xs text-danger`,children:`Limit and window are required; all values must be positive whole numbers.`}),T&&(0,_.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:T})]})]}),(0,_.jsxs)(s,{children:[(0,_.jsx)(o,{title:`Concurrency policy`}),(0,_.jsx)(`p`,{className:`mb-3 text-xs text-faint`,children:`Live SDK readback is available in Queue Control. Applying a value replaces the broker concurrency for this queue.`}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,_.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,_.jsx)(d,{label:`Concurrency`,children:(0,_.jsx)(l,{type:`number`,min:1,max:2**53-1,step:1,name:`concurrency`,value:y,onChange:e=>b(e.target.value),placeholder:`max in-flight`})})}),(0,_.jsx)(a,{variant:`accent`,size:`sm`,disabled:t||!j.valid,onClick:()=>n(`Concurrency set`,()=>i.setConcurrency(e,j.value),`Replace the current concurrency policy for "${e}" with ${j.value} maximum in-flight jobs?`,()=>k(`Applied concurrency ${j.value} at ${new Date().toISOString()}.`)),children:`Replace policy`}),(0,_.jsx)(`div`,{className:`min-w-40 flex-1`,children:(0,_.jsx)(d,{label:`Type ${e} to clear`,children:(0,_.jsx)(l,{name:`concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:C,onChange:e=>w(e.target.value)})})}),(0,_.jsx)(a,{size:`sm`,disabled:t||C!==e,onClick:()=>n(`No concurrency limit ensured`,()=>i.clearConcurrency(e),`Remove the current concurrency policy from queue "${e}"?`,()=>k(`Removed the concurrency policy at ${new Date().toISOString()}.`)),children:`Ensure no concurrency limit`}),!j.valid&&y.trim()&&(0,_.jsx)(`span`,{role:`alert`,className:`self-center text-xs text-danger`,children:`Concurrency must be a positive whole number.`}),O&&(0,_.jsx)(`span`,{role:`status`,className:`w-full text-xs text-success`,children:O})]})]})]})}export{A as a,j as i,R as n,T as o,M as r,w as s,z as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{g as t,t as n}from"./react-vendor-CvwrP0tU.js";import{t as r}from"./bq-C7wdABtE.js";import{n as i}from"./usePolledData-CNtNtd0a.js";import{t as a}from"./Button-Ch1W94fJ.js";import{n as o,t as s}from"./Card-CWxrC8OY.js";import{i as c,n as l,r as u}from"./feedback-QDN1AsYt.js";import{n as d}from"./StatusBadge-BoOVTnKu.js";import{t as f}from"./PageHeader-CvIyaFOO.js";import{s as p}from"./format-Cg7VCIZW.js";import{n as m}from"./index-AUHH2nTG.js";import{a as h,n as g,t as _}from"./form-C4oby9pI.js";import{r as v}from"./useServerActionGuard-Db7PPgaI.js";import{a as y,i as b,n as x,o as S,r as C,s as w,t as ee}from"./QueueActions-b19K0vCT.js";var T=e(t(),1),E={limits:async(e,t)=>k(await r.queueOperations.limits(e,t)),group:async(e,t,n,i)=>D(await r.queueOperations.group(e,t,n,i)),setGroupRateLimit:async(e,t,n,i)=>{O(await r.queueOperations.setGroupRateLimit(e,t,n,i))},removeGroupRateLimit:async(e,t)=>j(await r.queueOperations.removeGroupRateLimit(e,t)),setGroupConcurrency:async(e,t,n)=>{O(await r.queueOperations.setGroupConcurrency(e,t,n))},removeGroupConcurrency:async(e,t)=>j(await r.queueOperations.removeGroupConcurrency(e,t)),deduplicationJobId:async(e,t)=>A(await r.queueOperations.deduplicationJobId(e,t)),removeDeduplicationKey:async(e,t)=>j(await r.queueOperations.removeDeduplicationKey(e,t)),metrics:async(e,t,n,i)=>M(await r.queueOperations.metrics(e,t,n,i)),trimEvents:async(e,t)=>j(await r.queueOperations.trimEvents(e,t))};function D(e){let t=P(N(e,`Queue group`).group,`Queue group`),n=t.rateLimit;if(!L(t.jobs,0)||!L(t.active,0)||!L(t.totalGrouped,0)||n!==null&&(!F(n)||!I(n.max)||!I(n.duration))||!L(t.rateLimitTtl,-2)||t.concurrency!==null&&!I(t.concurrency))throw R(`Queue group`);return t}function O(e){if(N(e,`Queue mutation`).applied!==!0)throw R(`Queue mutation`)}function k(e){let t=P(N(e,`Queue limits`).limits,`Queue limits`),n=t.rateLimit;if(n!==null&&(!F(n)||!I(n.max)||!I(n.duration))||t.concurrency!==null&&!I(t.concurrency)||!L(t.rateLimitTtl,-2)||typeof t.maxed!=`boolean`)throw R(`Queue limits`);return{rateLimit:n,concurrency:t.concurrency,rateLimitTtl:t.rateLimitTtl,maxed:t.maxed}}function A(e){let t=N(e,`deduplication lookup`).jobId;if(t!==null&&(typeof t!=`string`||!t))throw R(`deduplication lookup`);return t}function j(e){let t=N(e,`Queue mutation`).removed;if(!L(t,0))throw R(`Queue mutation`);return t}function M(e){let t=P(N(e,`Queue metrics`).metrics,`Queue metrics`),n=P(t.meta,`Queue metrics`);if(!L(n.count,0)||!L(n.prevTS,0)||!L(n.prevCount,0)||!L(t.count,0)||!Array.isArray(t.data)||t.data.length>10001||!t.data.every(e=>L(e,0)))throw R(`Queue metrics`);return t}function N(e,t){let n=P(e,t);if(n.ok!==!0)throw R(t);return n}function P(e,t){if(!F(e))throw R(t);return e}function F(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var I=e=>L(e,1),L=(e,t)=>Number.isSafeInteger(e)&&e>=t,R=e=>Error(`Malformed ${e} response`),z=n();function te({queue:e,repository:t,busy:n,run:r}){let[i,o]=(0,T.useState)(``),[s,c]=(0,T.useState)(),[l,u]=(0,T.useState)(``),d=i.length>0&&i.length<=1024;return(0,z.jsxs)(`section`,{"aria-labelledby":`queue-dedup-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,z.jsx)(`h3`,{id:`queue-dedup-title`,className:`text-sm font-semibold text-fg`,children:`Deduplication registry`}),(0,z.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,z.jsx)(_,{label:`Deduplication ID`,children:(0,z.jsx)(g,{name:`queue-sdk-deduplication-id`,autoComplete:`off`,spellCheck:!1,maxLength:1024,value:i,onChange:e=>{o(e.target.value),c(void 0),u(``)}})}),(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,z.jsx)(a,{size:`sm`,disabled:!d||!!n,onClick:()=>r(`Looking up deduplication key`,()=>t.deduplicationJobId(e,i),c),children:`Find owner`}),(0,z.jsx)(a,{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`})]}),s!==void 0&&(0,z.jsx)(`p`,{role:`status`,className:`mt-3 break-all text-xs text-muted`,children:s===null?`No active owner.`:`Current job: ${s}`}),l&&(0,z.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l})]})}function ne({queue:e,repository:t,busy:n,run:r}){let[i,o]=(0,T.useState)(`default`),[s,c]=(0,T.useState)(``),[l,u]=(0,T.useState)(`100`),[d,f]=(0,T.useState)(`100`),[p,m]=(0,T.useState)(`60000`),[h,v]=(0,T.useState)(`1`),[y,b]=(0,T.useState)(null),x=re(i);return(0,z.jsxs)(`section`,{className:`xl:col-span-2`,"aria-labelledby":`queue-groups-title`,children:[(0,z.jsx)(`h3`,{id:`queue-groups-title`,className:`mb-3 text-sm font-medium text-fg`,children:`Groups`}),(0,z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3 xl:grid-cols-6`,children:[(0,z.jsx)(_,{label:`Group ID`,children:(0,z.jsx)(g,{value:i,maxLength:256,onChange:e=>o(e.target.value)})}),(0,z.jsx)(_,{label:`TTL maxJobs`,hint:`Optional`,children:(0,z.jsx)(g,{type:`number`,min:0,value:s,onChange:e=>c(e.target.value)})}),(0,z.jsx)(_,{label:`Groups maxCount`,children:(0,z.jsx)(g,{type:`number`,min:1,value:l,onChange:e=>u(e.target.value)})}),(0,z.jsx)(_,{label:`Rate max`,children:(0,z.jsx)(g,{type:`number`,min:1,value:d,onChange:e=>f(e.target.value)})}),(0,z.jsx)(_,{label:`Duration (ms)`,children:(0,z.jsx)(g,{type:`number`,min:1,value:p,onChange:e=>m(e.target.value)})}),(0,z.jsx)(_,{label:`Concurrency`,children:(0,z.jsx)(g,{type:`number`,min:1,value:h,onChange:e=>v(e.target.value)})})]}),(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,z.jsx)(a,{size:`sm`,disabled:!!n||!x,onClick:()=>{let n=H(s,0),i=H(l,1);!x||n===null||i===null||r(`Reading group`,()=>t.group(e,x,n,i),b)},children:`Read group`}),(0,z.jsx)(a,{size:`sm`,disabled:!!n||!x,onClick:()=>{let n=V(d),i=V(p);!x||n===null||i===null||r(`Setting group rate limit`,async()=>(await t.setGroupRateLimit(e,x,n,i),t.group(e,x)),b,!0)},children:`Set rate limit`}),(0,z.jsx)(a,{size:`sm`,disabled:!!n||!x,onClick:()=>r(`Clearing group rate limit`,async()=>(await t.removeGroupRateLimit(e,x),t.group(e,x)),b,!0),children:`Clear rate limit`}),(0,z.jsx)(a,{size:`sm`,disabled:!!n||!x,onClick:()=>{let n=V(h);!x||n===null||r(`Setting group concurrency`,async()=>(await t.setGroupConcurrency(e,x,n),t.group(e,x)),b,!0)},children:`Set concurrency`}),(0,z.jsx)(a,{size:`sm`,disabled:!!n||!x,onClick:()=>r(`Clearing group concurrency`,async()=>(await t.removeGroupConcurrency(e,x),t.group(e,x)),b,!0),children:`Clear concurrency`})]}),!x&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:`Group ID must contain 1–256 characters and no NUL.`}),y&&(0,z.jsxs)(`dl`,{className:`mt-4 grid grid-cols-2 gap-3 rounded-lg border border-line p-3 text-xs sm:grid-cols-6`,children:[(0,z.jsx)(B,{label:`Jobs`,value:y.jobs}),(0,z.jsx)(B,{label:`Active`,value:y.active}),(0,z.jsx)(B,{label:`All grouped`,value:y.totalGrouped}),(0,z.jsx)(B,{label:`Rate`,value:y.rateLimit?`${y.rateLimit.max}/${y.rateLimit.duration}ms`:`None`}),(0,z.jsx)(B,{label:`TTL`,value:`${y.rateLimitTtl} ms`}),(0,z.jsx)(B,{label:`Concurrency`,value:y.concurrency??`None`})]})]})}function B({label:e,value:t}){return(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-faint`,children:e}),(0,z.jsx)(`dd`,{className:`mt-1 font-mono text-fg`,children:t})]})}var re=e=>e.length>=1&&e.length<=256&&!e.includes(`\0`)?e:null,V=e=>{let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null},H=(e,t)=>{if(!e.trim())return;let n=Number(e);return Number.isSafeInteger(n)&&n>=t?n:null};function ie({snapshot:e,loading:t,error:n}){if(t&&!e)return(0,z.jsx)(`p`,{className:`text-sm text-muted`,children:`Reading broker limit state...`});if(n&&!e)return(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n});if(!e)return null;let r=e.rateLimit;return(0,z.jsxs)(`div`,{children:[n&&(0,z.jsxs)(`p`,{role:`alert`,className:`mb-3 text-xs text-warning`,children:[`Refresh failed. Showing the last successful limit snapshot: `,n]}),(0,z.jsxs)(`dl`,{className:`grid gap-x-6 gap-y-4 sm:grid-cols-2 xl:grid-cols-4`,children:[(0,z.jsx)(U,{label:`Global rate limit`,value:r?`${r.max} / ${r.duration} ms`:`Not configured`}),(0,z.jsx)(U,{label:`Rate-limit TTL`,value:e.rateLimitTtl===-2?`No active limit`:`${e.rateLimitTtl} ms`}),(0,z.jsx)(U,{label:`Global concurrency`,value:e.concurrency===null?`Not configured`:String(e.concurrency)}),(0,z.jsx)(U,{label:`Capacity`,value:e.maxed?`Maxed`:`Available`})]})]})}function U({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`min-w-0 border-l-2 border-line pl-3`,children:[(0,z.jsx)(`dt`,{className:`text-[11px] font-medium text-faint`,children:e}),(0,z.jsx)(`dd`,{className:`mt-1 break-words font-mono text-sm text-fg`,children:t})]})}function ae({queue:e,repository:t,busy:n,run:r}){let[i,o]=(0,T.useState)(`completed`),[s,c]=(0,T.useState)(`0`),[l,u]=(0,T.useState)(`29`),[d,f]=(0,T.useState)(`1000`),[p,m]=(0,T.useState)(null),[v,y]=(0,T.useState)(``),b=se(s,l),x=W(d,0,1e6);return(0,z.jsxs)(`section`,{"aria-labelledby":`queue-telemetry-title`,className:`border-t border-line pt-4 xl:border-t-0`,children:[(0,z.jsx)(`h3`,{id:`queue-telemetry-title`,className:`text-sm font-semibold text-fg`,children:`Durable queue telemetry`}),(0,z.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,z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,z.jsx)(_,{label:`Metric`,children:(0,z.jsxs)(h,{name:`queue-sdk-metric-type`,value:i,onChange:e=>o(e.target.value),children:[(0,z.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,z.jsx)(`option`,{value:`failed`,children:`Failed`})]})}),(0,z.jsx)(_,{label:`Start bucket`,children:(0,z.jsx)(g,{name:`queue-sdk-metric-start`,type:`number`,min:0,max:1e4,value:s,onChange:e=>c(e.target.value)})}),(0,z.jsx)(_,{label:`End bucket`,hint:`Use -1 for all remaining buckets`,children:(0,z.jsx)(g,{name:`queue-sdk-metric-end`,type:`number`,min:-1,max:1e4,value:l,onChange:e=>u(e.target.value)})})]}),(0,z.jsx)(a,{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,z.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,z.jsx)(oe,{metrics:p}),(0,z.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-end gap-3 border-t border-line pt-4`,children:[(0,z.jsx)(`div`,{className:`min-w-48 flex-1`,children:(0,z.jsx)(_,{label:`Retain lifecycle events`,hint:`0 clears the queue journal`,children:(0,z.jsx)(g,{name:`queue-sdk-event-retention`,type:`number`,min:0,max:1e6,value:d,onChange:e=>f(e.target.value)})})}),(0,z.jsx)(a,{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`})]}),v&&(0,z.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:v})]})}function oe({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,z.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-2 p-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-1 font-mono text-xs text-muted`,children:[(0,z.jsxs)(`span`,{children:[`Total terminal: `,e.meta.count]}),(0,z.jsxs)(`span`,{children:[`Available buckets: `,e.count]}),(0,z.jsxs)(`span`,{children:[`Latest bucket: `,e.meta.prevCount]})]}),t.length?(0,z.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,z.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,z.jsx)(`p`,{className:`mt-3 text-xs text-faint`,children:`No buckets in this range.`}),e.data.length>t.length&&(0,z.jsx)(`p`,{className:`mt-2 text-[11px] text-faint`,children:`Showing the first 120 returned buckets.`})]})}function se(e,t){let n=W(e,0,1e4),r=W(t,-1,1e4);return n===null||r===null||r!==-1&&r<n?null:{start:n,end:r}}function W(e,t,n){let r=Number(e);return Number.isSafeInteger(r)&&r>=t&&r<=n?r:null}function ce({queue:e,refreshKey:t=0,repository:n=E,onApplied:r}){let[i,c]=(0,T.useState)(``),[l,u]=(0,T.useState)(null),[d,f]=(0,T.useState)(``),[p,m]=(0,T.useState)(``),h=(0,T.useRef)(!1),v=(0,T.useRef)(0),y=(0,T.useRef)(!0),b=l?.queue===e?l:{queue:e,snapshot:null,loading:!0,error:``};(0,T.useEffect)(()=>(y.current=!0,()=>{y.current=!1,v.current+=1}),[]);let x=(0,T.useCallback)(async()=>{let t=le(i);if(t===null){u(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=++v.current;u(t=>({queue:e,snapshot:t?.queue===e?t.snapshot:null,loading:!0,error:``}));try{let i=await n.limits(e,t);y.current&&r===v.current&&u({queue:e,snapshot:i,loading:!1,error:``})}catch(t){y.current&&r===v.current&&u({queue:e,snapshot:null,loading:!1,error:G(t)})}},[i,e,n]);(0,T.useEffect)(()=>void x(),[e,t]);let S=(e,t,n,i=!1)=>{h.current||(h.current=!0,f(e),m(``),t().then(e=>{y.current&&(n(e),i&&(r?.(),r||x()))}).catch(e=>{y.current&&m(G(e))}).finally(()=>{h.current=!1,y.current&&f(``)}))};return(0,z.jsxs)(s,{className:`mb-6`,children:[(0,z.jsx)(o,{title:`Queue SDK operations`,action:d?(0,z.jsxs)(`span`,{className:`font-mono text-xs text-accent`,children:[d,`...`]}):void 0}),(0,z.jsx)(`p`,{className:`mb-5 max-w-3xl text-xs leading-5 text-faint`,children:`Live Bunqueue 2.9.2 limit, group, deduplication, metric, and event-journal contracts. Requests are pinned to the server managed by this control agent.`}),(0,z.jsxs)(`div`,{className:`mb-5 flex flex-wrap items-end gap-3 border-b border-line pb-5`,children:[(0,z.jsx)(`div`,{className:`w-48`,children:(0,z.jsx)(_,{label:`TTL threshold (maxJobs)`,hint:`Optional token-consumption threshold`,children:(0,z.jsx)(g,{name:`queue-sdk-max-jobs`,type:`number`,min:0,max:1e6,step:1,value:i,onChange:e=>c(e.target.value),placeholder:`Not set`})})}),(0,z.jsx)(a,{size:`sm`,disabled:b.loading||!!d,onClick:x,children:`Refresh limits`})]}),(0,z.jsx)(ie,{snapshot:b.snapshot,loading:b.loading,error:b.error}),p&&(0,z.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:p}),(0,z.jsxs)(`div`,{className:`mt-6 grid gap-6 xl:grid-cols-[0.8fr_1.2fr]`,children:[(0,z.jsx)(ne,{queue:e,repository:n,busy:d,run:S},`${e}:groups`),(0,z.jsx)(te,{queue:e,repository:n,busy:d,run:S},`${e}:deduplication`),(0,z.jsx)(ae,{queue:e,repository:n,busy:d,run:S},`${e}:telemetry`)]})]})}function le(e){if(!e.trim())return;let t=Number(e);return Number.isSafeInteger(t)&&t>=0&&t<=1e6?t:null}var G=e=>e instanceof Error?e.message:String(e),K=[`waiting`,`prioritized`,`active`,`completed`,`failed`,`delayed`,`waiting-children`,`paused`],q=500,J=200,Y=q*J;function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ue(e){return X(e)&&K.every(t=>Z(e[t]))}function Q(e,t){if(!X(e)||e.ok!==!0||!Array.isArray(e.queues)||!Z(e.total)||!Z(e.limit)||e.limit<1||!Z(e.offset)||e.offset!==t||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp)||!e.queues.every(e=>X(e)&&typeof e.name==`string`&&e.name.length>0&&Z(e.waiting)&&Z(e.delayed)&&Z(e.active)&&Z(e.dlq)&&typeof e.paused==`boolean`))throw Error(`Malformed /dashboard/queues response.`)}async function $(){let e=await r.queues(q,0);Q(e,0);let t=e.total;if(t>Y)throw Error(`Queue discovery reported ${t} queues, above the safe dashboard limit of ${Y}.`);if(e.queues.length!==Math.min(q,t))throw Error(`Incomplete /dashboard/queues page at offset 0: expected ${Math.min(q,t)} queues, received ${e.queues.length}.`);let n=new Map,i=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)}};i(e);let a=e.queues.length,o=1;for(;a<t;){if(o>=J)throw Error(`Queue discovery exceeded the safe limit of ${J} pages.`);let e=await r.queues(q,a);if(Q(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(q,t-a);if(e.queues.length!==n)throw Error(`Incomplete /dashboard/queues page at offset ${a}: expected ${n} queues, received ${e.queues.length}.`);i(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:q,offset:0}}function de(e,t){if(!X(e)||e.ok!==!0||e.name!==t||typeof e.paused!=`boolean`||!ue(e.counts))throw Error(`Malformed queue detail response for "${t}".`)}function fe(e){if(!X(e)||e.ok!==!0||!w(e.config))throw Error(`Malformed /stall-config response.`);return e.config}function pe(e){if(!X(e)||e.ok!==!0||!S(e.config))throw Error(`Malformed /dlq-config response.`);return e.config}function me(e){if(!X(e)||e.ok!==!0)throw Error(`Malformed queue action response: expected { ok: true }.`);if(e.count!==void 0){if(!Z(e.count))throw Error(`Malformed queue action response: count must be a non-negative integer.`);return e.count}}function he(e,t){return t.some(t=>t.name===e)?e:t[0]?.name??``}function ge(){let[e,t]=(0,T.useState)(``),[n,a]=(0,T.useState)(!1),[o,s]=(0,T.useState)(0),[g,_]=(0,T.useState)(null),S=v(`queue-control:${e}`);(0,T.useEffect)(()=>{a(!1),_(null)},[S.scopeKey]);let{data:w,error:E,loading:D,refetch:O}=i($,[],{intervalMs:3e4});(0,T.useEffect)(()=>{w&&t(e=>he(e,w.queues))},[w]);let{data:k,error:A,loading:j,refetch:M}=i((0,T.useCallback)(async()=>{if(!e)return null;let[t,n,i]=await Promise.all([r.queueDetail(e,!1),r.getStallConfig(e).then(fe).catch(()=>null),r.getDlqConfig(e).then(pe).catch(()=>null)]);return de(t,e),{queue:e,detail:t,stall:n,dlq:i}},[e]),[e]),N=!w||w.queues.some(t=>t.name===e),P=k?.queue===e&&N?k:null,F=(t,n,i,o)=>{let c=e;if(!c||i&&!window.confirm(i))return;let l=S.begin(`queue-write`);l&&(a(!0),_(null),(async()=>{try{let e=await r.queuesSummary();if(!l.isCurrent())return;if(!e.some(e=>e.name===c))throw Error(`Queue "${c}" no longer exists`);let i=me(await n());if(!l.isCurrent())return;_({queue:c,ok:!0,text:`${t}${i==null?` ✓`:`: ${i}`}`}),o?.(),s(e=>e+1),await M()}catch(e){l.isCurrent()&&_({queue:c,ok:!1,text:e.message})}finally{l.finish()&&a(!1)}})())};return(0,z.jsxs)(`div`,{children:[(0,z.jsx)(f,{title:`Queue Control`,description:`Full per-queue operations and configuration.`,live:!!e&&!!P?.detail&&!!P.stall&&!!P.dlq&&!A&&!E}),(0,z.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-center gap-3`,children:[(0,z.jsx)(`div`,{className:`w-56`,children:(0,z.jsx)(h,{value:e,"aria-label":`Queue`,name:`queue-control-queue`,autoComplete:`off`,onChange:e=>t(e.target.value),children:(w?.queues??[]).map(e=>(0,z.jsx)(`option`,{value:e.name,children:e.name},e.name))})}),P?.detail&&(0,z.jsx)(d,{label:P.detail.paused?`Paused`:`Active`,tone:P.detail.paused?`amber`:`green`}),g?.queue===e&&(0,z.jsx)(`span`,{role:`status`,className:g.ok?`text-xs text-success`:`text-xs text-danger`,children:g.text})]}),E&&(0,z.jsx)(c,{onRetry:O,message:`Could not discover queues — ${E.message}. Retry to choose a queue.`}),A&&P&&(0,z.jsx)(c,{message:`Queue refresh failed — showing the last successful configuration.`,onRetry:M}),A&&!P?(0,z.jsx)(l,{error:A,onRetry:M}):D&&!w&&!e&&!E?(0,z.jsx)(u,{label:`Discovering queues…`}):j&&!P?(0,z.jsx)(u,{}):E&&!e?(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:`Queue discovery failed. Retry the request above before choosing a queue.`}):P?.detail?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`mb-6 grid grid-cols-2 gap-3 md:grid-cols-4 xl:grid-cols-8`,children:K.map(e=>(0,z.jsx)(m,{label:e,value:p(P.detail.counts[e]),compact:!0},e))}),(0,z.jsx)(x,{queue:e,paused:P.detail.paused,busy:n,run:F},`${e}:lifecycle`),(0,z.jsx)(ee,{queue:e,busy:n,run:F},`${e}:limits`),(0,z.jsx)(ce,{queue:e,refreshKey:o,onApplied:()=>s(e=>e+1)},`${e}:sdk-operations`),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[P.stall?(0,z.jsx)(b,{queue:e,config:P.stall,onSaved:async()=>{_({queue:e,ok:!0,text:`Stall config saved ✓`}),await M()}},`${e}:stall`):(0,z.jsx)(C,{title:`Stall detection`,onRetry:M}),P.dlq?(0,z.jsx)(y,{queue:e,config:P.dlq,onSaved:async()=>{_({queue:e,ok:!0,text:`DLQ config saved ✓`}),await M()}},`${e}:dlq`):(0,z.jsx)(C,{title:`DLQ policy`,onRetry:M})]})]}):!A&&(0,z.jsx)(`p`,{className:`text-sm text-faint`,children:w?.queues.length===0?`No queues are available.`:`Select a queue.`})]})}export{ge as QueueControl,$ as t};
@@ -1 +1 @@
1
- import{i as e}from"./cn-zFEt5SO8.js";import{d as t,g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{t as a}from"./bq-BOfwNIlJ.js";import{A as o,b as s,i as c,m as l,n as u,x as d}from"./icons-BVzwsfbG.js";import{t as f}from"./api-81m1TwB7.js";import{n as p}from"./usePolledData-CNtNtd0a.js";import{t as m}from"./Button-Ch1W94fJ.js";import{t as h}from"./Card-CWxrC8OY.js";import{i as g,r as _,t as v}from"./feedback-QDN1AsYt.js";import{n as y,t as b}from"./StatusBadge-BoOVTnKu.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{n as D}from"./index-TploGF7u.js";import{a as O,n as k,t as A}from"./form-C4oby9pI.js";import{r as j,t as M}from"./useServerActionGuard-Db7PPgaI.js";import{r as N}from"./flowMutationSafety-6cP-l4Pa.js";var P=e(n(),1),F=i();function I({queue:e}){return(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:`Bunqueue v2.9.0 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,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,F.jsx)(z,{queue:e}),(0,F.jsx)(B,{queue:e})]})]})}function L(e){if(!e.trim())return null;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null}function R(e,t){let[n,r]=(0,P.useState)(!1),[i,o]=(0,P.useState)(null),[s,c]=(0,P.useState)(null),l=j(`classic-queue-policy:${e}:${t}`);return(0,P.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 z({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),[o,s]=(0,P.useState)(`permanent`),[c,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(``),{busy:p,error:g,receipt:_,run:v}=R(e,`rate-limit`),y=L(t),b=L(r),x=o===`expires`?L(c):void 0,S=y!==null&&b!==null&&(o===`permanent`||x!=null);return(0,F.jsxs)(h,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate-limit desired state`}),(0,F.jsx)(l,{className:`size-4 text-faint`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,F.jsx)(A,{label:`Limit`,children:(0,F.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,F.jsx)(A,{label:`Window (ms)`,children:(0,F.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,F.jsx)(A,{label:`TTL`,children:(0,F.jsxs)(O,{name:`classic-rate-ttl-mode`,value:o,onChange:e=>s(e.target.value),children:[(0,F.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,F.jsx)(`option`,{value:`expires`,children:`Expires after`})]})}),(0,F.jsx)(A,{label:`TTL (ms)`,hint:o===`permanent`?`Not sent`:void 0,children:(0,F.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,F.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:(0,F.jsx)(m,{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,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:d,onChange:e=>f(e.target.value)})}),(0,F.jsx)(m,{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`})]}),_&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:_}),g&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:g})]})}function B({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),{busy:s,error:c,receipt:l,run:u}=R(e,`concurrency`),d=L(t);return(0,F.jsxs)(h,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency desired state`}),(0,F.jsx)(o,{className:`size-4 text-faint`})]}),(0,F.jsx)(A,{label:`Maximum in-flight jobs`,children:(0,F.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,F.jsx)(`div`,{className:`mt-4 flex items-center gap-2`,children:(0,F.jsx)(m,{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,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value)})}),(0,F.jsx)(m,{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,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l}),c&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c})]})}var V=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`,`paused`],H={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 U(){let{name:e=``}=t(),[n,i]=(0,P.useState)(null),[o,l]=(0,P.useState)(null),h=j(`classic-queue:${e}`);(0,P.useEffect)(()=>{i(null),l(null)},[h.scopeKey]);let{data:O,error:k,loading:A,refetch:L}=p((0,P.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([f.queueDetail(e,!1),f.jobsList(e,{states:V,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]),R=async(t,n,r)=>{if(r&&!window.confirm(r))return;let o=h.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 L()}catch(e){o.isCurrent()&&l(e.message)}finally{o.finish()&&i(null)}}};if(A&&!O&&!k)return(0,F.jsx)(_,{label:`Loading ${e}…`});if(k&&!O)return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(g,{onRetry:L})]});if(O?.exists===!1)return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(g,{onRetry:L}),(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(v,{title:`Queue not found`,hint:`No queue named "${e}" exists on the current Bunqueue server.`,action:(0,F.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 z=O?.exists===!0?O:H,{detail:B}=z,U=B.counts,W=E(U.completed??0,U.failed??0),G=[...z.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(g,{onRetry:L}),(0,F.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.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,F.jsx)(c,{className:`size-4`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,F.jsx)(y,{label:B.paused?`Paused`:`Active`,tone:B.paused?`amber`:`green`}),(0,F.jsx)(y,{label:k?`Stale`:`Live`,tone:k?`amber`:`green`})]})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[B.paused?(0,F.jsxs)(m,{variant:`success`,size:`sm`,disabled:n!=null,onClick:()=>R(`resume`,()=>f.resume(e)),children:[(0,F.jsx)(d,{className:`size-3.5`}),` Resume`]}):(0,F.jsxs)(m,{variant:`warning`,size:`sm`,disabled:n!=null,onClick:()=>R(`pause`,()=>f.pause(e)),children:[(0,F.jsx)(s,{className:`size-3.5`}),` Pause`]}),(0,F.jsx)(m,{size:`sm`,disabled:!0,title:N,children:`Drain`}),(0,F.jsx)(m,{variant:`danger`,size:`sm`,disabled:!0,title:N,children:`Obliterate`})]})]}),o&&(0,F.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,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:N}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,F.jsx)(D,{label:`Waiting`,value:T(U.waiting),tone:`amber`}),(0,F.jsx)(D,{label:`Active`,value:T(U.active),tone:`blue`}),(0,F.jsx)(D,{label:`Completed`,value:T(U.completed),tone:`green`}),(0,F.jsx)(D,{label:`Failed`,value:T(U.failed),tone:U.failed?`red`:`default`}),(0,F.jsx)(D,{label:`Delayed`,value:T(U.delayed),tone:`default`}),(0,F.jsx)(D,{label:`Error Rate`,value:W==null?`—`:S(W),tone:W==null?`default`:W>.05?`red`:`green`})]}),(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,F.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,F.jsx)(u,{className:`size-3.5`})]})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,F.jsxs)(`table`,{className:`w-full min-w-[44rem] text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,F.jsx)(`tbody`,{children:z.recentJobsError?(0,F.jsx)(`tr`,{children:(0,F.jsxs)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,z.recentJobsError,`. Retry the page.`]})}):G.length===0?(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):G.map(e=>(0,F.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,F.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,F.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,F.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unknown`}),(0,F.jsx)(`td`,{className:`px-5 py-3`,children:(0,F.jsx)(b,{status:String(e.state??e.status??`waiting`)})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:x(C(e.startedAt,e.completedAt))}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:w(e.createdAt)})]},e.id))})]})})]}),(0,F.jsx)(I,{queue:e})]})}export{U as QueueDetail};
1
+ import{i as e}from"./cn-zFEt5SO8.js";import{d as t,g as n,r,t as i}from"./react-vendor-CvwrP0tU.js";import{t as a}from"./bq-C7wdABtE.js";import{A as o,b as s,i as c,m as l,n as u,x as d}from"./icons-BVzwsfbG.js";import{t as f}from"./api-BxYPEynh.js";import{n as p}from"./usePolledData-CNtNtd0a.js";import{t as m}from"./Button-Ch1W94fJ.js";import{t as h}from"./Card-CWxrC8OY.js";import{i as g,r as _,t as v}from"./feedback-QDN1AsYt.js";import{n as y,t as b}from"./StatusBadge-BoOVTnKu.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{n as D}from"./index-AUHH2nTG.js";import{a as O,n as k,t as A}from"./form-C4oby9pI.js";import{r as j,t as M}from"./useServerActionGuard-Db7PPgaI.js";import{r as N}from"./flowMutationSafety-DSd3JLAV.js";var P=e(n(),1),F=i();function I({queue:e}){return(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsx)(`h2`,{className:`mb-3 text-lg font-semibold text-fg`,children:`Configuration`}),(0,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:`Bunqueue v2.9.2 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,F.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,F.jsx)(z,{queue:e}),(0,F.jsx)(B,{queue:e})]})]})}function L(e){if(!e.trim())return null;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:null}function R(e,t){let[n,r]=(0,P.useState)(!1),[i,o]=(0,P.useState)(null),[s,c]=(0,P.useState)(null),l=j(`classic-queue-policy:${e}:${t}`);return(0,P.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 z({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),[o,s]=(0,P.useState)(`permanent`),[c,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(``),{busy:p,error:g,receipt:_,run:v}=R(e,`rate-limit`),y=L(t),b=L(r),x=o===`expires`?L(c):void 0,S=y!==null&&b!==null&&(o===`permanent`||x!=null);return(0,F.jsxs)(h,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Rate-limit desired state`}),(0,F.jsx)(l,{className:`size-4 text-faint`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,F.jsx)(A,{label:`Limit`,children:(0,F.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,F.jsx)(A,{label:`Window (ms)`,children:(0,F.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,F.jsx)(A,{label:`TTL`,children:(0,F.jsxs)(O,{name:`classic-rate-ttl-mode`,value:o,onChange:e=>s(e.target.value),children:[(0,F.jsx)(`option`,{value:`permanent`,children:`Permanent`}),(0,F.jsx)(`option`,{value:`expires`,children:`Expires after`})]})}),(0,F.jsx)(A,{label:`TTL (ms)`,hint:o===`permanent`?`Not sent`:void 0,children:(0,F.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,F.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:(0,F.jsx)(m,{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,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-rate-clear-queue`,autoComplete:`off`,spellCheck:!1,value:d,onChange:e=>f(e.target.value)})}),(0,F.jsx)(m,{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`})]}),_&&(0,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:_}),g&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:g})]})}function B({queue:e}){let[t,n]=(0,P.useState)(``),[r,i]=(0,P.useState)(``),{busy:s,error:c,receipt:l,run:u}=R(e,`concurrency`),d=L(t);return(0,F.jsxs)(h,{children:[(0,F.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:`Concurrency desired state`}),(0,F.jsx)(o,{className:`size-4 text-faint`})]}),(0,F.jsx)(A,{label:`Maximum in-flight jobs`,children:(0,F.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,F.jsx)(`div`,{className:`mt-4 flex items-center gap-2`,children:(0,F.jsx)(m,{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,F.jsxs)(`div`,{className:`mt-4 border-t border-line pt-4`,children:[(0,F.jsx)(A,{label:`Type ${e} to clear`,children:(0,F.jsx)(k,{name:`classic-concurrency-clear-queue`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value)})}),(0,F.jsx)(m,{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,F.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:l}),c&&(0,F.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c})]})}var V=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`,`paused`],H={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 U(){let{name:e=``}=t(),[n,i]=(0,P.useState)(null),[o,l]=(0,P.useState)(null),h=j(`classic-queue:${e}`);(0,P.useEffect)(()=>{i(null),l(null)},[h.scopeKey]);let{data:O,error:k,loading:A,refetch:L}=p((0,P.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([f.queueDetail(e,!1),f.jobsList(e,{states:V,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]),R=async(t,n,r)=>{if(r&&!window.confirm(r))return;let o=h.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 L()}catch(e){o.isCurrent()&&l(e.message)}finally{o.finish()&&i(null)}}};if(A&&!O&&!k)return(0,F.jsx)(_,{label:`Loading ${e}…`});if(k&&!O)return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(g,{onRetry:L})]});if(O?.exists===!1)return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(g,{onRetry:L}),(0,F.jsx)(`h1`,{className:`mb-4 font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsx)(v,{title:`Queue not found`,hint:`No queue named "${e}" exists on the current Bunqueue server.`,action:(0,F.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 z=O?.exists===!0?O:H,{detail:B}=z,U=B.counts,W=E(U.completed??0,U.failed??0),G=[...z.jobs].sort((e,t)=>(t.createdAt??0)-(e.createdAt??0));return(0,F.jsxs)(`div`,{children:[k&&(0,F.jsx)(g,{onRetry:L}),(0,F.jsxs)(`div`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.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,F.jsx)(c,{className:`size-4`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h1`,{className:`font-mono text-2xl font-bold tracking-tight text-fg`,children:e}),(0,F.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[(0,F.jsx)(y,{label:B.paused?`Paused`:`Active`,tone:B.paused?`amber`:`green`}),(0,F.jsx)(y,{label:k?`Stale`:`Live`,tone:k?`amber`:`green`})]})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[B.paused?(0,F.jsxs)(m,{variant:`success`,size:`sm`,disabled:n!=null,onClick:()=>R(`resume`,()=>f.resume(e)),children:[(0,F.jsx)(d,{className:`size-3.5`}),` Resume`]}):(0,F.jsxs)(m,{variant:`warning`,size:`sm`,disabled:n!=null,onClick:()=>R(`pause`,()=>f.pause(e)),children:[(0,F.jsx)(s,{className:`size-3.5`}),` Pause`]}),(0,F.jsx)(m,{size:`sm`,disabled:!0,title:N,children:`Drain`}),(0,F.jsx)(m,{variant:`danger`,size:`sm`,disabled:!0,title:N,children:`Obliterate`})]})]}),o&&(0,F.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,F.jsx)(`p`,{className:`mb-4 text-xs text-warning`,children:N}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,F.jsx)(D,{label:`Waiting`,value:T(U.waiting),tone:`amber`}),(0,F.jsx)(D,{label:`Active`,value:T(U.active),tone:`blue`}),(0,F.jsx)(D,{label:`Completed`,value:T(U.completed),tone:`green`}),(0,F.jsx)(D,{label:`Failed`,value:T(U.failed),tone:U.failed?`red`:`default`}),(0,F.jsx)(D,{label:`Delayed`,value:T(U.delayed),tone:`default`}),(0,F.jsx)(D,{label:`Error Rate`,value:W==null?`—`:S(W),tone:W==null?`default`:W>.05?`red`:`green`})]}),(0,F.jsxs)(`div`,{className:`mt-8`,children:[(0,F.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Recent Jobs`}),(0,F.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,F.jsx)(u,{className:`size-3.5`})]})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,F.jsxs)(`table`,{className:`w-full min-w-[44rem] text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`ID`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Name`}),(0,F.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Duration`}),(0,F.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Created`})]})}),(0,F.jsx)(`tbody`,{children:z.recentJobsError?(0,F.jsx)(`tr`,{children:(0,F.jsxs)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-danger`,children:[`Could not load recent jobs — `,z.recentJobsError,`. Retry the page.`]})}):G.length===0?(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:5,className:`px-5 py-12 text-center text-sm text-faint`,children:`No recent jobs.`})}):G.map(e=>(0,F.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,F.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs`,children:(0,F.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,F.jsx)(`td`,{className:`px-5 py-3 text-fg`,children:e.data?.name||`unknown`}),(0,F.jsx)(`td`,{className:`px-5 py-3`,children:(0,F.jsx)(b,{status:String(e.state??e.status??`waiting`)})}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:x(C(e.startedAt,e.completedAt))}),(0,F.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:w(e.createdAt)})]},e.id))})]})})]}),(0,F.jsx)(I,{queue:e})]})}export{U as QueueDetail};
@@ -1 +1 @@
1
- import{i as e,t}from"./cn-zFEt5SO8.js";import{d as n,g as r,r as i,t as a}from"./react-vendor-CvwrP0tU.js";import{t as o}from"./bq-BOfwNIlJ.js";import{t as s}from"./toastStore-B31o6Z5J.js";import{i as c,n as l}from"./icons-BVzwsfbG.js";import{n as u}from"./usePolledData-CNtNtd0a.js";import{t as d}from"./Button-Ch1W94fJ.js";import{n as f,t as p}from"./Card-CWxrC8OY.js";import{i as m,n as h,r as g,t as _}from"./feedback-QDN1AsYt.js";import{n as v}from"./StatusBadge-BoOVTnKu.js";import{t as y}from"./PageHeader-CvIyaFOO.js";import{a as b,c as x,s as S,t as C}from"./format-Cg7VCIZW.js";import{n as w}from"./index-TploGF7u.js";import{r as T,t as E}from"./useServerActionGuard-Db7PPgaI.js";import{r as D}from"./flowMutationSafety-6cP-l4Pa.js";import{t as O}from"./AreaChart-DEAalJ6P.js";import{n as k}from"./controlConnectionEpoch-DzbuWOhe.js";import{a as A,i as j,n as M,r as N,t as P}from"./QueueActions-D7cQrGvJ.js";import{t as F}from"./useThroughputSeries-_J7gWbcI.js";var I=e(r(),1),L=[`waiting`,`prioritized`,`active`,`waiting-children`,`delayed`,`completed`,`failed`,`paused`],R=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`],z=2e3,B=a();function V({name:e,jobs:t,error:n}){return(0,B.jsxs)(p,{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)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,B.jsx)(l,{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)(i,{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)(p,{className:`mb-6`,children:[(0,B.jsx)(f,{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:n,trend:r,rate:i}){return(0,B.jsxs)(p,{className:`mb-6`,children:[(0,B.jsx)(f,{title:`Backlog depth`,action:(0,B.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,r.draining?`bg-emerald-500/10 text-success`:r.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:r.label})}),n.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)(O,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:n,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 `,i==null?`—`:x(i)]})]})]})}function W(e,t){let n=`${k()}\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)}}function G(){let{name:e=``}=n(),[t,r]=(0,I.useState)(!1),[a,f]=(0,I.useState)(null),p=T(`queue:${e}`);(0,I.useEffect)(()=>{r(!1),f(null)},[p.scopeKey]);let{data:b,error:x,loading:O,refetch:k}=u((0,I.useCallback)(async()=>{if(!e)return null;if(!(await o.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([o.queueDetail(e,!1),o.getStallConfig(e).catch(()=>null),o.getDlqConfig(e).catch(()=>null),o.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,i,a)=>{if(i&&!window.confirm(i))return;let c=p.begin();if(c){r(!0),f(null);try{let r=await o.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}`}`;f({ok:!0,text:u}),s.success(u,e),a?.(),k()}catch(e){if(!c.isCurrent())return;let n=e.message;f({ok:!1,text:n}),s.error(`${t} failed`,n)}finally{c.finish()&&r(!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)(i,{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)(c,{className:`size-4`})}),actions:F?.exists===!0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(i,{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)(l,{className:`size-3.5`})]}),(0,B.jsxs)(i,{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)(l,{className:`size-3.5`})]}),(0,B.jsx)(d,{variant:`danger`,size:`sm`,disabled:!0,title:D,children:`Obliterate`})]}):void 0}),x&&F&&(0,B.jsx)(m,{message:`Queue refresh failed — showing the last successful snapshot.`,onRetry:k}),x&&!F?(0,B.jsx)(h,{error:x,onRetry:k}):O&&!F?(0,B.jsx)(g,{label:`Loading ${e}…`}):F?.exists===!1||!q||!J?!x&&(0,B.jsx)(_,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,B.jsx)(i,{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)(v,{label:q.paused?`Paused`:`Active`,tone:q.paused?`amber`:`green`}),a&&(0,B.jsx)(`span`,{role:`status`,className:a.ok?`text-xs text-success`:`text-xs text-danger`,children:a.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:t,run:K}),(0,B.jsx)(P,{queue:e,busy:t,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:()=>{f({ok:!0,text:`Stall config saved ✓`}),s.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:()=>{f({ok:!0,text:`DLQ config saved ✓`}),s.success(`DLQ config saved`,e)}},`${e}:dlq`):(0,B.jsx)(N,{title:`DLQ policy`,onRetry:k})]})]})]})}export{G as QueueDetailPro};
1
+ import{i as e,t}from"./cn-zFEt5SO8.js";import{d as n,g as r,r as i,t as a}from"./react-vendor-CvwrP0tU.js";import{t as o}from"./bq-C7wdABtE.js";import{t as s}from"./toastStore-B31o6Z5J.js";import{i as c,n as l}from"./icons-BVzwsfbG.js";import{n as u}from"./usePolledData-CNtNtd0a.js";import{t as d}from"./Button-Ch1W94fJ.js";import{n as f,t as p}from"./Card-CWxrC8OY.js";import{i as m,n as h,r as g,t as _}from"./feedback-QDN1AsYt.js";import{n as v}from"./StatusBadge-BoOVTnKu.js";import{t as y}from"./PageHeader-CvIyaFOO.js";import{a as b,c as x,s as S,t as C}from"./format-Cg7VCIZW.js";import{n as w}from"./index-AUHH2nTG.js";import{r as T,t as E}from"./useServerActionGuard-Db7PPgaI.js";import{r as D}from"./flowMutationSafety-DSd3JLAV.js";import{t as O}from"./AreaChart-DEAalJ6P.js";import{n as k}from"./controlConnectionEpoch-DzbuWOhe.js";import{a as A,i as j,n as M,r as N,t as P}from"./QueueActions-b19K0vCT.js";import{t as F}from"./useThroughputSeries-y7Yyi7Zh.js";var I=e(r(),1),L=[`waiting`,`prioritized`,`active`,`waiting-children`,`delayed`,`completed`,`failed`,`paused`],R=[`active`,`waiting`,`prioritized`,`waiting-children`,`completed`,`failed`,`delayed`],z=2e3,B=a();function V({name:e,jobs:t,error:n}){return(0,B.jsxs)(p,{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)(i,{to:`/jobs?queue=${encodeURIComponent(e)}`,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View all `,(0,B.jsx)(l,{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)(i,{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)(p,{className:`mb-6`,children:[(0,B.jsx)(f,{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:n,trend:r,rate:i}){return(0,B.jsxs)(p,{className:`mb-6`,children:[(0,B.jsx)(f,{title:`Backlog depth`,action:(0,B.jsx)(`span`,{className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,r.draining?`bg-emerald-500/10 text-success`:r.label===`accumulating`?`bg-red-500/10 text-danger`:`bg-surface-2 text-muted`),children:r.label})}),n.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)(O,{height:140,ariaLabel:`${e} backlog depth`,series:[{label:`depth`,color:`var(--accent)`,points:n,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 `,i==null?`—`:x(i)]})]})]})}function W(e,t){let n=`${k()}\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)}}function G(){let{name:e=``}=n(),[t,r]=(0,I.useState)(!1),[a,f]=(0,I.useState)(null),p=T(`queue:${e}`);(0,I.useEffect)(()=>{r(!1),f(null)},[p.scopeKey]);let{data:b,error:x,loading:O,refetch:k}=u((0,I.useCallback)(async()=>{if(!e)return null;if(!(await o.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([o.queueDetail(e,!1),o.getStallConfig(e).catch(()=>null),o.getDlqConfig(e).catch(()=>null),o.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,i,a)=>{if(i&&!window.confirm(i))return;let c=p.begin();if(c){r(!0),f(null);try{let r=await o.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}`}`;f({ok:!0,text:u}),s.success(u,e),a?.(),k()}catch(e){if(!c.isCurrent())return;let n=e.message;f({ok:!1,text:n}),s.error(`${t} failed`,n)}finally{c.finish()&&r(!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)(i,{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)(c,{className:`size-4`})}),actions:F?.exists===!0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(i,{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)(l,{className:`size-3.5`})]}),(0,B.jsxs)(i,{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)(l,{className:`size-3.5`})]}),(0,B.jsx)(d,{variant:`danger`,size:`sm`,disabled:!0,title:D,children:`Obliterate`})]}):void 0}),x&&F&&(0,B.jsx)(m,{message:`Queue refresh failed — showing the last successful snapshot.`,onRetry:k}),x&&!F?(0,B.jsx)(h,{error:x,onRetry:k}):O&&!F?(0,B.jsx)(g,{label:`Loading ${e}…`}):F?.exists===!1||!q||!J?!x&&(0,B.jsx)(_,{title:`Queue not found`,hint:`No queue named "${e}" exists — it may have been obliterated, or the link is stale.`,action:(0,B.jsx)(i,{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)(v,{label:q.paused?`Paused`:`Active`,tone:q.paused?`amber`:`green`}),a&&(0,B.jsx)(`span`,{role:`status`,className:a.ok?`text-xs text-success`:`text-xs text-danger`,children:a.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:t,run:K}),(0,B.jsx)(P,{queue:e,busy:t,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:()=>{f({ok:!0,text:`Stall config saved ✓`}),s.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:()=>{f({ok:!0,text:`DLQ config saved ✓`}),s.success(`DLQ config saved`,e)}},`${e}:dlq`):(0,B.jsx)(N,{title:`DLQ policy`,onRetry:k})]})]})]})}export{G as QueueDetailPro};