rigscope 0.1.2 → 0.1.4

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 (92) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +2 -2
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  5. package/.next/server/app/_global-error.html +1 -1
  6. package/.next/server/app/_global-error.rsc +1 -1
  7. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  10. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  11. package/.next/server/app/_not-found.html +1 -1
  12. package/.next/server/app/_not-found.rsc +2 -2
  13. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  14. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  15. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  16. package/.next/server/app/administration/page_client-reference-manifest.js +1 -1
  17. package/.next/server/app/administration.html +1 -1
  18. package/.next/server/app/administration.rsc +2 -2
  19. package/.next/server/app/administration.segments/_full.segment.rsc +2 -2
  20. package/.next/server/app/administration.segments/_tree.segment.rsc +1 -1
  21. package/.next/server/app/administration.segments/administration/__PAGE__.segment.rsc +2 -2
  22. package/.next/server/app/alerts/page_client-reference-manifest.js +1 -1
  23. package/.next/server/app/alerts.html +1 -1
  24. package/.next/server/app/alerts.rsc +2 -2
  25. package/.next/server/app/alerts.segments/_full.segment.rsc +2 -2
  26. package/.next/server/app/alerts.segments/_tree.segment.rsc +1 -1
  27. package/.next/server/app/alerts.segments/alerts/__PAGE__.segment.rsc +2 -2
  28. package/.next/server/app/connections/page_client-reference-manifest.js +1 -1
  29. package/.next/server/app/connections.html +1 -1
  30. package/.next/server/app/connections.rsc +2 -2
  31. package/.next/server/app/connections.segments/_full.segment.rsc +2 -2
  32. package/.next/server/app/connections.segments/_tree.segment.rsc +1 -1
  33. package/.next/server/app/connections.segments/connections/__PAGE__.segment.rsc +2 -2
  34. package/.next/server/app/history/page.js +1 -1
  35. package/.next/server/app/history/page_client-reference-manifest.js +1 -1
  36. package/.next/server/app/history.html +1 -1
  37. package/.next/server/app/history.rsc +4 -4
  38. package/.next/server/app/history.segments/_full.segment.rsc +4 -4
  39. package/.next/server/app/history.segments/_tree.segment.rsc +1 -1
  40. package/.next/server/app/history.segments/history/__PAGE__.segment.rsc +4 -4
  41. package/.next/server/app/index.html +1 -1
  42. package/.next/server/app/index.rsc +2 -2
  43. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  44. package/.next/server/app/index.segments/_full.segment.rsc +2 -2
  45. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  46. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  47. package/.next/server/app/login.html +1 -1
  48. package/.next/server/app/login.rsc +2 -2
  49. package/.next/server/app/login.segments/_full.segment.rsc +2 -2
  50. package/.next/server/app/login.segments/_tree.segment.rsc +1 -1
  51. package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  52. package/.next/server/app/machines/[machineId]/page.js +1 -1
  53. package/.next/server/app/machines/[machineId]/page_client-reference-manifest.js +1 -1
  54. package/.next/server/app/page_client-reference-manifest.js +1 -1
  55. package/.next/server/app/processes/page.js +1 -1
  56. package/.next/server/app/processes/page_client-reference-manifest.js +1 -1
  57. package/.next/server/app/processes.html +1 -1
  58. package/.next/server/app/processes.rsc +3 -3
  59. package/.next/server/app/processes.segments/_full.segment.rsc +3 -3
  60. package/.next/server/app/processes.segments/_tree.segment.rsc +1 -1
  61. package/.next/server/app/processes.segments/processes/__PAGE__.segment.rsc +3 -3
  62. package/.next/server/app-paths-manifest.json +2 -2
  63. package/.next/server/chunks/161.js +1 -1
  64. package/.next/server/chunks/168.js +1 -1
  65. package/.next/server/middleware-build-manifest.js +1 -1
  66. package/.next/server/pages/404.html +1 -1
  67. package/.next/server/pages/500.html +1 -1
  68. package/.next/static/chunks/408-29f55984738967db.js +1 -0
  69. package/.next/static/chunks/939-514e554087419c71.js +1 -0
  70. package/.next/static/chunks/app/history/{page-22be927a4c3a9c76.js → page-69ea64476ee5db85.js} +1 -1
  71. package/.next/static/chunks/app/machines/[machineId]/page-1a25a267563c18c0.js +1 -0
  72. package/.next/static/chunks/app/processes/{page-e471ed23a1d5632f.js → page-0e98a4a64e829c5f.js} +1 -1
  73. package/ARCHITECTURE.md +30 -4
  74. package/CHANGELOG.md +53 -2
  75. package/README.md +2 -0
  76. package/dist/cli.cjs +3575 -2555
  77. package/dist/collector.cjs +155 -232
  78. package/dist/hub.cjs +5 -18
  79. package/dist/ops.cjs +158 -31
  80. package/dist/system.cjs +869 -450
  81. package/docs/bottlenecks.md +4 -6
  82. package/docs/configuration.md +2 -0
  83. package/docs/installation.md +107 -23
  84. package/docs/operations.md +44 -22
  85. package/docs/releasing.md +21 -17
  86. package/docs/system-installation.md +11 -2
  87. package/package.json +1 -2
  88. package/.next/static/chunks/408-4fe7147e38981ee1.js +0 -1
  89. package/.next/static/chunks/939-2600d7c8e583d5ef.js +0 -1
  90. package/.next/static/chunks/app/machines/[machineId]/page-916ee73de5eb067d.js +0 -1
  91. /package/.next/static/{npHoP6NSY976Yaye-xi86 → -mNveXe-cHv8irQe97wI_}/_buildManifest.js +0 -0
  92. /package/.next/static/{npHoP6NSY976Yaye-xi86 → -mNveXe-cHv8irQe97wI_}/_ssgManifest.js +0 -0
@@ -1,3 +1,3 @@
1
1
  (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[952],{1:(e,t,r)=>{"use strict";r.d(t,{PE:()=>o,UR:()=>c,kg:()=>l,uW:()=>d});let s=/^[\u0009\u000a\u000d ]*[=+\-@]/,n=/^[\u0009\u000a\u000d]/;function a(e){if(null==e)return"";if("number"==typeof e)return Number.isFinite(e)?String(e):"";if("boolean"==typeof e)return e?"true":"false";let t=0===e.length?e:s.test(e)||n.test(e)?`'${e}`:e;return/[",\t\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function i(e){return e.map(a).join(",")}function l(e){return`${e.map(i).join("\r\n")}\r
2
- `}function o(e,t,r){if("u"<typeof document)return;let s=new Blob([t],{type:r}),n=URL.createObjectURL(s),a=document.createElement("a");a.href=n,a.download=e,a.rel="noopener",a.style.display="none",document.body.append(a),a.click(),a.remove(),globalThis.setTimeout(()=>URL.revokeObjectURL(n),0)}let c="text/csv;charset=utf-8",d="application/json;charset=utf-8"},438:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},2910:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]])},3381:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]])},4268:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},6582:(e,t,r)=>{"use strict";r.d(t,{E:()=>x,x:()=>g});var s=r(5155),n=r(8500),a=r.n(n),i=r(828),l=r(6914),o=r(7029),c=r(438),d=r(7422),u=r(1735),p=r(3440),h=r(9939);function m(e){return(0,s.jsxs)("button",{type:"button",onClick:e.onClick,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,s.jsx)(i.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.children]})}function f(e){return(0,s.jsx)(a(),{href:e.href,className:e.primary?"inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90":"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:e.children})}function g(){let{session:e,phase:t,retryConnection:r}=(0,h.M)();switch(e.kind){case"restoring":return(0,s.jsx)(p.Z,{title:"Checking session",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(p.p,{icon:l.A,note:"Checking your session…"})});case"restore-failed":return(0,s.jsxs)(p.Z,{title:"Hub unreachable",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:o.A,note:"The hub is unreachable right now."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(m,{onClick:r,children:"Check again"})})]});case"signed-out":if("expired"===t)return(0,s.jsxs)(p.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:c.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]});return(0,s.jsxs)(p.Z,{title:"Sign in required",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:l.A,note:"Sign in required."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]});case"auth-unavailable":return(0,s.jsx)(p.Z,{title:"Sign-in unavailable",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(p.p,{icon:d.A,note:"Browser sign-in is not configured on this hub."})})}return"expired"===t?(0,s.jsxs)(p.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:c.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]}):"no-permission"===t?(0,s.jsxs)(p.Z,{title:"No permission",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:d.A,note:`You are signed in as ${e.user.username}, but this hub grants no machine view to this account.`}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(m,{onClick:r,children:"Check again"})})]}):null}function x(){let{phase:e,retryConnection:t}=(0,h.M)();return"reconnecting"!==e&&"disconnected"!==e&&"connecting"!==e?null:"connecting"===e?(0,s.jsxs)("div",{role:"status",className:"mb-5 flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Connecting to the live feed — waiting for the first snapshot."]}):(0,s.jsxs)("div",{role:"status",className:"mb-5 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(u.A,{className:"h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,s.jsxs)("span",{children:["Connection lost — values below are ",(0,s.jsx)("strong",{className:"font-medium text-foreground",children:"last known"}),", not live measurements","reconnecting"===e?" — retrying with backoff…":" — retries stopped."]}),"disconnected"===e?(0,s.jsx)(m,{onClick:t,children:"Retry now"}):null]})}},7339:(e,t,r)=>{"use strict";r.d(t,{ProcessesView:()=>eX});var s=r(5155),n=r(8500),a=r.n(n),i=r(9926),l=r(3381),o=r(8731),c=r(4173),d=r(3440),u=r(940),p=r(802),h=r(6582),m=r(9939),f=r(8664),g=r(2115),x=r(828),b=r(7422),y=r(7029),w=r(2910),v=r(1735),j=r(9764),k=r(9664),M=r(4268),N=r(9942);let A=new Set(["bash","zsh","fish","sh","dash","ksh","mksh","tcsh","csh","ash","busybox"]),P=new Set(["sshd","sshd-session","dropbear","tmux","screen","systemd"]),S=["cpuPercent","memoryRssBytes","gpuMemoryBytes","ioReadBytesPerSec","ioWriteBytesPerSec"];function $(e,t,r){return e.slice().sort((e,s)=>W(D(e,t),D(s,t),r))}function R(e){return null!==e&&!!("init.scope"===e||/^session-.+\.scope$/.test(e)||/^user@.+\.service$/.test(e))}function C(e){return null===e||!e.endsWith(".scope")&&!e.endsWith(".service")||R(e)?null:e}function B(e){let t=e.replace(/\.(scope|service)$/,"");return t.startsWith("app-gnome-")?t=t.slice(10):t.startsWith("app-")&&(t=t.slice(4)),(t=t.replace(/-\d+$/,"")).length>0?t:e}function T(e){return{key:`tree:${e.pid}:${e.startTicks}`,label:e.name,kind:"tree",leader:e}}function U(e,t){switch(t){case"cpu":return e.cpuPercent;case"memory":return e.memoryRssBytes;case"gpuMemory":return e.gpuMemoryBytes;case"ioRead":return e.ioReadBytesPerSec;case"ioWrite":return e.ioWriteBytesPerSec;case"name":return e.label;case"count":return e.count;case"pid":var r=e.members;let s=null;for(let e of r)(null===s||e.pid<s)&&(s=e.pid);return s;case"user":return e.users.length>0?e.users[0]:null}}function D(e,t){switch(t){case"cpu":return e.cpuPercent;case"memory":return e.memoryRssBytes;case"gpuMemory":return e.gpuMemoryBytes;case"ioRead":return e.ioReadBytesPerSec;case"ioWrite":return e.ioWriteBytesPerSec;case"name":return e.name;case"count":return 1;case"pid":return e.pid;case"user":return e.user}}function W(e,t,r){let s,n=null==e,a=null==t;if(n&&a)return 0;if(n)return 1;if(a)return -1;if("number"==typeof e&&"number"==typeof t)s=e-t;else{let r=String(e).toLowerCase(),n=String(t).toLowerCase();s=r<n?-1:+(r>n)}return"asc"===r?s:-s}var I=r(592),L=r(7586);let q={key:"cpu",dir:"desc"};function K(e,t,r){return null!==e&&t-e>=(!Number.isFinite(r)||r<=0?1e4:Math.max(1e4,3*r))}let _=[{value:"applications",label:"Applications"},{value:"processes",label:"Processes"},{value:"tree",label:"Tree"}];function E(e){return`${e.pid}:${e.startTicks}`}function F(e){if(void 0===e.command)return e;let{command:t,...r}=e;return r}function z(e){return null!=e&&Number.isFinite(e)?Math.round(e).toString().replace(/\B(?=(\d{3})+(?!\d))/g,","):"—"}function O(e){switch(e){case"idle":return{label:"Not connected",tone:"muted",description:"Select a machine to request process detail.",retryable:!1};case"acquiring":return{label:"Connecting",tone:"warn",description:"Requesting process detail…",retryable:!1};case"loading":return{label:"Waiting",tone:"warn",description:"Waiting for the collector's first process snapshot…",retryable:!1};case"ready":return{label:"Live",tone:"ok",description:"Process detail is live.",retryable:!1};case"paused":return{label:"Paused",tone:"muted",description:"Process updates are paused.",retryable:!1};case"stale":return{label:"Not refreshing",tone:"warn",description:"The last snapshot is retained, but new snapshots are not arriving.",retryable:!0};case"disconnected":return{label:"Disconnected",tone:"crit",description:"The collector is disconnected; the last snapshot is not live.",retryable:!0};case"withheld":return{label:"Withheld",tone:"warn",description:"Process detail is withheld for this hub.",retryable:!0};case"unsupported":return{label:"Unsupported",tone:"warn",description:"This collector cannot provide process detail.",retryable:!0};case"busy":return{label:"Busy",tone:"warn",description:"Too many process views are open for this hub.",retryable:!0};case"expired":return{label:"Expired",tone:"warn",description:"Process detail expired before a fresh snapshot arrived.",retryable:!0};case"failed":return{label:"Scan failed",tone:"crit",description:"The process scan failed repeatedly.",retryable:!0};case"cancelled":return{label:"Stopped",tone:"muted",description:"The process detail view was stopped.",retryable:!0};case"error":return{label:"Unavailable",tone:"crit",description:"Process detail is unavailable right now.",retryable:!0}}}function V(e){return"number"==typeof e&&Number.isFinite(e)&&e>0}var Z=r(7348);class G{maxAgeMs;limit;session=null;entries=new Map;constructor(e=3e5,t=32){this.maxAgeMs=e,this.limit=t}scope(e){(this.session!==e||null===e)&&this.entries.clear(),this.session=e}get(e,t,r=Date.now()){this.scope(t);let s=this.entries.get(e);return s&&r-s.lastReceivedMs>=this.maxAgeMs?void this.entries.delete(e):s}set(e,t,r){this.scope(t),this.entries.delete(e),this.entries.set(e,r),this.entries.size>this.limit&&this.entries.delete(this.entries.keys().next().value)}delete(e,t){this.scope(t),this.entries.delete(e)}}let Y=new G;function X(e,t){let r=Y.get(e??"",t);return void 0!==r?{phase:"stale",message:"Resuming process updates…",...r}:{phase:null===e?"idle":"acquiring",detail:null,message:null,intervalMs:1e3,leaseMs:15e3,lastReceivedMs:null}}async function J(e){try{let t=await e.json();if(t&&"object"==typeof t&&"error"in t){let e=t.error;if("string"==typeof e&&e.length>0)return e}}catch{}return e.statusText||null}var H=r(8698);let Q=(0,H.A)("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),ee=(0,H.A)("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),et=(0,H.A)("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);var er=r(8528),es=r(6114);let en=[{id:"name",label:"Application",sortKey:"name",align:"left",width:300},{id:"count",label:"Procs",sortKey:"count",align:"right",width:76},{id:"cpu",label:"CPU / core",sortKey:"cpu",align:"right",width:104},{id:"memory",label:"RSS",sortKey:"memory",align:"right",width:96},{id:"gpuMemory",label:"VRAM",sortKey:"gpuMemory",align:"right",width:96},{id:"ioRead",label:"Read",sortKey:"ioRead",align:"right",width:104},{id:"ioWrite",label:"Write",sortKey:"ioWrite",align:"right",width:104},{id:"users",label:"Users",sortKey:"user",align:"left",width:160}],ea=[{id:"name",label:"Process",sortKey:"name",align:"left",width:300},{id:"pid",label:"PID",sortKey:"pid",align:"right",width:84},{id:"user",label:"User",sortKey:"user",align:"left",width:120},{id:"cpu",label:"CPU / core",sortKey:"cpu",align:"right",width:104},{id:"memory",label:"RSS",sortKey:"memory",align:"right",width:96},{id:"gpuMemory",label:"VRAM",sortKey:"gpuMemory",align:"right",width:96},{id:"ioRead",label:"Read",sortKey:"ioRead",align:"right",width:104},{id:"ioWrite",label:"Write",sortKey:"ioWrite",align:"right",width:104},{id:"threads",label:"Threads",align:"right",width:84}],ei=Object.freeze({}),el=Object.freeze([]),eo=new Set(["cpu","memory","gpuMemory","ioRead","ioWrite","name","count","pid","user"]);function ec(e){return Math.round(Math.min(1200,Math.max(56,e)))}function ed(e){return"applications"===e||"processes"===e||"tree"===e?e:null}function eu(e){if(null===e||"object"!=typeof e)return null;let{key:t,dir:r}=e;return"string"==typeof t&&eo.has(t)&&("asc"===r||"desc"===r)?{key:t,dir:r}:null}function ep(e){if(null===e||"object"!=typeof e||Array.isArray(e))return null;let t={};for(let[r,s]of Object.entries(e))"number"==typeof s&&Number.isFinite(s)&&(t[r]=ec(s));return t}function eh(e){return"string"==typeof e?e.slice(0,200):null}function em(e){return"boolean"==typeof e?e:null}function ef(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e)?e.slice(0,500):null}let eg="overflow-hidden text-ellipsis whitespace-nowrap border-b border-border px-2 py-2 align-middle",ex=`${eg} tnum text-right text-xs`,eb="relative overflow-hidden whitespace-nowrap border-b border-border px-2 py-2 text-left text-xs font-normal text-muted-foreground";function ey(e,t){return t[e.id]??e.width}function ew({label:e,width:t,onChange:r,onReset:n}){let a=(0,g.useRef)(null);return(0,s.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e} column`,"aria-valuenow":t,"aria-valuemin":56,"aria-valuemax":1200,tabIndex:0,title:"Drag to resize \xb7 double-click to reset",onPointerDown:e=>{0===e.button&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),a.current={x:e.clientX,width:t})},onPointerMove:e=>{null!==a.current&&r(ec(a.current.width+e.clientX-a.current.x))},onPointerUp:e=>{null!==a.current&&r(ec(a.current.width+e.clientX-a.current.x)),a.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:()=>{a.current=null},onLostPointerCapture:()=>{a.current=null},onClick:e=>e.stopPropagation(),onDoubleClick:e=>{e.stopPropagation(),n()},onKeyDown:e=>{"ArrowLeft"===e.key?(e.preventDefault(),r(ec(t-16))):"ArrowRight"===e.key&&(e.preventDefault(),r(ec(t+16)))},className:"group/handle absolute inset-y-0 right-0 z-10 flex w-2.5 cursor-col-resize touch-none select-none justify-end",children:(0,s.jsx)("span",{"aria-hidden":!0,className:"my-2 w-px bg-border transition-colors group-hover/handle:bg-accent group-focus-visible/handle:bg-accent"})})}function ev({column:e,sort:t,onSort:r,width:n,onResize:a,onReset:i}){let l="right"===e.align,o=e.sortKey,c=void 0!==o?t.key!==o?"none":"asc"===t.dir?"ascending":"descending":"none",d="none"!==c,u=d?"asc"===t.dir?ee:et:Q;return(0,s.jsxs)("th",{scope:"col","aria-sort":void 0!==o?c:void 0,className:l?`${eb} text-right`:eb,children:[void 0!==o?(0,s.jsxs)("button",{type:"button",onClick:()=>r(o),className:["inline-flex min-h-6 max-w-full items-center gap-1 rounded-sm transition-colors hover:text-foreground",l?"w-full justify-end pr-1":"",d?"text-foreground":""].filter(Boolean).join(" "),children:[(0,s.jsx)("span",{className:"truncate",children:e.label}),(0,s.jsx)(u,{className:d?"h-3 w-3 shrink-0":"h-3 w-3 shrink-0 opacity-40","aria-hidden":!0})]}):(0,s.jsx)("span",{className:l?"block truncate pr-1":"block truncate",children:e.label}),(0,s.jsx)(ew,{label:e.label,width:n,onChange:a,onReset:i})]})}function ej({table:e,columns:t,label:r,caption:n,sort:a,onSort:i,children:l}){let[o,c]=(0,es.u)(`processes.widths.${e}`,ei,ep),d=(0,g.useRef)(null),[u,p]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=d.current;if(!e)return;let t=new ResizeObserver(([e])=>p(e.contentRect.width));return t.observe(e),()=>t.disconnect()},[]);let h=e=>"name"===e.id?160:56,m=t.reduce((e,t)=>e+h(t),0),f=t.reduce((e,t)=>e+ey(t,o),0),x={},b=Math.max(u||f,m),y=[...t];for(;y.length>0;){let e=y.reduce((e,t)=>e+ey(t,o),0),t=y.filter(t=>b*ey(t,o)/e<h(t));if(0===t.length){for(let t of y)x[t.id]=b*ey(t,o)/e;break}for(let e of t)x[e.id]=h(e),b-=h(e);y=y.filter(e=>!t.includes(e))}return(0,s.jsx)("div",{ref:d,className:"relative min-h-0 w-full min-w-0 flex-1 overflow-auto overscroll-contain",tabIndex:0,role:"region","aria-label":r,children:(0,s.jsxs)("table",{className:"table-fixed border-separate border-spacing-0 text-left",style:{width:"100%",minWidth:m},children:[(0,s.jsx)("caption",{className:"sr-only",children:n}),(0,s.jsx)("colgroup",{children:t.map(e=>(0,s.jsx)("col",{style:{width:x[e.id]}},e.id))}),(0,s.jsx)("thead",{className:"sticky top-0 z-20 bg-card",children:(0,s.jsx)("tr",{children:t.map(e=>(0,s.jsx)(ev,{column:e,sort:a,onSort:i,width:x[e.id],onResize:r=>{let s,n,a;return s=t.indexOf(e),n=t[s+1]??t[s-1],a=Math.max(h(e)-x[e.id],Math.min(r-x[e.id],x[n.id]-h(n))),void c({...x,[e.id]:x[e.id]+a,[n.id]:x[n.id]-a})},onReset:()=>c(t=>{let{[e.id]:r,...s}=t;return s})},e.id))})}),(0,s.jsx)("tbody",{children:l})]})})}function ek({value:e,kind:t,partial:r=!1}){let n=function(e,t,r=!1){let s;if(null===e||!Number.isFinite(e)||e<0)return{text:"—",atLeast:!1,title:null};switch(t){case"percent":s=(0,L.l9)(e);break;case"bytes":s=(0,L.z3)(e);break;case"rate":s=`${(0,L.z3)(e)}/s`;break;case"count":s=z(e)}return{text:s,atLeast:r,title:r?`At least ${s}: some processes in this group did not report this metric.`:null}}(e,t,r);return(0,s.jsxs)("td",{className:"—"===n.text?`${ex} text-muted-foreground`:ex,title:n.title??void 0,children:[n.atLeast?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{"aria-hidden":!0,children:"≥ "}),(0,s.jsx)("span",{className:"sr-only",children:"at least "})]}):null,n.text]})}function eM(e){let t=e.name.length>0?e.name:"Unnamed process";return null!==e.unit?`${t} \xb7 ${e.unit}`:t}function eN({row:e,depth:t=0}){return(0,s.jsx)("th",{scope:"row",className:`${eg} text-left text-sm font-medium`,title:eM(e),children:(0,s.jsxs)("span",{style:t>0?{paddingLeft:`${14*t}px`}:void 0,children:[t>0?(0,s.jsx)("span",{className:"sr-only",children:`Nested level ${t+1}. `}):null,e.name.length>0?e.name:(0,s.jsx)("span",{className:"text-muted-foreground",children:"Unnamed process"})]})})}function eA({entries:e,sort:t,onSort:r,mode:n}){return(0,s.jsx)(ej,{table:"processes",columns:ea,label:"tree"===n?"Process tree":"Process list",caption:"tree"===n?"Process tree with nesting depth, PID, user, CPU per core, resident memory, GPU memory, read and write rates, and threads":"Processes with PID, user, CPU per core, resident memory, GPU memory, read and write rates, and threads",sort:t,onSort:r,children:e.map(({row:e,depth:t})=>(0,s.jsxs)("tr",{className:"transition-colors hover:bg-card-strong/60",children:[(0,s.jsx)(eN,{row:e,depth:t}),(0,s.jsx)("td",{className:ex,children:e.pid}),(0,s.jsx)("td",{className:`${eg} text-xs text-muted-foreground`,title:e.user??void 0,children:e.user??"—"}),(0,s.jsx)(ek,{value:e.cpuPercent,kind:"percent"}),(0,s.jsx)(ek,{value:e.memoryRssBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.gpuMemoryBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.ioReadBytesPerSec,kind:"rate"}),(0,s.jsx)(ek,{value:e.ioWriteBytesPerSec,kind:"rate"}),(0,s.jsx)("td",{className:ex,children:z(e.threads)})]},E(e)))})}function eP({group:e}){return(0,s.jsx)(s.Fragment,{children:e.members.map(e=>(0,s.jsxs)("tr",{className:"bg-card-strong/40 transition-colors hover:bg-card-strong/70",children:[(0,s.jsx)("th",{scope:"row",className:`${eg} text-left text-xs font-normal`,title:`${eM(e)} \xb7 PID ${e.pid}`,children:(0,s.jsxs)("span",{className:"pl-5",children:[e.name.length>0?e.name:"Unnamed process",(0,s.jsx)("span",{className:"tnum ml-2 text-muted-foreground",children:e.pid})]})}),(0,s.jsx)("td",{className:ex}),(0,s.jsx)(ek,{value:e.cpuPercent,kind:"percent"}),(0,s.jsx)(ek,{value:e.memoryRssBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.gpuMemoryBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.ioReadBytesPerSec,kind:"rate"}),(0,s.jsx)(ek,{value:e.ioWriteBytesPerSec,kind:"rate"}),(0,s.jsx)("td",{className:`${eg} text-xs text-muted-foreground`,title:e.user??void 0,children:e.user??"—"})]},E(e)))})}function eS({groups:e,sort:t,onSort:r,expanded:n,onToggleGroup:a}){return(0,s.jsx)(ej,{table:"applications",columns:en,label:"Applications",caption:"Applications grouped by systemd unit, process tree, or kernel, with process count, aggregate CPU per core, resident memory, GPU memory, read and write rates, and users",sort:t,onSort:r,children:e.map(e=>{var t;let r=n.has(e.key),i=e.label.length>0?e.label:"Unnamed application",l=e.users.length>0?e.users.join(", "):"—";return(0,s.jsxs)(g.Fragment,{children:[(0,s.jsxs)("tr",{className:"transition-colors hover:bg-card-strong/60",children:[(0,s.jsx)("th",{scope:"row",className:`${eg} text-left font-normal`,title:`${i} \xb7 ${"unit"===(t=e.kind)?"systemd unit":"kernel"===t?"kernel":"process tree"}`,children:(0,s.jsxs)("button",{type:"button","aria-expanded":r,onClick:()=>a(e.key),className:"inline-flex min-h-6 max-w-full items-center gap-1.5 rounded-sm text-left",children:[(0,s.jsx)(er.A,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform ${r?"rotate-90":""}`,"aria-hidden":!0}),(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:i})]})}),(0,s.jsx)("td",{className:ex,children:z(e.count)}),(0,s.jsx)(ek,{value:e.cpuPercent,kind:"percent",partial:e.partial.cpuPercent}),(0,s.jsx)(ek,{value:e.memoryRssBytes,kind:"bytes",partial:e.partial.memoryRssBytes}),(0,s.jsx)(ek,{value:e.gpuMemoryBytes,kind:"bytes",partial:e.partial.gpuMemoryBytes}),(0,s.jsx)(ek,{value:e.ioReadBytesPerSec,kind:"rate",partial:e.partial.ioReadBytesPerSec}),(0,s.jsx)(ek,{value:e.ioWriteBytesPerSec,kind:"rate",partial:e.partial.ioWriteBytesPerSec}),(0,s.jsx)("td",{className:`${eg} text-xs text-muted-foreground`,title:l,children:l})]}),r?(0,s.jsx)(eP,{group:e}):null]},e.key)})})}function e$({mode:e,groups:t,rows:r,tree:n,sort:a,onSort:i,expanded:l,onToggleGroup:o}){if("applications"===e)return(0,s.jsx)(eS,{groups:t,sort:a,onSort:i,expanded:l,onToggleGroup:o});let c="tree"===e?n.map(e=>({row:e.row,depth:e.depth})):r.map(e=>({row:e,depth:0}));return(0,s.jsx)(eA,{entries:c,mode:e,sort:a,onSort:i})}var eR=r(1),eC=r(7499);let eB=[{key:"cpuPercent",label:"cpu"},{key:"memoryRssBytes",label:"memory"},{key:"gpuMemoryBytes",label:"vram"},{key:"ioReadBytesPerSec",label:"read"},{key:"ioWriteBytesPerSec",label:"write"},{key:"threads",label:"threads"}];function eT(e){return new Date(e).toISOString()}function eU(e){return e.displayName?.trim()||e.hostname.trim()||e.machineId}function eD(e){return"applications"===e.mode?e.groups.flatMap(t=>$([...t.members],e.sort.key,e.sort.dir).map(e=>({row:e,application:t.label,applicationKind:t.kind,depth:0}))):"tree"===e.mode?e.tree.map(e=>({row:e.row,application:null,applicationKind:null,depth:e.depth})):e.sortedRows.map(e=>({row:e,application:null,applicationKind:null,depth:0}))}function eW(e){let t=e.now??Date.now(),r=null===e.receivedAtMs?null:Math.max(0,t-e.receivedAtMs),s=null===r?"receipt time unknown":`${Math.round(r/1e3)}s old`;return null===e.receivedAtMs?{label:"unknown",ageMs:null,stale:!0,note:"No browser receipt time is available for this snapshot."}:"paused"===e.phase?{label:"paused",ageMs:r,stale:!1,note:`Paused \xb7 ${s}. Not live.`}:"disconnected"===e.phase?{label:"disconnected",ageMs:r,stale:!0,note:`Collector disconnected \xb7 last snapshot ${s}. Not live.`}:"withheld"===e.phase||"unsupported"===e.phase?{label:"not live",ageMs:r,stale:!0,note:`Process detail is ${e.phase} \xb7 last snapshot ${s}.`}:"failed"===e.phase||"expired"===e.phase||"busy"===e.phase||"cancelled"===e.phase||"error"===e.phase?{label:"not live",ageMs:r,stale:!0,note:`Refresh problem \xb7 last snapshot ${s}. Not live.`}:"acquiring"===e.phase||"loading"===e.phase||"idle"===e.phase?{label:"waiting",ageMs:r,stale:!0,note:`Waiting for a fresh snapshot \xb7 ${s}.`}:K(e.receivedAtMs,t,e.intervalMs)?{label:"stale",ageMs:r,stale:!0,note:`No new snapshot has arrived \xb7 ${s}. Not live.`}:{label:"live",ageMs:r,stale:!1,note:`Live \xb7 updated ${s}.`}}function eI(e){return eB.filter(({key:t})=>null===e[t]).map(({label:e})=>e).join(" ")}function eL(e,t){let r=eW({phase:e.phase,receivedAtMs:e.receivedAtMs,intervalMs:e.intervalMs,now:t}),s=null===e.receivedAtMs?"unknown":eT(e.receivedAtMs),n=e.query.trim();return[`Filtered process snapshot from the loaded view \xb7 ${r.note}`,`Search: ${n.length>0?n:"(none)"} \xb7 view: ${e.mode} \xb7 sort: ${e.sort.key} ${e.sort.dir}`,`Snapshot ${e.snapshot.processes.length} shown of ${e.snapshot.totalProcesses} processes \xb7 ${e.snapshot.inaccessible} unreadable${e.snapshot.truncated?" \xb7 collector kept the highest-CPU rows":""}`,`Captured ${e.capturedAt} \xb7 received ${s}`]}let eq=["name","pid","user","application","application_kind","tree_depth","cpu_percent","memory_rss_bytes","gpu_memory_bytes","io_read_bytes_per_sec","io_write_bytes_per_sec","threads","unavailable_metrics"],eK="inline-flex min-h-7 items-center rounded-md border border-border bg-background px-2 text-xs text-foreground transition-colors hover:bg-card-strong disabled:cursor-not-allowed disabled:opacity-50";function e_(e){let[t,r]=(0,g.useState)(null),n=null!==e.snapshot&&null!==e.capturedAt,a=n?"applications"===e.mode?e.filteredRows.length:"tree"===e.mode?e.tree.length:e.sortedRows.length:0,i=!n||0===a,l=t=>{if(null===e.snapshot||null===e.capturedAt)return;let s=Date.now(),n={...e,snapshot:e.snapshot,capturedAt:e.capturedAt,exportedAt:s};try{let e,i,l,o=function(e,t,r=Date.now()){let s=Date.parse(e.capturedAt);return(0,eC.Y8)("processes",eU(e.machine),Number.isFinite(s)?s:r,t)}(n,t,s),c="csv"===t?function(e){let t,r,s=e.exportedAt??Date.now(),n=(t=eD(e),r=eW({phase:e.phase,receivedAtMs:e.receivedAtMs,intervalMs:e.intervalMs,now:s}),[["Rigscope process snapshot"],["Scope",eL(e,s)[0]],["Machine",eU(e.machine)],["Machine ID",e.machine.machineId],["Snapshot captured",e.capturedAt],["Snapshot received",null===e.receivedAtMs?"unknown":eT(e.receivedAtMs)],["Freshness",`${r.label}${null===r.ageMs?"":` \xb7 ${Math.round(r.ageMs/1e3)}s old`}`],["Search",e.query.trim()||"(none)"],["View",e.mode],["Sort",`${e.sort.key} ${e.sort.dir}`],["Snapshot rows",`${e.snapshot.processes.length} shown of ${e.snapshot.totalProcesses}`],["Unreadable",String(e.snapshot.inaccessible)],["Collector truncated",e.snapshot.truncated?"true":"false"],["Exported rows",String(t.length)],["Note",eL(e,s).slice(1).join(" ")],[]]);for(let t of(n.push([...eq]),eD(e)))n.push(function(e){let{row:t}=e;return[t.name,t.pid,t.user,e.application,e.applicationKind,e.depth,t.cpuPercent,t.memoryRssBytes,t.gpuMemoryBytes,t.ioReadBytesPerSec,t.ioWriteBytesPerSec,t.threads,eI(t)]}(t));return(0,eR.kg)(n)}(n):(e=n.exportedAt??Date.now(),i=eW({phase:n.phase,receivedAtMs:n.receivedAtMs,intervalMs:n.intervalMs,now:e}),l={app:"Rigscope",kind:"processes",version:1,exportedAt:eT(e),scope:{description:"Filtered process snapshot from the loaded view",machine:{id:n.machine.machineId,name:eU(n.machine),hostname:n.machine.hostname,connected:n.machine.connected},query:n.query.trim(),view:n.mode,sort:n.sort},snapshot:{capturedAt:n.capturedAt,receivedAt:null===n.receivedAtMs?null:eT(n.receivedAtMs),ageMs:i.ageMs,freshness:i.label,live:!i.stale&&"live"===i.label,note:i.note,totalProcesses:n.snapshot.totalProcesses,shownProcesses:n.snapshot.processes.length,inaccessible:n.snapshot.inaccessible,truncated:n.snapshot.truncated},exportedRows:eD(n).length,notes:eL(n,e),processes:eD(n).map(e=>({name:e.row.name,pid:e.row.pid,user:e.row.user,application:e.application,applicationKind:e.applicationKind,treeDepth:e.depth,cpuPercent:e.row.cpuPercent,memoryRssBytes:e.row.memoryRssBytes,gpuMemoryBytes:e.row.gpuMemoryBytes,ioReadBytesPerSec:e.row.ioReadBytesPerSec,ioWriteBytesPerSec:e.row.ioWriteBytesPerSec,threads:e.row.threads,unavailableMetrics:eI(e.row).split(" ").filter(Boolean)}))},`${JSON.stringify(l,null,2)}
2
+ `}function o(e,t,r){if("u"<typeof document)return;let s=new Blob([t],{type:r}),n=URL.createObjectURL(s),a=document.createElement("a");a.href=n,a.download=e,a.rel="noopener",a.style.display="none",document.body.append(a),a.click(),a.remove(),globalThis.setTimeout(()=>URL.revokeObjectURL(n),0)}let c="text/csv;charset=utf-8",d="application/json;charset=utf-8"},438:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},2910:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]])},3381:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]])},4268:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},6582:(e,t,r)=>{"use strict";r.d(t,{E:()=>x,x:()=>g});var s=r(5155),n=r(8500),a=r.n(n),i=r(828),l=r(6914),o=r(7029),c=r(438),d=r(7422),u=r(1735),p=r(3440),h=r(9939);function m(e){return(0,s.jsxs)("button",{type:"button",onClick:e.onClick,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,s.jsx)(i.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.children]})}function f(e){return(0,s.jsx)(a(),{href:e.href,className:e.primary?"inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90":"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:e.children})}function g(){let{session:e,phase:t,retryConnection:r}=(0,h.M)();switch(e.kind){case"restoring":return(0,s.jsx)(p.Z,{title:"Checking session",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(p.p,{icon:l.A,note:"Checking your session…"})});case"restore-failed":return(0,s.jsxs)(p.Z,{title:"Hub unreachable",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:o.A,note:"The hub is unreachable right now."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(m,{onClick:r,children:"Check again"})})]});case"signed-out":if("expired"===t)return(0,s.jsxs)(p.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:c.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]});return(0,s.jsxs)(p.Z,{title:"Sign in required",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:l.A,note:"Sign in required."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]});case"auth-unavailable":return(0,s.jsx)(p.Z,{title:"Sign-in unavailable",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(p.p,{icon:d.A,note:"Browser sign-in is not configured on this hub."})})}return"expired"===t?(0,s.jsxs)(p.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:c.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(f,{href:"/login",primary:!0,children:"Sign in"})})]}):"no-permission"===t?(0,s.jsxs)(p.Z,{title:"No permission",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(p.p,{icon:d.A,note:`You are signed in as ${e.user.username}, but this hub grants no machine view to this account.`}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(m,{onClick:r,children:"Check again"})})]}):null}function x(){let{phase:e,retryConnection:t}=(0,h.M)();return"reconnecting"!==e&&"disconnected"!==e&&"connecting"!==e?null:"connecting"===e?(0,s.jsxs)("div",{role:"status",className:"mb-5 flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Connecting to the live feed — waiting for the first snapshot."]}):(0,s.jsxs)("div",{role:"status",className:"mb-5 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(u.A,{className:"h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,s.jsxs)("span",{children:["Connection lost — values below are ",(0,s.jsx)("strong",{className:"font-medium text-foreground",children:"last known"}),", not live measurements","reconnecting"===e?" — retrying with backoff…":" — retries stopped."]}),"disconnected"===e?(0,s.jsx)(m,{onClick:t,children:"Retry now"}):null]})}},7339:(e,t,r)=>{"use strict";r.d(t,{ProcessesView:()=>eX});var s=r(5155),n=r(8500),a=r.n(n),i=r(9926),l=r(3381),o=r(8731),c=r(4173),d=r(3440),u=r(940),p=r(802),h=r(6582),m=r(9939),f=r(8664),g=r(2115),x=r(828),b=r(7422),y=r(7029),w=r(2910),v=r(1735),j=r(9764),k=r(9664),M=r(4268),N=r(9942);let A=new Set(["bash","zsh","fish","sh","dash","ksh","mksh","tcsh","csh","ash","busybox"]),P=new Set(["sshd","sshd-session","dropbear","tmux","screen","systemd"]),S=["cpuPercent","memoryRssBytes","gpuMemoryBytes","ioReadBytesPerSec","ioWriteBytesPerSec"];function $(e,t,r){return e.slice().sort((e,s)=>W(D(e,t),D(s,t),r))}function R(e){return null!==e&&!!("init.scope"===e||/^session-.+\.scope$/.test(e)||/^user@.+\.service$/.test(e))}function C(e){return null===e||!e.endsWith(".scope")&&!e.endsWith(".service")||R(e)?null:e}function B(e){let t=e.replace(/\.(scope|service)$/,"");return t.startsWith("app-gnome-")?t=t.slice(10):t.startsWith("app-")&&(t=t.slice(4)),(t=t.replace(/-\d+$/,"")).length>0?t:e}function T(e){return{key:`tree:${e.pid}:${e.startTicks}`,label:e.name,kind:"tree",leader:e}}function U(e,t){switch(t){case"cpu":return e.cpuPercent;case"memory":return e.memoryRssBytes;case"gpuMemory":return e.gpuMemoryBytes;case"ioRead":return e.ioReadBytesPerSec;case"ioWrite":return e.ioWriteBytesPerSec;case"name":return e.label;case"count":return e.count;case"pid":var r=e.members;let s=null;for(let e of r)(null===s||e.pid<s)&&(s=e.pid);return s;case"user":return e.users.length>0?e.users[0]:null}}function D(e,t){switch(t){case"cpu":return e.cpuPercent;case"memory":return e.memoryRssBytes;case"gpuMemory":return e.gpuMemoryBytes;case"ioRead":return e.ioReadBytesPerSec;case"ioWrite":return e.ioWriteBytesPerSec;case"name":return e.name;case"count":return 1;case"pid":return e.pid;case"user":return e.user}}function W(e,t,r){let s,n=null==e,a=null==t;if(n&&a)return 0;if(n)return 1;if(a)return -1;if("number"==typeof e&&"number"==typeof t)s=e-t;else{let r=String(e).toLowerCase(),n=String(t).toLowerCase();s=r<n?-1:+(r>n)}return"asc"===r?s:-s}var I=r(592),L=r(7586);let q={key:"cpu",dir:"desc"};function K(e,t,r){return null!==e&&t-e>=(!Number.isFinite(r)||r<=0?1e4:Math.max(1e4,3*r))}let _=[{value:"applications",label:"Applications"},{value:"processes",label:"Processes"},{value:"tree",label:"Tree"}];function E(e){return`${e.pid}:${e.startTicks}`}function F(e){if(void 0===e.command)return e;let{command:t,...r}=e;return r}function z(e){return null!=e&&Number.isFinite(e)?Math.round(e).toString().replace(/\B(?=(\d{3})+(?!\d))/g,","):"—"}function O(e){switch(e){case"idle":return{label:"Not connected",tone:"muted",description:"Select a machine to request process detail.",retryable:!1};case"acquiring":return{label:"Connecting",tone:"warn",description:"Requesting process detail…",retryable:!1};case"loading":return{label:"Waiting",tone:"warn",description:"Waiting for the collector's first process snapshot…",retryable:!1};case"ready":return{label:"Live",tone:"ok",description:"Process detail is live.",retryable:!1};case"paused":return{label:"Paused",tone:"muted",description:"Process updates are paused.",retryable:!1};case"stale":return{label:"Not refreshing",tone:"warn",description:"The last snapshot is retained, but new snapshots are not arriving.",retryable:!0};case"disconnected":return{label:"Disconnected",tone:"crit",description:"The collector is disconnected; the last snapshot is not live.",retryable:!0};case"withheld":return{label:"Withheld",tone:"warn",description:"Process detail is withheld for this hub.",retryable:!0};case"unsupported":return{label:"Unsupported",tone:"warn",description:"This collector cannot provide process detail.",retryable:!0};case"busy":return{label:"Busy",tone:"warn",description:"Too many process views are open for this hub.",retryable:!0};case"expired":return{label:"Expired",tone:"warn",description:"Process detail expired before a fresh snapshot arrived.",retryable:!0};case"failed":return{label:"Scan failed",tone:"crit",description:"The process scan failed repeatedly.",retryable:!0};case"cancelled":return{label:"Stopped",tone:"muted",description:"The process detail view was stopped.",retryable:!0};case"error":return{label:"Unavailable",tone:"crit",description:"Process detail is unavailable right now.",retryable:!0}}}function V(e){return"number"==typeof e&&Number.isFinite(e)&&e>0}var Z=r(7348);class G{maxAgeMs;limit;session=null;entries=new Map;constructor(e=3e5,t=32){this.maxAgeMs=e,this.limit=t}scope(e){(this.session!==e||null===e)&&this.entries.clear(),this.session=e}get(e,t,r=Date.now()){this.scope(t);let s=this.entries.get(e);return s&&r-s.lastReceivedMs>=this.maxAgeMs?void this.entries.delete(e):s}set(e,t,r){this.scope(t),this.entries.delete(e),this.entries.set(e,r),this.entries.size>this.limit&&this.entries.delete(this.entries.keys().next().value)}delete(e,t){this.scope(t),this.entries.delete(e)}}let Y=new G;function X(e,t){let r=Y.get(e??"",t);return void 0!==r?{phase:"stale",message:"Resuming process updates…",...r}:{phase:null===e?"idle":"acquiring",detail:null,message:null,intervalMs:1e3,leaseMs:15e3,lastReceivedMs:null}}async function J(e){try{let t=await e.json();if(t&&"object"==typeof t&&"error"in t){let e=t.error;if("string"==typeof e&&e.length>0)return e}}catch{}return e.statusText||null}var H=r(8698);let Q=(0,H.A)("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),ee=(0,H.A)("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),et=(0,H.A)("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);var er=r(8528),es=r(6114);let en=[{id:"name",label:"Application",sortKey:"name",align:"left",width:300},{id:"count",label:"Procs",sortKey:"count",align:"right",width:76},{id:"cpu",label:"CPU / core",sortKey:"cpu",align:"right",width:104},{id:"memory",label:"RSS",sortKey:"memory",align:"right",width:96},{id:"gpuMemory",label:"VRAM",sortKey:"gpuMemory",align:"right",width:96},{id:"ioRead",label:"Read",sortKey:"ioRead",align:"right",width:104},{id:"ioWrite",label:"Write",sortKey:"ioWrite",align:"right",width:104},{id:"users",label:"Users",sortKey:"user",align:"left",width:160}],ea=[{id:"name",label:"Process",sortKey:"name",align:"left",width:300},{id:"pid",label:"PID",sortKey:"pid",align:"right",width:84},{id:"user",label:"User",sortKey:"user",align:"left",width:120},{id:"cpu",label:"CPU / core",sortKey:"cpu",align:"right",width:104},{id:"memory",label:"RSS",sortKey:"memory",align:"right",width:96},{id:"gpuMemory",label:"VRAM",sortKey:"gpuMemory",align:"right",width:96},{id:"ioRead",label:"Read",sortKey:"ioRead",align:"right",width:104},{id:"ioWrite",label:"Write",sortKey:"ioWrite",align:"right",width:104},{id:"threads",label:"Threads",align:"right",width:84}],ei=Object.freeze({}),el=Object.freeze([]),eo=new Set(["cpu","memory","gpuMemory","ioRead","ioWrite","name","count","pid","user"]);function ec(e){return Math.round(Math.min(1200,Math.max(56,e)))}function ed(e){return"applications"===e||"processes"===e||"tree"===e?e:null}function eu(e){if(null===e||"object"!=typeof e)return null;let{key:t,dir:r}=e;return"string"==typeof t&&eo.has(t)&&("asc"===r||"desc"===r)?{key:t,dir:r}:null}function ep(e){if(null===e||"object"!=typeof e||Array.isArray(e))return null;let t={};for(let[r,s]of Object.entries(e))"number"==typeof s&&Number.isFinite(s)&&(t[r]=ec(s));return t}function eh(e){return"string"==typeof e?e.slice(0,200):null}function em(e){return"boolean"==typeof e?e:null}function ef(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e)?e.slice(0,500):null}let eg="overflow-hidden text-ellipsis whitespace-nowrap border-b border-border px-2 py-2 align-middle",ex=`${eg} tnum text-right text-xs`,eb="relative overflow-hidden whitespace-nowrap border-b border-border px-2 py-2 text-left text-xs font-normal text-muted-foreground";function ey(e,t){return t[e.id]??e.width}function ew({label:e,width:t,onChange:r,onReset:n}){let a=(0,g.useRef)(null);return(0,s.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${e} column`,"aria-valuenow":t,"aria-valuemin":56,"aria-valuemax":1200,tabIndex:0,title:"Drag to resize \xb7 double-click to reset",onPointerDown:e=>{0===e.button&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),a.current={x:e.clientX,width:t})},onPointerMove:e=>{null!==a.current&&r(ec(a.current.width+e.clientX-a.current.x))},onPointerUp:e=>{null!==a.current&&r(ec(a.current.width+e.clientX-a.current.x)),a.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:()=>{a.current=null},onLostPointerCapture:()=>{a.current=null},onClick:e=>e.stopPropagation(),onDoubleClick:e=>{e.stopPropagation(),n()},onKeyDown:e=>{"ArrowLeft"===e.key?(e.preventDefault(),r(ec(t-16))):"ArrowRight"===e.key&&(e.preventDefault(),r(ec(t+16)))},className:"group/handle absolute inset-y-0 right-0 z-10 flex w-2.5 cursor-col-resize touch-none select-none justify-end",children:(0,s.jsx)("span",{"aria-hidden":!0,className:"my-2 w-px bg-border transition-colors group-hover/handle:bg-accent group-focus-visible/handle:bg-accent"})})}function ev({column:e,sort:t,onSort:r,width:n,onResize:a,onReset:i}){let l="right"===e.align,o=e.sortKey,c=void 0!==o?t.key!==o?"none":"asc"===t.dir?"ascending":"descending":"none",d="none"!==c,u=d?"asc"===t.dir?ee:et:Q;return(0,s.jsxs)("th",{scope:"col","aria-sort":void 0!==o?c:void 0,className:l?`${eb} text-right`:eb,children:[void 0!==o?(0,s.jsxs)("button",{type:"button",onClick:()=>r(o),className:["inline-flex min-h-6 max-w-full items-center gap-1 rounded-sm transition-colors hover:text-foreground",l?"w-full justify-end pr-1":"",d?"text-foreground":""].filter(Boolean).join(" "),children:[(0,s.jsx)("span",{className:"truncate",children:e.label}),(0,s.jsx)(u,{className:d?"h-3 w-3 shrink-0":"h-3 w-3 shrink-0 opacity-40","aria-hidden":!0})]}):(0,s.jsx)("span",{className:l?"block truncate pr-1":"block truncate",children:e.label}),(0,s.jsx)(ew,{label:e.label,width:n,onChange:a,onReset:i})]})}function ej({table:e,columns:t,label:r,caption:n,sort:a,onSort:i,children:l}){let[o,c]=(0,es.u)(`processes.widths.${e}`,ei,ep),d=(0,g.useRef)(null),[u,p]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=d.current;if(!e)return;let t=new ResizeObserver(([e])=>p(e.contentRect.width));return t.observe(e),()=>t.disconnect()},[]);let h=e=>"name"===e.id?160:56,m=t.reduce((e,t)=>e+h(t),0),f=t.reduce((e,t)=>e+ey(t,o),0),x={},b=Math.max(u||f,m),y=[...t];for(;y.length>0;){let e=y.reduce((e,t)=>e+ey(t,o),0),t=y.filter(t=>b*ey(t,o)/e<h(t));if(0===t.length){for(let t of y)x[t.id]=b*ey(t,o)/e;break}for(let e of t)x[e.id]=h(e),b-=h(e);y=y.filter(e=>!t.includes(e))}return(0,s.jsx)("div",{ref:d,className:"relative min-h-0 w-full min-w-0 flex-1 overflow-auto overscroll-contain",tabIndex:0,role:"region","aria-label":r,children:(0,s.jsxs)("table",{className:"table-fixed border-separate border-spacing-0 text-left",style:{width:"100%",minWidth:m},children:[(0,s.jsx)("caption",{className:"sr-only",children:n}),(0,s.jsx)("colgroup",{children:t.map(e=>(0,s.jsx)("col",{style:{width:x[e.id]}},e.id))}),(0,s.jsx)("thead",{className:"sticky top-0 z-20 bg-card",children:(0,s.jsx)("tr",{children:t.map(e=>(0,s.jsx)(ev,{column:e,sort:a,onSort:i,width:x[e.id],onResize:r=>{let s,n,a;return s=t.indexOf(e),n=t[s+1]??t[s-1],a=Math.max(h(e)-x[e.id],Math.min(r-x[e.id],x[n.id]-h(n))),void c({...x,[e.id]:x[e.id]+a,[n.id]:x[n.id]-a})},onReset:()=>c(t=>{let{[e.id]:r,...s}=t;return s})},e.id))})}),(0,s.jsx)("tbody",{children:l})]})})}function ek({value:e,kind:t,partial:r=!1}){let n=function(e,t,r=!1){let s;if(null===e||!Number.isFinite(e)||e<0)return{text:"—",atLeast:!1,title:null};switch(t){case"percent":s=(0,L.l9)(e);break;case"bytes":s=(0,L.z3)(e);break;case"rate":s=`${(0,L.z3)(e)}/s`;break;case"count":s=z(e)}return{text:s,atLeast:r,title:r?`At least ${s}: some processes in this group did not report this metric.`:null}}(e,t,r);return(0,s.jsxs)("td",{className:"—"===n.text?`${ex} text-muted-foreground`:ex,title:n.title??void 0,children:[n.atLeast?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{"aria-hidden":!0,children:"≥ "}),(0,s.jsx)("span",{className:"sr-only",children:"at least "})]}):null,n.text]})}function eM(e){let t=e.name.length>0?e.name:"Unnamed process";return null!==e.unit?`${t} \xb7 ${e.unit}`:t}function eN({row:e,depth:t=0}){return(0,s.jsx)("th",{scope:"row",className:`${eg} text-left text-sm font-medium`,title:eM(e),children:(0,s.jsxs)("span",{style:t>0?{paddingLeft:`${14*t}px`}:void 0,children:[t>0?(0,s.jsx)("span",{className:"sr-only",children:`Nested level ${t+1}. `}):null,e.name.length>0?e.name:(0,s.jsx)("span",{className:"text-muted-foreground",children:"Unnamed process"})]})})}function eA({entries:e,sort:t,onSort:r,mode:n}){return(0,s.jsx)(ej,{table:"processes",columns:ea,label:"tree"===n?"Process tree":"Process list",caption:"tree"===n?"Process tree with nesting depth, PID, user, CPU per core, resident memory, GPU memory, read and write rates, and threads":"Processes with PID, user, CPU per core, resident memory, GPU memory, read and write rates, and threads",sort:t,onSort:r,children:e.map(({row:e,depth:t})=>(0,s.jsxs)("tr",{className:"transition-colors hover:bg-card-strong/60",children:[(0,s.jsx)(eN,{row:e,depth:t}),(0,s.jsx)("td",{className:ex,children:e.pid}),(0,s.jsx)("td",{className:`${eg} text-xs text-muted-foreground`,title:e.user??void 0,children:e.user??"—"}),(0,s.jsx)(ek,{value:e.cpuPercent,kind:"percent"}),(0,s.jsx)(ek,{value:e.memoryRssBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.gpuMemoryBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.ioReadBytesPerSec,kind:"rate"}),(0,s.jsx)(ek,{value:e.ioWriteBytesPerSec,kind:"rate"}),(0,s.jsx)("td",{className:ex,children:z(e.threads)})]},E(e)))})}function eP({group:e}){return(0,s.jsx)(s.Fragment,{children:e.members.map(e=>(0,s.jsxs)("tr",{className:"bg-card-strong/40 transition-colors hover:bg-card-strong/70",children:[(0,s.jsx)("th",{scope:"row",className:`${eg} text-left text-xs font-normal`,title:`${eM(e)} \xb7 PID ${e.pid}`,children:(0,s.jsxs)("span",{className:"pl-5",children:[e.name.length>0?e.name:"Unnamed process",(0,s.jsx)("span",{className:"tnum ml-2 text-muted-foreground",children:e.pid})]})}),(0,s.jsx)("td",{className:ex}),(0,s.jsx)(ek,{value:e.cpuPercent,kind:"percent"}),(0,s.jsx)(ek,{value:e.memoryRssBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.gpuMemoryBytes,kind:"bytes"}),(0,s.jsx)(ek,{value:e.ioReadBytesPerSec,kind:"rate"}),(0,s.jsx)(ek,{value:e.ioWriteBytesPerSec,kind:"rate"}),(0,s.jsx)("td",{className:`${eg} text-xs text-muted-foreground`,title:e.user??void 0,children:e.user??"—"})]},E(e)))})}function eS({groups:e,sort:t,onSort:r,expanded:n,onToggleGroup:a}){return(0,s.jsx)(ej,{table:"applications",columns:en,label:"Applications",caption:"Applications grouped by systemd unit, process tree, or kernel, with process count, aggregate CPU per core, resident memory, GPU memory, read and write rates, and users",sort:t,onSort:r,children:e.map(e=>{var t;let r=n.has(e.key),i=e.label.length>0?e.label:"Unnamed application",l=e.users.length>0?e.users.join(", "):"—";return(0,s.jsxs)(g.Fragment,{children:[(0,s.jsxs)("tr",{className:"transition-colors hover:bg-card-strong/60",children:[(0,s.jsx)("th",{scope:"row",className:`${eg} text-left font-normal`,title:`${i} \xb7 ${"unit"===(t=e.kind)?"systemd unit":"kernel"===t?"kernel":"process tree"}`,children:(0,s.jsxs)("button",{type:"button","aria-expanded":r,onClick:()=>a(e.key),className:"inline-flex min-h-6 max-w-full items-center gap-1.5 rounded-sm text-left",children:[(0,s.jsx)(er.A,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform ${r?"rotate-90":""}`,"aria-hidden":!0}),(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:i})]})}),(0,s.jsx)("td",{className:ex,children:z(e.count)}),(0,s.jsx)(ek,{value:e.cpuPercent,kind:"percent",partial:e.partial.cpuPercent}),(0,s.jsx)(ek,{value:e.memoryRssBytes,kind:"bytes",partial:e.partial.memoryRssBytes}),(0,s.jsx)(ek,{value:e.gpuMemoryBytes,kind:"bytes",partial:e.partial.gpuMemoryBytes}),(0,s.jsx)(ek,{value:e.ioReadBytesPerSec,kind:"rate",partial:e.partial.ioReadBytesPerSec}),(0,s.jsx)(ek,{value:e.ioWriteBytesPerSec,kind:"rate",partial:e.partial.ioWriteBytesPerSec}),(0,s.jsx)("td",{className:`${eg} text-xs text-muted-foreground`,title:l,children:l})]}),r?(0,s.jsx)(eP,{group:e}):null]},e.key)})})}function e$({mode:e,groups:t,rows:r,tree:n,sort:a,onSort:i,expanded:l,onToggleGroup:o}){if("applications"===e)return(0,s.jsx)(eS,{groups:t,sort:a,onSort:i,expanded:l,onToggleGroup:o});let c="tree"===e?n.map(e=>({row:e.row,depth:e.depth})):r.map(e=>({row:e,depth:0}));return(0,s.jsx)(eA,{entries:c,mode:e,sort:a,onSort:i})}var eR=r(1),eC=r(7499);let eB=[{key:"cpuPercent",label:"cpu"},{key:"memoryRssBytes",label:"memory"},{key:"gpuMemoryBytes",label:"vram"},{key:"ioReadBytesPerSec",label:"read"},{key:"ioWriteBytesPerSec",label:"write"},{key:"threads",label:"threads"}];function eT(e){return new Date(e).toISOString()}function eU(e){return e.displayName?.trim()||e.hostname.trim()||e.machineId}function eD(e){return"applications"===e.mode?e.groups.flatMap(t=>$([...t.members],e.sort.key,e.sort.dir).map(e=>({row:e,application:t.label,applicationKind:t.kind,depth:0}))):"tree"===e.mode?e.tree.map(e=>({row:e.row,application:null,applicationKind:null,depth:e.depth})):e.sortedRows.map(e=>({row:e,application:null,applicationKind:null,depth:0}))}function eW(e){let t=e.now??Date.now(),r=null===e.receivedAtMs?null:Math.max(0,t-e.receivedAtMs),s=null===r?"receipt time unknown":`${Math.round(r/1e3)}s old`;return null===e.receivedAtMs?{label:"unknown",ageMs:null,stale:!0,note:"No browser receipt time is available for this snapshot."}:"paused"===e.phase?{label:"paused",ageMs:r,stale:!1,note:`Paused \xb7 ${s}. Not live.`}:"disconnected"===e.phase?{label:"disconnected",ageMs:r,stale:!0,note:`Collector disconnected \xb7 last snapshot ${s}. Not live.`}:"withheld"===e.phase||"unsupported"===e.phase?{label:"not live",ageMs:r,stale:!0,note:`Process detail is ${e.phase} \xb7 last snapshot ${s}.`}:"failed"===e.phase||"expired"===e.phase||"busy"===e.phase||"cancelled"===e.phase||"error"===e.phase?{label:"not live",ageMs:r,stale:!0,note:`Refresh problem \xb7 last snapshot ${s}. Not live.`}:"acquiring"===e.phase||"loading"===e.phase||"idle"===e.phase?{label:"waiting",ageMs:r,stale:!0,note:`Waiting for a fresh snapshot \xb7 ${s}.`}:K(e.receivedAtMs,t,e.intervalMs)?{label:"stale",ageMs:r,stale:!0,note:`No new snapshot has arrived \xb7 ${s}. Not live.`}:{label:"live",ageMs:r,stale:!1,note:`Live \xb7 updated ${s}.`}}function eI(e){return eB.filter(({key:t})=>null===e[t]).map(({label:e})=>e).join(" ")}function eL(e,t){let r=eW({phase:e.phase,receivedAtMs:e.receivedAtMs,intervalMs:e.intervalMs,now:t}),s=null===e.receivedAtMs?"unknown":eT(e.receivedAtMs),n=e.query.trim();return[`Filtered process snapshot from the loaded view \xb7 ${r.note}`,`Search: ${n.length>0?n:"(none)"} \xb7 view: ${e.mode} \xb7 sort: ${e.sort.key} ${e.sort.dir}`,`Snapshot ${e.snapshot.processes.length} shown of ${e.snapshot.totalProcesses} processes \xb7 ${e.snapshot.inaccessible} unreadable${e.snapshot.truncated?" \xb7 collector kept the highest-CPU rows":""}`,`Captured ${e.capturedAt} \xb7 received ${s}`]}let eq=["name","pid","user","application","application_kind","tree_depth","cpu_percent","memory_rss_bytes","gpu_memory_bytes","io_read_bytes_per_sec","io_write_bytes_per_sec","threads","unavailable_metrics"],eK="inline-flex min-h-7 items-center rounded-md border border-border bg-background px-2 text-xs text-foreground transition-colors hover:bg-card-strong disabled:cursor-not-allowed disabled:opacity-50";function e_(e){let[t,r]=(0,g.useState)(null),n=null!==e.snapshot&&null!==e.capturedAt,a=n?"applications"===e.mode?e.filteredRows.length:"tree"===e.mode?e.tree.length:e.sortedRows.length:0,i=!n||0===a,l=t=>{if(null===e.snapshot||null===e.capturedAt)return;let s=Date.now(),n={...e,snapshot:e.snapshot,capturedAt:e.capturedAt,exportedAt:s};try{let e,i,l,o=function(e,t,r=Date.now()){let s=Date.parse(e.capturedAt);return(0,eC.Y8)("processes",eU(e.machine),Number.isFinite(s)?s:r,t)}(n,t,s),c="csv"===t?function(e){let t,r,s=e.exportedAt??Date.now(),n=(t=eD(e),r=eW({phase:e.phase,receivedAtMs:e.receivedAtMs,intervalMs:e.intervalMs,now:s}),[["Rigscope process snapshot"],["Scope",eL(e,s)[0]],["Machine",eU(e.machine)],["Machine ID",e.machine.machineId],["Snapshot captured",e.capturedAt],["Snapshot received",null===e.receivedAtMs?"unknown":eT(e.receivedAtMs)],["Freshness",`${r.label}${null===r.ageMs?"":` \xb7 ${Math.round(r.ageMs/1e3)}s old`}`],["Search",e.query.trim()||"(none)"],["View",e.mode],["Sort",`${e.sort.key} ${e.sort.dir}`],["Snapshot rows",`${e.snapshot.processes.length} shown of ${e.snapshot.totalProcesses}`],["Unreadable",String(e.snapshot.inaccessible)],["Collector truncated",e.snapshot.truncated?"true":"false"],["Exported rows",String(t.length)],["Note",eL(e,s).slice(1).join(" ")],[]]);for(let t of(n.push([...eq]),eD(e)))n.push(function(e){let{row:t}=e;return[t.name,t.pid,t.user,e.application,e.applicationKind,e.depth,t.cpuPercent,t.memoryRssBytes,t.gpuMemoryBytes,t.ioReadBytesPerSec,t.ioWriteBytesPerSec,t.threads,eI(t)]}(t));return(0,eR.kg)(n)}(n):(e=n.exportedAt??Date.now(),i=eW({phase:n.phase,receivedAtMs:n.receivedAtMs,intervalMs:n.intervalMs,now:e}),l={app:"Rigscope",kind:"processes",exportedAt:eT(e),scope:{description:"Filtered process snapshot from the loaded view",machine:{id:n.machine.machineId,name:eU(n.machine),hostname:n.machine.hostname,connected:n.machine.connected},query:n.query.trim(),view:n.mode,sort:n.sort},snapshot:{capturedAt:n.capturedAt,receivedAt:null===n.receivedAtMs?null:eT(n.receivedAtMs),ageMs:i.ageMs,freshness:i.label,live:!i.stale&&"live"===i.label,note:i.note,totalProcesses:n.snapshot.totalProcesses,shownProcesses:n.snapshot.processes.length,inaccessible:n.snapshot.inaccessible,truncated:n.snapshot.truncated},exportedRows:eD(n).length,notes:eL(n,e),processes:eD(n).map(e=>({name:e.row.name,pid:e.row.pid,user:e.row.user,application:e.application,applicationKind:e.applicationKind,treeDepth:e.depth,cpuPercent:e.row.cpuPercent,memoryRssBytes:e.row.memoryRssBytes,gpuMemoryBytes:e.row.gpuMemoryBytes,ioReadBytesPerSec:e.row.ioReadBytesPerSec,ioWriteBytesPerSec:e.row.ioWriteBytesPerSec,threads:e.row.threads,unavailableMetrics:eI(e.row).split(" ").filter(Boolean)}))},`${JSON.stringify(l,null,2)}
3
3
  `);(0,eR.PE)(o,c,"csv"===t?eR.UR:eR.uW),r(`${t.toUpperCase()} downloaded \xb7 ${a} ${1===a?"process":"processes"}`)}catch{r("The process export could not be created.")}},o=n?0===a?"No processes match the current search":void 0:"A process snapshot is not available yet";return(0,s.jsxs)("div",{className:"flex min-w-0 shrink-0 items-center gap-1.5",children:[(0,s.jsx)("span",{className:"hidden text-xs text-muted-foreground sm:inline",children:"Export"}),(0,s.jsx)("button",{type:"button",onClick:()=>l("csv"),disabled:i,"aria-label":"Download current process snapshot as CSV",title:o??"Download the filtered process snapshot as CSV",className:eK,children:"CSV"}),(0,s.jsx)("button",{type:"button",onClick:()=>l("json"),disabled:i,"aria-label":"Download current process snapshot as JSON",title:o??"Download the filtered process snapshot as JSON",className:eK,children:"JSON"}),(0,s.jsxs)("span",{role:"status",className:t?.includes("could not")?"inline-flex items-center gap-1 text-xs text-warn":"sr-only",children:[t?.includes("could not")?(0,s.jsx)(v.A,{className:"h-3 w-3","aria-hidden":!0}):null,t??""]})]})}let eE={ok:"bg-ok-soft text-ok",warn:"bg-warn-soft text-warn",crit:"bg-crit-soft text-crit",muted:"border border-border text-muted-foreground"};function eF({phase:e,message:t}){return(0,s.jsxs)("span",{title:t??e.description,className:`inline-flex h-6 w-32 shrink-0 items-center gap-1.5 rounded-full px-2 py-0.5 text-xs ${eE[e.tone]}`,children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-current","aria-hidden":!0}),e.label]})}function ez({onClick:e,label:t="Check again"}){return(0,s.jsxs)("button",{type:"button",onClick:e,className:"inline-flex min-h-5 items-center gap-1.5 rounded-md border border-border bg-card px-2 py-1 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,s.jsx)(x.A,{className:"h-3 w-3","aria-hidden":!0}),t]})}function eO({phase:e,info:t,message:r,onRetry:n}){let a="withheld"===e||"unsupported"===e?b.A:"disconnected"===e||"error"===e?y.A:"paused"===e?w.A:"acquiring"===e||"loading"===e?i.A:"busy"===e||"expired"===e||"failed"===e||"stale"===e?v.A:j.A;return(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 break-words",children:[(0,s.jsx)(d.p,{icon:a,note:r??t.description,className:"min-h-64 w-full"}),"paused"!==e&&t.retryable?(0,s.jsx)(ez,{onClick:n,label:"Retry process detail"}):null]})}function eV({summary:e,lastReceivedMs:t,intervalMs:r,message:n,phase:a,hasSnapshot:i}){let l=(0,Z.c)(1e3),o="ready"===a&&K(t,l,r),c=o?"stale":a,d="paused"===c,u=O(c),p=null===t?null:(0,L.nV)(Math.max(0,l-t)),h=null===p?null:"ready"===c?`Updated ${p}`:`Last snapshot ${p}`,m=d?i?"Paused. This snapshot is not live.":"Paused. Use Resume to request a fresh snapshot.":`${u.label}${o?". No new snapshot has arrived.":""}${n?`. ${n}`:""}`;return d&&!i?(0,s.jsx)("p",{role:"status",className:"sr-only",children:m}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{role:"status",className:"sr-only",children:m}),(0,s.jsxs)("div",{className:"flex min-h-6 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[d?(0,s.jsx)("span",{children:"Paused — not live"}):(0,s.jsx)(eF,{phase:u,message:n}),i&&null!==h?(0,s.jsx)("span",{className:"tnum",children:h}):null,i&&e.truncated?(0,s.jsxs)("span",{className:"tnum",title:"The collector kept the highest-CPU rows",children:["top ",z(e.shown)," of ",z(e.total)]}):null,i&&e.inaccessible>0?(0,s.jsxs)("span",{className:"tnum text-warn",children:[z(e.inaccessible)," unreadable"]}):null]})]})}function eZ({machine:e,csrfToken:t,paused:r,onPausedChange:n}){var a;let[i,l]=(0,es.u)("processes.query","",eh,"session"),o=(0,g.useDeferredValue)(i),[c,u]=(0,es.u)("processes.mode","applications",ed),[p,h]=(a="applications"===c?"applications":"processes",(0,es.u)(`processes.sort.${a}`,q,eu)),[m,f]=(0,es.u)("processes.expanded",el,ef,"session"),x=(0,g.useMemo)(()=>new Set(m),[m]),{state:b,refresh:y}=function(e){let{machineId:t,csrfToken:r,paused:s}=e,[n,a]=(0,g.useState)(()=>"u">typeof document&&document.hidden),[i,l]=(0,g.useState)(0),[o,c]=(0,g.useState)(()=>X(t,r)),d=(0,g.useRef)(o),u=(0,g.useRef)({machineId:t,csrfToken:r}),p=(0,g.useRef)(0),h=(0,g.useCallback)(()=>{p.current+=1,l(p.current)},[]);return(0,g.useEffect)(()=>{if("u"<typeof document)return;let e=()=>a(document.hidden);return e(),document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[]),(0,g.useEffect)(()=>{let e;if(u.current.machineId!==t||u.current.csrfToken!==r){u.current={machineId:t,csrfToken:r};let e=X(t,r);d.current=e,c(e)}if(!(null!==t&&null!==r&&!s&&!n)){if(t&&r){let e={...d.current,phase:"paused",message:n?"This tab is hidden — process updates are stopped until it is visible again.":"Paused — process updates are stopped until you resume."};d.current=e,c(e)}else{let e=X(t,r);d.current=e,c(e)}return}let a=!1,i=new AbortController,l=(e=globalThis.crypto)&&"function"==typeof e.randomUUID?e.randomUUID():`viewer-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,o=`/api/processes?machineId=${encodeURIComponent(t)}&viewerId=${encodeURIComponent(l)}`,p=d.current.intervalMs||1e3,h=d.current.leaseMs||15e3,m=null!==d.current.detail,f=!1,g=!1,x=!1,b=null,y=null,w=null,v=e=>{if(a)return;let s=d.current,n="function"==typeof e?e(s):e,i={...s,...n};d.current=i,null!==i.detail&&null!==i.lastReceivedMs&&Y.set(t,r,{detail:i.detail,intervalMs:i.intervalMs,leaseMs:i.leaseMs,lastReceivedMs:i.lastReceivedMs}),c(i)},j=()=>{null!==b&&(clearTimeout(b),b=null),null!==y&&(clearTimeout(y),y=null),w?.abort(),w=null},k=()=>{try{fetch(o,{method:"DELETE",cache:"no-store",keepalive:!0,headers:{"X-CSRF-Token":r,Accept:"application/json"}}).catch(()=>void 0)}catch{}},M=()=>{g=!1,null!==b&&(clearTimeout(b),b=null)},N=(e,s)=>{x=!0,j(),m=!1,Y.delete(t,r),v({phase:e,detail:null,message:s,lastReceivedMs:null}),k()},A=e=>{let t="u">typeof navigator&&!1===navigator.onLine;v({phase:m?t?"disconnected":"stale":"error",message:e})},P=async()=>{try{let e=await fetch(o,{method:"POST",cache:"no-store",signal:i.signal,headers:{"X-CSRF-Token":r,Accept:"application/json"}});if(a||i.signal.aborted)return!1;if(!e.ok){M();let t=await J(e);return 401===e.status?N("error","Your session ended. Sign in again to inspect processes."):403===e.status?N("withheld",t??"Processes are not available to this hub."):409===e.status?N("unsupported",t??"This collector requires an upgrade before Processes is available."):(429===e.status||503===e.status)&&/budget/i.test(t??"")?v({phase:"busy",message:t??"Too many process views are open for this hub."}):A(t??`Could not request process detail (HTTP ${e.status}).`),!1}g=!0;let t=null;try{t=await e.json()}catch{t=null}let s=function(e){if(null===e||"object"!=typeof e||Array.isArray(e))return null;let t=e.leaseMs,r=e.intervalMs;return V(t)&&V(r)?{leaseMs:Math.round(t),intervalMs:Math.round(r)}:null}(t);if(null===s)return M(),k(),A("The hub returned an unexpected response."),!1;if(a||i.signal.aborted)return!1;return p=s.intervalMs,h=s.leaseMs,v(e=>({intervalMs:s.intervalMs,leaseMs:s.leaseMs,phase:null===e.detail?"loading":e.phase,message:null})),!0}catch(e){if(a||i.signal.aborted)return!1;return M(),A(m?"Could not refresh process detail. Showing the last snapshot, which is not live.":"Could not reach the hub for process detail."),!1}},S=()=>{a||x||null!==y||(y=setTimeout(()=>{y=null,$()},Math.max(1e3,Math.min(5e3,Math.floor(h/3)))))},$=async()=>{a||x||(await P(),a||x||(g&&!f&&null===b&&R(),S()))},R=async()=>{if(a||x||f)return;f=!0;let e=new AbortController;w=e;let t=()=>e.abort();i.signal.addEventListener("abort",t,{once:!0});try{let t=await fetch(o,{cache:"no-store",signal:e.signal,headers:{Accept:"application/json"}});if(a||e.signal.aborted)return;if(410===t.status){v({phase:m?"stale":"loading",message:"Process detail expired. Renewing…"}),await P();return}if(!t.ok){let e=await J(t);401===t.status?N("error","Your session ended. Sign in again to inspect processes."):403===t.status?N("withheld",e??"Processes are not available to this machine."):A(e??`Could not refresh processes (HTTP ${t.status}).`);return}let r=null;try{r=await t.json()}catch{r=null}let s=function(e){if(null===e||"object"!=typeof e||Array.isArray(e))return null;let t=e.state;if("string"!=typeof t||0===t.length)return null;let r=e.result;if(null==r)return{state:t,result:null};try{let e=(0,I.Q_)(r);if("detail.result"!==e.type)return null;return{state:t,result:e}}catch{return null}}(r);if(a||e.signal.aborted)return;if(null===s)return void A(m?"Unable to read the process update. Showing the last snapshot.":"Unable to read the process update from the hub.");((e,t)=>{if(null!==t){m=!0;let e=d.current;if(null!==e.detail&&e.detail.subscriptionId===t.subscriptionId&&e.detail.capturedAt===t.capturedAt&&"ready"===e.phase&&null===e.message)return;v(e=>{let r=null!==e.detail&&e.detail.subscriptionId===t.subscriptionId&&e.detail.capturedAt===t.capturedAt;return{phase:"ready",detail:r?e.detail:t,message:null,lastReceivedMs:r?e.lastReceivedMs:Date.now()}});return}let r=function(e){switch(e){case"ready":return"ready";case"loading":return"loading";case"paused":return"paused";case"disconnected":return"disconnected";case"withheld":return"withheld";case"unsupported":return"unsupported";case"busy":return"busy";case"expired":return"expired";case"failed":return"failed";case"cancelled":return"cancelled";default:return"error"}}(e);switch(r){case"ready":case"loading":return v({phase:m?"stale":"loading",message:m?"Waiting for a fresh snapshot. The values shown are from the last received snapshot.":"Waiting for the collector to report processes…"});case"disconnected":return v({phase:"disconnected",message:m?"The collector is disconnected. Showing the last received snapshot; it is not live.":"The collector is disconnected."});case"withheld":case"unsupported":case"cancelled":return N(r,O(r).description);case"busy":case"expired":case"failed":return v({phase:r,message:m?`${O(r).description} Showing the last received snapshot.`:O(r).description});case"paused":return v({phase:"paused",message:"Process updates are paused."});default:v({phase:m?"stale":"error",message:"Unable to read the process status from the hub."})}})(s.state,s.result)}catch{if(a||e.signal.aborted)return;A(m?"Process refresh failed. Showing the last snapshot, which is not live.":"Could not reach the hub for process detail.")}finally{i.signal.removeEventListener("abort",t),w===e&&(w=null),f=!1,a||x||a||x||!g||null!==b||(b=setTimeout(()=>{b=null,R()},p))}};return v(e=>null===e.detail?{phase:"acquiring",message:null}:"ready"===e.phase&&null===e.message?{}:{phase:"stale",message:"Resuming process updates…"}),(async()=>{let e=await P();a||x||(S(),e&&R())})(),()=>{a=!0,x=!0,j(),k()}},[t,r,s,n,i]),{state:u.current.machineId===t&&u.current.csrfToken===r?o:X(t,r),hidden:n,refresh:h}}({machineId:e.machineId,csrfToken:t,paused:r}),v=(0,g.useMemo)(()=>b.detail?.snapshot.processes??[],[b.detail]),j=(0,g.useMemo)(()=>(function(e){if(null===e)return{total:0,shown:0,inaccessible:0,truncated:!1};let t=e.processes.length;return{total:e.totalProcesses,shown:t,inaccessible:e.inaccessible,truncated:e.truncated}})(b.detail?.snapshot??null),[b.detail]),D=(0,g.useMemo)(()=>{var e,t,r;let s;return e=v,t=o,r=e.map(F),0===(s=t.trim().toLowerCase()).length?r.slice():r.filter(e=>!!(e.name.toLowerCase().includes(s)||null!==e.user&&e.user.toLowerCase().includes(s)||String(e.pid).includes(s)||null!==e.unit&&e.unit.toLowerCase().includes(s)||void 0!==e.command&&e.command.toLowerCase().includes(s)))},[v,o]),L=(0,g.useMemo)(()=>$(D,p.key,p.dir),[D,p]),K=(0,g.useMemo)(()=>{var e,t,r;return"applications"===c?(e=function(e){let t=new Map;for(let r of e)t.has(r.pid)||t.set(r.pid,r);let r=new Map;for(let s of e){let e=function(e,t){if(function(e,t){if(2===e.pid||2===e.ppid)return!0;let r=e,s=new Set;for(;r&&!s.has(r.pid);){if(2===r.pid)return!0;s.add(r.pid),r=t.get(r.ppid)}return!1}(e,t))return{key:"kernel",label:"kernel",kind:"kernel",leader:e};let r=C(e.unit);if(null!==r)return{key:`unit:${r}`,label:B(r),kind:"unit",leader:e};let s=e,n=new Set;for(;;){if(n.has(s.pid)){let e=s;for(let r of n){let s=t.get(r);s&&(s.pid<e.pid||s.pid===e.pid&&s.startTicks<e.startTicks)&&(e=s)}return T(e)}n.add(s.pid);let e=t.get(s.ppid);if(!e||function(e,t){if(1===e.pid)return!0;let r=e.name.toLowerCase();if(A.has(r)||P.has(r)||r.startsWith("tmux:"))return!0;if(R(e.unit)){let r=t.get(e.ppid);return void 0===r||r.unit!==e.unit}return!1}(e,t))return T(s);let r=C(e.unit);if(null!==r)return{key:`unit:${r}`,label:B(r),kind:"unit",leader:e};s=e}}(s,t),n=r.get(e.key);n?n.members.push(s):r.set(e.key,{descriptor:e,members:[s]})}return[...r.values()].map(({descriptor:e,members:t})=>(function(e,t){let r={cpuPercent:{sum:0,known:0},memoryRssBytes:{sum:0,known:0},gpuMemoryBytes:{sum:0,known:0},ioReadBytesPerSec:{sum:0,known:0},ioWriteBytesPerSec:{sum:0,known:0}},s=new Set;for(let e of t)for(let t of(null!==e.user&&s.add(e.user),S)){let s=e[t];null!==s&&Number.isFinite(s)&&(r[t].sum+=s,r[t].known++)}let n=e=>0===r[e].known?null:r[e].sum,a={};for(let e of S)a[e]=r[e].known>0&&r[e].known<t.length;return{key:e.key,label:e.label,kind:e.kind,members:e.leader!==t[0]?[e.leader,...t.filter(t=>t!==e.leader)]:t,cpuPercent:n("cpuPercent"),memoryRssBytes:n("memoryRssBytes"),gpuMemoryBytes:n("gpuMemoryBytes"),ioReadBytesPerSec:n("ioReadBytesPerSec"),ioWriteBytesPerSec:n("ioWriteBytesPerSec"),count:t.length,users:[...s].sort(),partial:a}})(e,t))}(D),t=p.key,r=p.dir,e.slice().sort((e,s)=>W(U(e,t),U(s,t),r))):[]},[D,c,p]),E=(0,g.useMemo)(()=>"tree"===c?function(e){let t=e.length,r=new Map;for(let s=0;s<t;s++)r.has(e[s].pid)||r.set(e[s].pid,s);let s=e.map(e=>{let t=r.get(e.ppid);return void 0===t?null:t}),n=new Uint8Array(t);for(let e=0;e<t;e++){if(0!==n[e])continue;let t=[],r=e;for(;null!==r&&0===n[r];)n[r]=1,t.push(r),r=s[r];for(let e of(null!==r&&1===n[r]&&(s[t[t.length-1]]=null),t))n[e]=2}let a=Array.from({length:t},()=>[]),i=[];for(let e=0;e<t;e++){let t=s[e];null===t?i.push(e):a[t].push(e)}let l=[],o=[];for(let e=i.length-1;e>=0;e--)o.push({index:i[e],depth:0});for(;o.length>0;){let{index:t,depth:r}=o.pop();l.push({row:e[t],depth:r,children:a[t].length});let s=a[t];for(let e=s.length-1;e>=0;e--)o.push({index:s[e],depth:r+1})}return l}(L):[],[c,L]),z=O(b.phase),Z=null!==b.detail,G=!Z&&("acquiring"===b.phase||"loading"===b.phase),H=o.trim().slice(0,80),Q=(0,g.useMemo)(()=>{let e=D.length,t=o.trim().length>0,r=1!==e||t?"processes":"process";return"applications"===c?`${K.length} app${1===K.length?"":"s"} \xb7 ${e}${t?` of ${j.shown}`:""} ${r}`:`${e}${t?` of ${j.shown}`:""} ${r}`},[o,D.length,K.length,c,j.shown]);return(0,s.jsx)(d.Z,{title:"Process detail",action:Z?(0,s.jsx)("span",{className:"tnum hidden max-w-[18rem] truncate text-muted-foreground sm:block",children:Q}):void 0,className:"min-h-0 flex-1",children:(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[(0,s.jsxs)("div",{className:"relative min-w-0 flex-1 basis-52",children:[(0,s.jsx)("label",{htmlFor:"process-search",className:"sr-only",children:"Search processes"}),(0,s.jsx)(k.A,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":!0}),(0,s.jsx)("input",{id:"process-search",type:"search",value:i,onChange:e=>l(e.target.value),placeholder:"Search name, user, PID, or unit",autoComplete:"off",spellCheck:!1,className:"h-9 w-full rounded-md border border-border bg-card-strong py-1.5 pl-8 pr-8 text-sm text-foreground placeholder:text-muted-foreground [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-cancel-button]:[-webkit-appearance:none]"}),i.length>0?(0,s.jsx)("button",{type:"button",onClick:()=>l(""),"aria-label":"Clear search",className:"absolute right-0.5 top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-card hover:text-foreground",children:(0,s.jsx)(M.A,{className:"h-3.5 w-3.5","aria-hidden":!0})}):null]}),(0,s.jsx)("div",{role:"group","aria-label":"Process view",className:"inline-flex shrink-0 rounded-md border border-border p-0.5",children:_.map(e=>{let t=c===e.value;return(0,s.jsx)("button",{type:"button","aria-pressed":t,onClick:()=>u(e.value),className:["rounded px-2.5 py-1 text-xs transition-colors",t?"bg-selected font-medium text-foreground":"text-muted-foreground hover:bg-card-strong hover:text-foreground"].join(" "),children:e.label},e.value)})}),(0,s.jsxs)("button",{type:"button",onClick:()=>n(!r),title:r?"Resume process updates":"Pause process updates",className:"inline-flex min-h-9 shrink-0 items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[r?(0,s.jsx)(N.A,{className:"h-3.5 w-3.5","aria-hidden":!0}):(0,s.jsx)(w.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),r?"Resume":"Pause"]}),(0,s.jsx)(e_,{machine:e,snapshot:b.detail?.snapshot??null,capturedAt:b.detail?.capturedAt??null,receivedAtMs:b.lastReceivedMs,intervalMs:b.intervalMs,phase:b.phase,query:o,mode:c,sort:p,filteredRows:D,sortedRows:L,groups:K,tree:E})]}),(0,s.jsx)(eV,{summary:j,lastReceivedMs:b.lastReceivedMs,intervalMs:b.intervalMs,message:b.message,phase:b.phase,hasSnapshot:Z}),(0,s.jsx)("div",{"aria-busy":G||"acquiring"===b.phase,className:"flex min-h-0 flex-1 flex-col overflow-auto",children:Z?0===D.length?(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 break-words",children:[(0,s.jsx)(d.p,{icon:k.A,note:0===j.shown?"The collector reported no processes in this snapshot.":o.trim().length>0?`No processes match “${H}”.`:"No processes to show.",className:"min-h-64 w-full"}),o.trim().length>0?(0,s.jsxs)("button",{type:"button",onClick:()=>l(""),className:"inline-flex min-h-6 items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,s.jsx)(M.A,{className:"h-3 w-3","aria-hidden":!0}),"Clear search"]}):null]}):(0,s.jsx)(e$,{mode:c,groups:K,rows:L,tree:E,sort:p,onSort:e=>h(t=>(function(e,t){return e.key===t?{key:t,dir:"asc"===e.dir?"desc":"asc"}:{key:t,dir:"name"===t||"user"===t||"pid"===t?"asc":"desc"}})(t,e)),expanded:x,onToggleGroup:e=>{f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}}):(0,s.jsx)(eO,{phase:b.phase,info:z,message:b.message,onRetry:y})})]})})}function eG({waiting:e}){return(0,s.jsx)(d.Z,{title:e?"Waiting for machines":"No machines",className:"mt-2",children:(0,s.jsx)(d.p,{icon:e?i.A:l.A,note:e?"Waiting for the fleet snapshot…":"No machines are available in your authorized fleet."})})}function eY({requested:e}){return(0,s.jsxs)(d.Z,{title:"Machine not found",className:"mt-2",children:[(0,s.jsx)(d.p,{icon:o.A,note:"This machine is unavailable or outside your access."}),(0,s.jsxs)("p",{className:"tnum mt-2 break-all text-center text-xs text-muted-foreground",children:["Requested identifier: ",e]}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(a(),{href:"/",className:"mt-2 inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:"Back to fleet"})})]})}function eX(){let{session:e,phase:t,machines:r}=(0,m.M)(),n=(0,h.x)(),[a,i]=(0,es.u)("processes.paused",!1,em,"session"),{machine:l,navMachineId:o,requestedMachineId:d}=(0,f.JG)("processes"),g="signed-in"===e.kind?e.user.csrfToken:null,x=0===r.length&&("connecting"===t||"idle"===t);return(0,s.jsx)(c.G,{title:"Processes",machineId:o,machineView:"processes",workspace:!0,headerRight:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.$E,{}),(0,s.jsx)(p.B,{})]}),children:n||(0,s.jsx)(s.Fragment,{children:0===r.length?(0,s.jsx)(eG,{waiting:x}):l?(0,s.jsx)(eZ,{machine:l,csrfToken:g,paused:a,onPausedChange:i},`${l.machineId}:${g}`):(0,s.jsx)(eY,{requested:d??""})})})}},7348:(e,t,r)=>{"use strict";r.d(t,{c:()=>n});var s=r(2115);function n(e=1e3){let[t,r]=(0,s.useState)(()=>Date.now());return(0,s.useEffect)(()=>{r(Date.now());let t=setInterval(()=>r(Date.now()),e);return()=>clearInterval(t)},[e]),t}},7499:(e,t,r)=>{"use strict";function s(e,t,r,s){return`rigscope-${e}-${function(e,t="machine"){let r=e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48).replace(/-+$/g,"");return r.length>0?r:t}(t)}-${!Number.isFinite(r)?"unknown-time":new Date(r).toISOString().replace(/[-:]/g,"").replace(/\.\d{3}Z$/,"Z")}.${s}`}r.d(t,{Y8:()=>s})},8528:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},9031:(e,t,r)=>{Promise.resolve().then(r.bind(r,1721)),Promise.resolve().then(r.bind(r,7339)),Promise.resolve().then(r.bind(r,2701)),Promise.resolve().then(r.bind(r,2394))},9664:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]])},9926:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]])},9942:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])}},e=>{e.O(0,[157,939,103,441,794,358],()=>e(e.s=9031)),_N_E=e.O()}]);
package/ARCHITECTURE.md CHANGED
@@ -72,9 +72,30 @@ wire contracts are a real process boundary already.
72
72
  ### Installation and component lifecycle
73
73
 
74
74
  One release contains the hub, collector, UI and administration tools. The install
75
- role is an initial preset; version 2 configuration records independent hub and
76
- collector enablement. Version 1 roles are mapped in memory on read and migrated
77
- on an explicit mutation. Read-only status never rewrites configuration or units.
75
+ role is an initial preset; the canonical configuration records independent hub and
76
+ collector enablement in a required `components` object. Configuration and
77
+ installation state have no schema version fields. Read-only status never rewrites
78
+ configuration or units.
79
+
80
+ Configuration uses one canonical on-disk shape. A pre-canonical installation is
81
+ never migrated: `upgrade` stages and validates the replacement, stops the owned
82
+ hub and collector completely, removes the old configuration and history, and
83
+ installs the latest release fresh. `install` resets detected pre-canonical state
84
+ the same way. There is no rollback to the old format; back up the state directory
85
+ before upgrading if history must be kept. System adoption reads only a canonical
86
+ `config.json`; `hub-config.json` and `collector.json` fallbacks are not read.
87
+
88
+ The low-level manifest installer follows the same rule. Its release manifest and
89
+ `install-state.json` have one canonical shape with no format-version field; an
90
+ unfinished pre-canonical state is rejected with an explicit reset/reinstall
91
+ instruction and is never rewritten. Canonical upgrades retain accounts, history,
92
+ settings and collector identities, and rollback keeps the existing paired-backup
93
+ behaviour.
94
+
95
+ Database migration numbers are the one deliberate exception: `schema_migrations`
96
+ rows order irreversible SQL changes and are not configuration or installation
97
+ state versions. Export payloads, collector state and the hub enrollment state also
98
+ carry no format version; they are validated by shape alone.
78
99
 
79
100
  User installations have separate hashed hub and collector systemd units, each
80
101
  running `rigscope run hub|collector` with its own supervisor lease. System scope
@@ -83,7 +104,7 @@ the other. Each retains its settings, credentials and data when disabled; a
83
104
  collector can continue sending to remote hubs while its local hub is disabled.
84
105
  An unconfigured collector reports Awaiting connection and stays dormant.
85
106
 
86
- The configuration module owns presets, migration and component setup. The service
107
+ The configuration module owns presets, canonical state and component setup. The service
87
108
  module owns systemd control and component service registration. The lifecycle
88
109
  module starts and verifies selected components. Upgrade and rollback coordinate
89
110
  one shared runtime, hold both component leases, back up hub storage and restore
@@ -124,6 +145,11 @@ hub's TLS certificate using ordinary certificate trust. Send credentials in an a
124
145
  header, not a URL. Remote connections require TLS; loopback-only development may explicitly
125
146
  use plaintext. Authenticate first and reject conflicting claimed collector identities.
126
147
 
148
+ The collector and hub use one canonical wire contract and
149
+ `/api/collector/connect` endpoint. There are no protocol-version markers,
150
+ metric-extension negotiations or alternate endpoint migrations. Update the hub
151
+ and its collectors together when replacing an unfinished installation.
152
+
127
153
  JSON message families:
128
154
 
129
155
  - `hello` / `welcome`: capabilities, inventory, hub/session identity.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # Release notes
2
2
 
3
+ ## 0.1.4
4
+
5
+ - Coordinate stopping running user services and owned foreground processes for
6
+ installation, configuration, enrollment and password recovery. Prompt before
7
+ stopping; `--yes` approves without prompting and `--no-restart` leaves the
8
+ installation stopped. Successful changes resume previously running components.
9
+ - **Uninstall now deletes saved data by default**, including accounts, history,
10
+ collector credentials, pending samples and backups. Use `uninstall --keep-data`
11
+ to retain data for reinstalling. `--purge` remains an explicit alias for default
12
+ deletion. Uninstall never restarts processes.
13
+ - Add terminal colors for help, status, warnings and completed actions. Piped
14
+ output and JSON remain plain; `NO_COLOR` disables terminal colors.
15
+ - Avoid extra History GPU cards created by empty historical PCI placeholder
16
+ series. Preserve historical cards that contain readings. Use the system PCI
17
+ name database when available, simplify fallback names and keep PCI addresses
18
+ separate. Normalize NVIDIA PCI domain widths without merging distinct domains.
19
+ - Clarify unavailable GPU counters, including Intel integrated adapters, and
20
+ avoid a last-known badge when no GPU reading is displayed.
21
+ - Update installation and operations documentation and add lifecycle, uninstall,
22
+ terminal output and GPU regression coverage.
23
+
24
+ ## 0.1.3
25
+
26
+ - Replace the unfinished versioned configuration formats with one canonical
27
+ on-disk shape. `config.json` and `system-install.json` require a `components`
28
+ object; collector state, `release-state.json`, `install-state.json`, release
29
+ manifests, package metadata, export documents and hub enrollment state carry
30
+ no format-version field. Adoption reads only a canonical `config.json`;
31
+ `hub-config.json` and `collector.json` fallbacks are not read. There is no
32
+ compatibility reader or in-place migration for the unfinished shapes.
33
+ - Reset pre-canonical installations instead of migrating them. Stop the owned
34
+ hub and collector completely first: the latest CLI stages and validates the
35
+ replacement release, then removes the old configuration and history and
36
+ installs fresh. Run `npx --yes rigscope@latest upgrade` directly, because an
37
+ older installed CLI cannot stage a package without the removed metadata.
38
+ `rigscope install` and detected system installs reset the same way. Back up the
39
+ state directory first if that history must be kept; there is no rollback to the
40
+ old shape. Reset upgrades retain the installation preset, and interrupted
41
+ resets cannot reuse the unfinished runtime on retry.
42
+ - Canonical upgrades still retain accounts, history, settings, collector
43
+ identities and pending samples. Rollback still returns to the retained previous
44
+ canonical runtime with its paired database backup. Database migration numbers
45
+ in `schema_migrations` remain independent implementation details.
46
+ - Use one canonical collector endpoint and wire format. Remove collector-version
47
+ markers, metric-extension negotiation, old-peer payload projection and the old
48
+ endpoint/outbox migration. Hub and collector must use the canonical contract;
49
+ reinstall existing collectors when updating an unfinished installation.
50
+ - Add `rigscope configure --port PORT` to change the local hub port while the
51
+ hub and collector are stopped, updating the colocated collector destination and
52
+ moving its outbox. `--origin` and `--port` cannot be combined; `--local
53
+ --port` is allowed.
54
+
3
55
  ## 0.1.2
4
56
 
5
57
  - Show History downtime shading as soon as the collector disconnects, and stop
@@ -48,5 +100,4 @@ hub federation and clustering are outside this release.
48
100
 
49
101
  See [installation](docs/installation.md) for hardware limits and
50
102
  [scale validation](docs/scale-validation.md) for measured synthetic workloads.
51
- Internal configuration, database and wire-protocol revisions are independent of
52
- the application version.
103
+ Database migration numbers are independent of the application version.
package/README.md CHANGED
@@ -36,6 +36,8 @@ The trial uses separate data and stops with Ctrl+C.
36
36
  | Check services and the dashboard URL | `rigscope status` |
37
37
  | Follow hub logs | `rigscope logs hub --follow` |
38
38
  | Upgrade from npm | `rigscope upgrade` |
39
+ | Delete installation and all saved data | `rigscope uninstall` |
40
+ | Remove installation, preserve saved data | `rigscope uninstall --keep-data` |
39
41
  | Stop or start the installation | `rigscope stop` / `rigscope start` |
40
42
  | Open the dashboard through Tailscale HTTPS | [Set up remote access](docs/installation.md#access-from-another-computer) |
41
43
  | Monitor another machine | [Add a collector](docs/installation.md#add-machines-and-hubs) |