@wrongstack/webui-hq 0.309.0 → 0.310.0
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.
- package/dist/assets/{alerts-CASro-zg.js → alerts-C9eBX9-8.js} +1 -1
- package/dist/assets/{brain-yIDgS4vG.js → brain-CasQFLGW.js} +1 -1
- package/dist/assets/{cockpit-qMcwPuag.js → cockpit-C-PXTlIf.js} +1 -1
- package/dist/assets/{control-YiwRf48C.js → control-BnJmaNmt.js} +1 -1
- package/dist/assets/{cost-EYiQcvHV.js → cost-BHY6zEoU.js} +1 -1
- package/dist/assets/{fleet-map-Chbzo4P_.js → fleet-map-DG8O3br5.js} +1 -1
- package/dist/assets/{fleet-topology-I_zBJHSw.js → fleet-topology-BupZawpq.js} +14 -14
- package/dist/assets/{icons-I81S_8cW.js → icons-Cxo3pc0p.js} +1 -1
- package/dist/assets/{index-C5Ihi44B.js → index-BYuL7DL0.js} +2 -2
- package/dist/assets/index-f4Nn_XLS.css +1 -0
- package/dist/assets/{kanban-ClEZyv0J.js → kanban-FnVQHZcq.js} +1 -1
- package/dist/assets/{live-console-DXTeZHNx.js → live-console-D4fbGyJM.js} +1 -1
- package/dist/assets/{mailbox-Z7GgSK__.js → mailbox-eWAmNL4x.js} +1 -1
- package/dist/assets/markdown-jMopG_H4.js +35 -0
- package/dist/assets/{settings-L17p0Bjr.js → settings-B62Hxx2p.js} +1 -1
- package/dist/assets/trends-DenFCLQy.js +1 -0
- package/dist/assets/{use-backfilled-events-CbvvmZr7.js → use-backfilled-events-CnQ_BlHx.js} +1 -1
- package/dist/assets/{vendor-CWm0VQZ2.js → vendor-ClUhoD-_.js} +1 -1
- package/dist/assets/{worktree-DgKbrwbZ.js → worktree-B4kJFv93.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +10 -9
- package/dist/assets/index-C0hFBKGu.css +0 -1
- package/dist/assets/markdown-C4I0Caum.js +0 -35
- package/dist/assets/trends-B1FxOq-M.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Dt as t,E as n,Ft as r,Mt as i,Nt as a,Xt as o,Zt as s,c,et as l,l as u,n as d,ut as f,xt as p}from"./icons-I81S_8cW.js";import{i as m}from"./markdown-C4I0Caum.js";import{s as h,u as g}from"./index-C5Ihi44B.js";var _=e(s(),1),v=m();function y({task:e,board:n,webuiUrl:i,dependencyTitles:a,onClose:o}){let s=e.dependsOn.map(e=>({id:e,title:a?.get(e)??e.slice(0,8)}));return(0,v.jsxs)(`aside`,{className:`hq-kanban-inspector`,"aria-label":`Task detail`,children:[(0,v.jsxs)(`header`,{className:`hq-kanban-inspector-header`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`span`,{className:`hq-pill ${e.status}`,children:e.status.replaceAll(`_`,` `)}),(0,v.jsx)(`span`,{className:`hq-kanban-priority ${e.priority}`,children:e.priority})]}),(0,v.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`Close inspector`,className:`hq-inspector-close`,children:(0,v.jsx)(d,{size:16})})]}),(0,v.jsx)(`h2`,{className:`hq-kanban-inspector-title`,children:e.title}),(0,v.jsx)(`span`,{className:`hq-mono hq-kanban-inspector-id`,children:e.id}),e.description?(0,v.jsxs)(`section`,{className:`hq-kanban-inspector-section`,children:[(0,v.jsx)(`h3`,{children:`Description`}),(0,v.jsx)(`p`,{className:`hq-kanban-inspector-description`,children:e.description})]}):null,(0,v.jsxs)(`section`,{className:`hq-kanban-inspector-section`,children:[(0,v.jsx)(`h3`,{children:`Details`}),(0,v.jsxs)(`dl`,{className:`hq-kanban-inspector-details`,children:[(0,v.jsxs)(`div`,{className:`hq-kanban-inspector-row`,children:[(0,v.jsxs)(`dt`,{children:[(0,v.jsx)(l,{size:13}),`Board`]}),(0,v.jsx)(`dd`,{children:n.title})]}),e.assignee?(0,v.jsxs)(`div`,{className:`hq-kanban-inspector-row`,children:[(0,v.jsxs)(`dt`,{children:[(0,v.jsx)(c,{size:13}),`Assignee`]}),(0,v.jsxs)(`dd`,{children:[e.assignee,e.assignmentStatus?(0,v.jsxs)(`span`,{className:`hq-mono`,style:{marginLeft:6,opacity:.7},children:[`(`,e.assignmentStatus,`)`]}):null]})]}):null,e.dueDate?(0,v.jsxs)(`div`,{className:`hq-kanban-inspector-row`,children:[(0,v.jsxs)(`dt`,{children:[(0,v.jsx)(t,{size:13}),`Due`]}),(0,v.jsx)(`dd`,{children:new Date(e.dueDate).toLocaleString()})]}):null,e.columnId?(0,v.jsxs)(`div`,{className:`hq-kanban-inspector-row`,children:[(0,v.jsxs)(`dt`,{children:[(0,v.jsx)(l,{size:13}),`Column`]}),(0,v.jsx)(`dd`,{children:n.columns.find(t=>t.id===e.columnId)?.title??e.columnId})]}):null]})]}),e.labels.length>0?(0,v.jsxs)(`section`,{className:`hq-kanban-inspector-section`,children:[(0,v.jsx)(`h3`,{children:`Labels`}),(0,v.jsx)(`div`,{className:`hq-kanban-inspector-labels`,children:e.labels.map(e=>(0,v.jsx)(`span`,{className:`hq-pill info`,children:e},e))})]}):null,s.length>0?(0,v.jsxs)(`section`,{className:`hq-kanban-inspector-section`,children:[(0,v.jsxs)(`h3`,{children:[(0,v.jsx)(f,{size:13}),`Dependencies (`,s.length,`)`]}),(0,v.jsx)(`ul`,{className:`hq-kanban-inspector-deps`,children:s.map(t=>(0,v.jsxs)(`li`,{children:[(0,v.jsx)(`span`,{className:`hq-mono`,children:t.id.slice(0,8)}),(0,v.jsx)(`span`,{children:t.title}),e.status===`completed`?(0,v.jsx)(r,{size:13,className:`is-done`}):null]},t.id))})]}):null,e.status===`blocked`||e.status===`failed`?(0,v.jsxs)(`div`,{className:`hq-kanban-inspector-alert`,children:[(0,v.jsx)(u,{size:14}),(0,v.jsxs)(`span`,{children:[`This task is `,e.status,` and may need attention.`]})]}):null,i?(0,v.jsx)(`footer`,{className:`hq-kanban-inspector-footer`,children:(0,v.jsxs)(`a`,{href:i,target:`_blank`,rel:`noopener noreferrer`,className:`hq-button hq-button-primary`,children:[(0,v.jsx)(p,{size:14}),`Open in WebUI`]})}):null]})}function b({board:e}){let n=x(e),s=n.blocked===0&&n.failed===0;return(0,v.jsxs)(`div`,{className:`hq-kanban-queue-health`,role:`status`,"aria-label":`Queue health`,children:[(0,v.jsx)(`span`,{className:`hq-kanban-qh-label`,children:`Queue health`}),n.startable>0?(0,v.jsxs)(`span`,{className:`hq-kanban-qh-pill ready`,title:`Claimable tasks`,children:[(0,v.jsx)(i,{size:12}),n.startable,` ready`]}):null,n.running>0?(0,v.jsxs)(`span`,{className:`hq-kanban-qh-pill running`,title:`Running assignments`,children:[(0,v.jsx)(o,{size:12}),n.running,` running`]}):null,n.review>0?(0,v.jsxs)(`span`,{className:`hq-kanban-qh-pill review`,title:`In review`,children:[(0,v.jsx)(t,{size:12}),n.review,` review`]}):null,n.blocked>0?(0,v.jsxs)(`span`,{className:`hq-kanban-qh-pill blocked`,title:`Manually blocked`,children:[(0,v.jsx)(a,{size:12}),n.blocked,` blocked`]}):null,n.failed>0?(0,v.jsxs)(`span`,{className:`hq-kanban-qh-pill failed`,title:`Failed tasks`,children:[(0,v.jsx)(u,{size:12}),n.failed,` failed`]}):null,s?(0,v.jsxs)(`span`,{className:`hq-kanban-qh-pill healthy`,title:`No issues detected`,children:[(0,v.jsx)(r,{size:12}),`healthy`]}):null]})}function x(e){let t={startable:0,running:0,review:0,blocked:0,failed:0},n=new Set;for(let t of e.columns)for(let e of t.tasks)e.status===`completed`&&n.add(e.id);for(let r of e.columns)for(let e of r.tasks){let r=e.assignmentStatus===`running`||e.assignmentStatus===`queued`;switch((e.status===`in_progress`||e.assignmentStatus===`running`)&&t.running++,!r&&(e.status===`pending`||e.status===`ready`)&&e.dependsOn.every(e=>n.has(e))&&t.startable++,e.status){case`review`:t.review++;break;case`blocked`:t.blocked++;break;case`failed`:t.failed++}}return t}var S=new Set([`low`,`medium`,`high`,`critical`]),C=new Set([`pending`,`ready`,`in_progress`,`review`,`completed`,`blocked`,`failed`,`archived`]);function w(e){return`/api/projects/${encodeURIComponent(e)}/kanban`}function T(e){return e.boards.map(e=>E(e)).filter(e=>e!==null).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))}function E(e){let t=e.board;if(t.id!==e.boardId)return null;let n=k(t.columns).map(D).filter(e=>e!==null),r=k(t.tasks).map(O).filter(e=>e!==null),i=new Set(n.map(e=>e.id)),a=new Set(r.map(e=>e.columnId).filter(e=>!i.has(e)));for(let e of a)n.push({id:e,title:e.length>0?e:`Unmapped`,order:2**53-1});let o=n.sort((e,t)=>e.order-t.order||e.title.localeCompare(t.title)).map(e=>({...e,tasks:r.filter(t=>t.columnId===e.id).sort((e,t)=>e.order-t.order||e.title.localeCompare(t.title))}));return{id:e.boardId,title:M(t.title)??e.boardId,description:M(t.description),tags:j(t.tags),revision:e.revision,updatedAt:e.updatedAt,activePresence:k(t.presence).filter(e=>e.active===!0).length,taskCount:r.length,completedTaskCount:r.filter(e=>e.status===`completed`).length,activeTaskCount:r.filter(e=>e.status===`in_progress`||e.status===`review`).length,blockedTaskCount:r.filter(e=>e.status===`blocked`||e.status===`failed`).length,columns:o}}function D(e){let t=M(e.id),n=M(e.title);return!t||!n?null:{id:t,title:n,color:M(e.color),order:N(e.order)??0,wipLimit:N(e.wipLimit)}}function O(e){let t=M(e.id),n=M(e.title),r=M(e.columnId);if(!t||!n||r===void 0)return null;let i=A(e.assignment);return{id:t,title:n,description:M(e.description),columnId:r,order:N(e.order)??0,priority:P(e.priority,S)??`medium`,status:P(e.status,C)??`pending`,assignee:M(e.assignee)??M(e.assignedAgent)??M(i?.name)??M(i?.agentId),assignmentStatus:M(i?.status),labels:j(e.labels),dependsOn:j(e.dependsOn),dueDate:M(e.dueDate)}}function k(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&!Array.isArray(e)):[]}function A(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function j(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function M(e){return typeof e==`string`?e:void 0}function N(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function P(e,t){return typeof e==`string`&&t.has(e)?e:void 0}var F=1e4,I=[];function L(){let e=g(e=>e.snapshot?.projects??I),t=g(e=>{for(let t=e.events.length-1;t>=0;t--){let n=e.events[t];if(n?.type===`kanban.snapshot`)return n.id}return null}),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(null),[l,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),[m,x]=(0,_.useState)(null),S=(0,_.useRef)(0),C=(0,_.useRef)(t);(0,_.useEffect)(()=>{if(e.length===0){i(``),c(null);return}e.some(e=>e.projectId===r)||i(e[0].projectId)},[r,e]);let E=(0,_.useCallback)(async(e=!1)=>{if(!r)return;let t=++S.current;e?d(!0):p(!0);try{let e=await h(w(r));if(t!==S.current)return;c(e),x(null)}catch(e){if(t!==S.current)return;x(e instanceof Error?e.message:String(e))}finally{t===S.current&&(d(!1),p(!1))}},[r]);(0,_.useEffect)(()=>{S.current++,c(null),o(``),x(null)},[r]),(0,_.useEffect)(()=>{if(!r)return;E(!0);let e=window.setInterval(()=>void E(!1),F);return()=>{S.current++,window.clearInterval(e)}},[E,r]),(0,_.useEffect)(()=>{t!==null&&t!==C.current&&(C.current=t,r&&E(!1))},[t,E,r]);let D=(0,_.useMemo)(()=>s?T(s):[],[s]);(0,_.useEffect)(()=>{D.length===0?o(``):D.some(e=>e.id===a)||o(D[0].id)},[a,D]);let O=D.find(e=>e.id===a)??null,k=e.find(e=>e.projectId===r)??null,[A,j]=(0,_.useState)(null);(0,_.useEffect)(()=>{j(null)},[a]);let M=(0,_.useMemo)(()=>{if(!O||!A)return null;for(let e of O.columns){let t=e.tasks.find(e=>e.id===A);if(t)return t}return null},[O,A]),N=(0,_.useMemo)(()=>{if(!O)return new Map;let e=new Map;for(let t of O.columns)for(let n of t.tasks)e.set(n.id,n.title);return e},[O]);return e.length===0?(0,v.jsx)(`div`,{className:`hq-empty`,children:`No HQ projects are available. Connect a WrongStack client to publish its project identity and Kanban snapshot.`}):(0,v.jsxs)(`div`,{className:`hq-kanban-view`,children:[(0,v.jsx)(R,{projects:e,projectId:r,onProjectChange:e=>i(e),boards:D,boardId:a,onBoardChange:o,generatedAt:s?.generatedAt,refreshing:f,onRefresh:()=>void E(!1)}),m?(0,v.jsxs)(`div`,{className:`hq-kanban-error`,role:`alert`,children:[(0,v.jsx)(u,{size:15}),(0,v.jsx)(`span`,{children:m}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>void E(!0),children:`Retry`})]}):null,l&&s===null?(0,v.jsxs)(`div`,{className:`hq-view-loading`,role:`status`,children:[(0,v.jsx)(n,{size:18}),(0,v.jsx)(`span`,{children:`Loading project boards…`})]}):O?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(z,{project:k,board:O,boardCount:D.length}),(0,v.jsx)(b,{board:O}),(0,v.jsxs)(`div`,{className:`hq-kanban-main`,children:[(0,v.jsx)(V,{board:O,onTaskClick:j,selectedTaskId:A}),M?(0,v.jsx)(y,{task:M,board:O,dependencyTitles:N,onClose:()=>j(null)}):null]})]}):(0,v.jsxs)(`div`,{className:`hq-empty`,children:[`This project has not published a Kanban board yet. Create one with `,(0,v.jsx)(`code`,{children:`/kanban`}),` `,`from any connected clone.`]})]})}function R({projects:e,projectId:t,onProjectChange:r,boards:i,boardId:a,onBoardChange:o,generatedAt:s,refreshing:c,onRefresh:l}){return(0,v.jsxs)(`div`,{className:`hq-kanban-toolbar`,children:[(0,v.jsxs)(`label`,{children:[(0,v.jsx)(`span`,{children:`Project`}),(0,v.jsx)(`select`,{className:`hq-select`,"aria-label":`Kanban project`,value:t,onChange:e=>r(e.target.value),children:e.map(e=>(0,v.jsx)(`option`,{value:e.projectId,children:e.projectName},e.projectId))})]}),(0,v.jsxs)(`label`,{children:[(0,v.jsx)(`span`,{children:`Board`}),(0,v.jsxs)(`select`,{className:`hq-select`,"aria-label":`Kanban board`,value:a,disabled:i.length===0,onChange:e=>o(e.target.value),children:[i.length===0?(0,v.jsx)(`option`,{value:``,children:`No boards`}):null,i.map(e=>(0,v.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,v.jsxs)(`div`,{className:`hq-kanban-sync`,children:[(0,v.jsx)(`span`,{children:s?`Synced ${W(s)}`:`Waiting for snapshot`}),(0,v.jsxs)(`button`,{type:`button`,onClick:l,disabled:c,"aria-label":`Refresh Kanban`,children:[(0,v.jsx)(n,{size:14,className:c?`is-spinning`:void 0}),`Refresh`]})]})]})}function z({project:e,board:t,boardCount:n}){return(0,v.jsxs)(`section`,{className:`hq-kanban-summary`,children:[(0,v.jsxs)(`div`,{className:`hq-kanban-heading`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsxs)(`span`,{children:[e?.projectName??`Project`,` · Kanban`]}),(0,v.jsx)(`h2`,{children:t.title}),t.description?(0,v.jsx)(`p`,{children:t.description}):null]}),(0,v.jsxs)(`div`,{className:`hq-kanban-board-meta`,children:[(0,v.jsxs)(`span`,{className:`hq-mono`,children:[`rev `,t.revision]}),(0,v.jsx)(`span`,{children:W(t.updatedAt)}),t.activePresence>0?(0,v.jsxs)(`span`,{className:`hq-pill active`,children:[t.activePresence,` active`]}):null]})]}),t.tags.length>0?(0,v.jsx)(`div`,{className:`hq-kanban-tags`,children:t.tags.map(e=>(0,v.jsx)(`span`,{className:`hq-pill info`,children:e},e))}):null,(0,v.jsxs)(`div`,{className:`hq-kanban-stats`,children:[(0,v.jsx)(B,{label:`Boards`,value:n}),(0,v.jsx)(B,{label:`Tasks`,value:t.taskCount}),(0,v.jsx)(B,{label:`Active`,value:t.activeTaskCount,tone:`active`}),(0,v.jsx)(B,{label:`Blocked`,value:t.blockedTaskCount,tone:`blocked`}),(0,v.jsx)(B,{label:`Done`,value:t.completedTaskCount,tone:`done`})]})]})}function B({label:e,value:t,tone:n}){return(0,v.jsxs)(`div`,{className:`hq-kanban-stat`,"data-tone":n,children:[(0,v.jsx)(`strong`,{children:t}),(0,v.jsx)(`span`,{children:e})]})}function V({board:e,onTaskClick:t,selectedTaskId:n}){return e.columns.length===0?(0,v.jsx)(`div`,{className:`hq-empty`,children:`This board does not have any columns yet.`}):(0,v.jsx)(`section`,{className:`hq-kanban-board`,"aria-label":`${e.title} Kanban board`,style:{"--hq-kanban-columns":Math.max(1,e.columns.length)},children:e.columns.map(e=>{let r=e.wipLimit!==void 0&&e.tasks.filter(e=>e.status!==`completed`).length>e.wipLimit;return(0,v.jsxs)(`div`,{className:`hq-kanban-column`,"data-over-limit":r,children:[(0,v.jsxs)(`header`,{style:e.color?{borderTopColor:e.color}:void 0,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`strong`,{children:e.title}),e.wipLimit===void 0?null:(0,v.jsxs)(`span`,{children:[`WIP `,e.tasks.length,`/`,e.wipLimit]})]}),(0,v.jsx)(`span`,{className:`hq-kanban-column-count`,children:e.tasks.length})]}),(0,v.jsx)(`div`,{className:`hq-kanban-column-body`,children:e.tasks.length===0?(0,v.jsx)(`div`,{className:`hq-kanban-column-empty`,children:`No cards`}):e.tasks.map(e=>(0,v.jsx)(H,{task:e,isSelected:e.id===n,onClick:()=>t(e.id)},e.id))})]},e.id)})})}function H({task:e,isSelected:n=!1,onClick:i}){return(0,v.jsxs)(`button`,{type:`button`,className:`hq-kanban-task`,"data-priority":e.priority,"data-selected":n,onClick:i,children:[(0,v.jsxs)(`div`,{className:`hq-kanban-task-topline`,children:[(0,v.jsx)(`span`,{className:`hq-pill ${e.status}`,children:e.status.replaceAll(`_`,` `)}),(0,v.jsx)(`span`,{className:`hq-kanban-priority ${e.priority}`,children:e.priority})]}),(0,v.jsx)(`h3`,{children:e.title}),e.description?(0,v.jsx)(`p`,{children:e.description}):null,e.labels.length>0?(0,v.jsx)(`div`,{className:`hq-kanban-task-labels`,children:e.labels.slice(0,4).map(e=>(0,v.jsx)(`span`,{children:e},e))}):null,(0,v.jsxs)(`footer`,{children:[e.assignee?(0,v.jsxs)(`span`,{title:e.assignmentStatus??`assigned`,children:[(0,v.jsx)(c,{size:12}),e.assignee]}):null,e.dependsOn.length>0?(0,v.jsxs)(`span`,{title:`${e.dependsOn.length} dependencies`,children:[(0,v.jsx)(f,{size:12}),e.dependsOn.length]}):null,e.dueDate?(0,v.jsxs)(`span`,{title:`Due ${new Date(e.dueDate).toLocaleString()}`,children:[(0,v.jsx)(t,{size:12}),U(e.dueDate)]}):null,e.status===`completed`?(0,v.jsx)(r,{size:13,className:`is-done`}):null]})]})}function U(e){let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleDateString(void 0,{month:`short`,day:`numeric`}):e}function W(e){let t=Date.parse(e);if(!Number.isFinite(t))return e;let n=Math.max(0,Math.floor((Date.now()-t)/1e3));if(n<10)return`just now`;if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}export{L as KanbanView};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Dt as t,E as n,Ft as r,Mt as i,Nt as a,Xt as o,Zt as s,c,et as l,l as u,n as d,ut as f,xt as p}from"./icons-Cxo3pc0p.js";import{i as m}from"./markdown-jMopG_H4.js";import{s as h,u as g}from"./index-BYuL7DL0.js";var _=e(s(),1),v=m();function y({task:e,board:n,webuiUrl:i,dependencyTitles:a,onClose:o}){let s=e.dependsOn.map(e=>({id:e,title:a?.get(e)??e.slice(0,8)}));return(0,v.jsxs)(`aside`,{className:`hq-kanban-inspector`,"aria-label":`Task detail`,children:[(0,v.jsxs)(`header`,{className:`hq-kanban-inspector-header`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`span`,{className:`hq-pill ${e.status}`,children:e.status.replaceAll(`_`,` `)}),(0,v.jsx)(`span`,{className:`hq-kanban-priority ${e.priority}`,children:e.priority})]}),(0,v.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`Close inspector`,className:`hq-inspector-close`,children:(0,v.jsx)(d,{size:16})})]}),(0,v.jsx)(`h2`,{className:`hq-kanban-inspector-title`,children:e.title}),(0,v.jsx)(`span`,{className:`hq-mono hq-kanban-inspector-id`,children:e.id}),e.description?(0,v.jsxs)(`section`,{className:`hq-kanban-inspector-section`,children:[(0,v.jsx)(`h3`,{children:`Description`}),(0,v.jsx)(`p`,{className:`hq-kanban-inspector-description`,children:e.description})]}):null,(0,v.jsxs)(`section`,{className:`hq-kanban-inspector-section`,children:[(0,v.jsx)(`h3`,{children:`Details`}),(0,v.jsxs)(`dl`,{className:`hq-kanban-inspector-details`,children:[(0,v.jsxs)(`div`,{className:`hq-kanban-inspector-row`,children:[(0,v.jsxs)(`dt`,{children:[(0,v.jsx)(l,{size:13}),`Board`]}),(0,v.jsx)(`dd`,{children:n.title})]}),e.assignee?(0,v.jsxs)(`div`,{className:`hq-kanban-inspector-row`,children:[(0,v.jsxs)(`dt`,{children:[(0,v.jsx)(c,{size:13}),`Assignee`]}),(0,v.jsxs)(`dd`,{children:[e.assignee,e.assignmentStatus?(0,v.jsxs)(`span`,{className:`hq-mono`,style:{marginLeft:6,opacity:.7},children:[`(`,e.assignmentStatus,`)`]}):null]})]}):null,e.dueDate?(0,v.jsxs)(`div`,{className:`hq-kanban-inspector-row`,children:[(0,v.jsxs)(`dt`,{children:[(0,v.jsx)(t,{size:13}),`Due`]}),(0,v.jsx)(`dd`,{children:new Date(e.dueDate).toLocaleString()})]}):null,e.columnId?(0,v.jsxs)(`div`,{className:`hq-kanban-inspector-row`,children:[(0,v.jsxs)(`dt`,{children:[(0,v.jsx)(l,{size:13}),`Column`]}),(0,v.jsx)(`dd`,{children:n.columns.find(t=>t.id===e.columnId)?.title??e.columnId})]}):null]})]}),e.labels.length>0?(0,v.jsxs)(`section`,{className:`hq-kanban-inspector-section`,children:[(0,v.jsx)(`h3`,{children:`Labels`}),(0,v.jsx)(`div`,{className:`hq-kanban-inspector-labels`,children:e.labels.map(e=>(0,v.jsx)(`span`,{className:`hq-pill info`,children:e},e))})]}):null,s.length>0?(0,v.jsxs)(`section`,{className:`hq-kanban-inspector-section`,children:[(0,v.jsxs)(`h3`,{children:[(0,v.jsx)(f,{size:13}),`Dependencies (`,s.length,`)`]}),(0,v.jsx)(`ul`,{className:`hq-kanban-inspector-deps`,children:s.map(t=>(0,v.jsxs)(`li`,{children:[(0,v.jsx)(`span`,{className:`hq-mono`,children:t.id.slice(0,8)}),(0,v.jsx)(`span`,{children:t.title}),e.status===`completed`?(0,v.jsx)(r,{size:13,className:`is-done`}):null]},t.id))})]}):null,e.status===`blocked`||e.status===`failed`?(0,v.jsxs)(`div`,{className:`hq-kanban-inspector-alert`,children:[(0,v.jsx)(u,{size:14}),(0,v.jsxs)(`span`,{children:[`This task is `,e.status,` and may need attention.`]})]}):null,i?(0,v.jsx)(`footer`,{className:`hq-kanban-inspector-footer`,children:(0,v.jsxs)(`a`,{href:i,target:`_blank`,rel:`noopener noreferrer`,className:`hq-button hq-button-primary`,children:[(0,v.jsx)(p,{size:14}),`Open in WebUI`]})}):null]})}function b({board:e}){let n=x(e),s=n.blocked===0&&n.failed===0;return(0,v.jsxs)(`div`,{className:`hq-kanban-queue-health`,role:`status`,"aria-label":`Queue health`,children:[(0,v.jsx)(`span`,{className:`hq-kanban-qh-label`,children:`Queue health`}),n.startable>0?(0,v.jsxs)(`span`,{className:`hq-kanban-qh-pill ready`,title:`Claimable tasks`,children:[(0,v.jsx)(i,{size:12}),n.startable,` ready`]}):null,n.running>0?(0,v.jsxs)(`span`,{className:`hq-kanban-qh-pill running`,title:`Running assignments`,children:[(0,v.jsx)(o,{size:12}),n.running,` running`]}):null,n.review>0?(0,v.jsxs)(`span`,{className:`hq-kanban-qh-pill review`,title:`In review`,children:[(0,v.jsx)(t,{size:12}),n.review,` review`]}):null,n.blocked>0?(0,v.jsxs)(`span`,{className:`hq-kanban-qh-pill blocked`,title:`Manually blocked`,children:[(0,v.jsx)(a,{size:12}),n.blocked,` blocked`]}):null,n.failed>0?(0,v.jsxs)(`span`,{className:`hq-kanban-qh-pill failed`,title:`Failed tasks`,children:[(0,v.jsx)(u,{size:12}),n.failed,` failed`]}):null,s?(0,v.jsxs)(`span`,{className:`hq-kanban-qh-pill healthy`,title:`No issues detected`,children:[(0,v.jsx)(r,{size:12}),`healthy`]}):null]})}function x(e){let t={startable:0,running:0,review:0,blocked:0,failed:0},n=new Set;for(let t of e.columns)for(let e of t.tasks)e.status===`completed`&&n.add(e.id);for(let r of e.columns)for(let e of r.tasks){let r=e.assignmentStatus===`running`||e.assignmentStatus===`queued`;switch((e.status===`in_progress`||e.assignmentStatus===`running`)&&t.running++,!r&&(e.status===`pending`||e.status===`ready`)&&e.dependsOn.every(e=>n.has(e))&&t.startable++,e.status){case`review`:t.review++;break;case`blocked`:t.blocked++;break;case`failed`:t.failed++}}return t}var S=new Set([`low`,`medium`,`high`,`critical`]),C=new Set([`pending`,`ready`,`in_progress`,`review`,`completed`,`blocked`,`failed`,`archived`]);function w(e){return`/api/projects/${encodeURIComponent(e)}/kanban`}function T(e){return e.boards.map(e=>E(e)).filter(e=>e!==null).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))}function E(e){let t=e.board;if(t.id!==e.boardId)return null;let n=k(t.columns).map(D).filter(e=>e!==null),r=k(t.tasks).map(O).filter(e=>e!==null),i=new Set(n.map(e=>e.id)),a=new Set(r.map(e=>e.columnId).filter(e=>!i.has(e)));for(let e of a)n.push({id:e,title:e.length>0?e:`Unmapped`,order:2**53-1});let o=n.sort((e,t)=>e.order-t.order||e.title.localeCompare(t.title)).map(e=>({...e,tasks:r.filter(t=>t.columnId===e.id).sort((e,t)=>e.order-t.order||e.title.localeCompare(t.title))}));return{id:e.boardId,title:M(t.title)??e.boardId,description:M(t.description),tags:j(t.tags),revision:e.revision,updatedAt:e.updatedAt,activePresence:k(t.presence).filter(e=>e.active===!0).length,taskCount:r.length,completedTaskCount:r.filter(e=>e.status===`completed`).length,activeTaskCount:r.filter(e=>e.status===`in_progress`||e.status===`review`).length,blockedTaskCount:r.filter(e=>e.status===`blocked`||e.status===`failed`).length,columns:o}}function D(e){let t=M(e.id),n=M(e.title);return!t||!n?null:{id:t,title:n,color:M(e.color),order:N(e.order)??0,wipLimit:N(e.wipLimit)}}function O(e){let t=M(e.id),n=M(e.title),r=M(e.columnId);if(!t||!n||r===void 0)return null;let i=A(e.assignment);return{id:t,title:n,description:M(e.description),columnId:r,order:N(e.order)??0,priority:P(e.priority,S)??`medium`,status:P(e.status,C)??`pending`,assignee:M(e.assignee)??M(e.assignedAgent)??M(i?.name)??M(i?.agentId),assignmentStatus:M(i?.status),labels:j(e.labels),dependsOn:j(e.dependsOn),dueDate:M(e.dueDate)}}function k(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&!Array.isArray(e)):[]}function A(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function j(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function M(e){return typeof e==`string`?e:void 0}function N(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function P(e,t){return typeof e==`string`&&t.has(e)?e:void 0}var F=1e4,I=[];function L(){let e=g(e=>e.snapshot?.projects??I),t=g(e=>{for(let t=e.events.length-1;t>=0;t--){let n=e.events[t];if(n?.type===`kanban.snapshot`)return n.id}return null}),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)(null),[l,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(!1),[m,x]=(0,_.useState)(null),S=(0,_.useRef)(0),C=(0,_.useRef)(t);(0,_.useEffect)(()=>{if(e.length===0){i(``),c(null);return}e.some(e=>e.projectId===r)||i(e[0].projectId)},[r,e]);let E=(0,_.useCallback)(async(e=!1)=>{if(!r)return;let t=++S.current;e?d(!0):p(!0);try{let e=await h(w(r));if(t!==S.current)return;c(e),x(null)}catch(e){if(t!==S.current)return;x(e instanceof Error?e.message:String(e))}finally{t===S.current&&(d(!1),p(!1))}},[r]);(0,_.useEffect)(()=>{S.current++,c(null),o(``),x(null)},[r]),(0,_.useEffect)(()=>{if(!r)return;E(!0);let e=window.setInterval(()=>void E(!1),F);return()=>{S.current++,window.clearInterval(e)}},[E,r]),(0,_.useEffect)(()=>{t!==null&&t!==C.current&&(C.current=t,r&&E(!1))},[t,E,r]);let D=(0,_.useMemo)(()=>s?T(s):[],[s]);(0,_.useEffect)(()=>{D.length===0?o(``):D.some(e=>e.id===a)||o(D[0].id)},[a,D]);let O=D.find(e=>e.id===a)??null,k=e.find(e=>e.projectId===r)??null,[A,j]=(0,_.useState)(null);(0,_.useEffect)(()=>{j(null)},[a]);let M=(0,_.useMemo)(()=>{if(!O||!A)return null;for(let e of O.columns){let t=e.tasks.find(e=>e.id===A);if(t)return t}return null},[O,A]),N=(0,_.useMemo)(()=>{if(!O)return new Map;let e=new Map;for(let t of O.columns)for(let n of t.tasks)e.set(n.id,n.title);return e},[O]);return e.length===0?(0,v.jsx)(`div`,{className:`hq-empty`,children:`No HQ projects are available. Connect a WrongStack client to publish its project identity and Kanban snapshot.`}):(0,v.jsxs)(`div`,{className:`hq-kanban-view`,children:[(0,v.jsx)(R,{projects:e,projectId:r,onProjectChange:e=>i(e),boards:D,boardId:a,onBoardChange:o,generatedAt:s?.generatedAt,refreshing:f,onRefresh:()=>void E(!1)}),m?(0,v.jsxs)(`div`,{className:`hq-kanban-error`,role:`alert`,children:[(0,v.jsx)(u,{size:15}),(0,v.jsx)(`span`,{children:m}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>void E(!0),children:`Retry`})]}):null,l&&s===null?(0,v.jsxs)(`div`,{className:`hq-view-loading`,role:`status`,children:[(0,v.jsx)(n,{size:18}),(0,v.jsx)(`span`,{children:`Loading project boards…`})]}):O?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(z,{project:k,board:O,boardCount:D.length}),(0,v.jsx)(b,{board:O}),(0,v.jsxs)(`div`,{className:`hq-kanban-main`,children:[(0,v.jsx)(V,{board:O,onTaskClick:j,selectedTaskId:A}),M?(0,v.jsx)(y,{task:M,board:O,dependencyTitles:N,onClose:()=>j(null)}):null]})]}):(0,v.jsxs)(`div`,{className:`hq-empty`,children:[`This project has not published a Kanban board yet. Create one with `,(0,v.jsx)(`code`,{children:`/kanban`}),` `,`from any connected clone.`]})]})}function R({projects:e,projectId:t,onProjectChange:r,boards:i,boardId:a,onBoardChange:o,generatedAt:s,refreshing:c,onRefresh:l}){return(0,v.jsxs)(`div`,{className:`hq-kanban-toolbar`,children:[(0,v.jsxs)(`label`,{children:[(0,v.jsx)(`span`,{children:`Project`}),(0,v.jsx)(`select`,{className:`hq-select`,"aria-label":`Kanban project`,value:t,onChange:e=>r(e.target.value),children:e.map(e=>(0,v.jsx)(`option`,{value:e.projectId,children:e.projectName},e.projectId))})]}),(0,v.jsxs)(`label`,{children:[(0,v.jsx)(`span`,{children:`Board`}),(0,v.jsxs)(`select`,{className:`hq-select`,"aria-label":`Kanban board`,value:a,disabled:i.length===0,onChange:e=>o(e.target.value),children:[i.length===0?(0,v.jsx)(`option`,{value:``,children:`No boards`}):null,i.map(e=>(0,v.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,v.jsxs)(`div`,{className:`hq-kanban-sync`,children:[(0,v.jsx)(`span`,{children:s?`Synced ${W(s)}`:`Waiting for snapshot`}),(0,v.jsxs)(`button`,{type:`button`,onClick:l,disabled:c,"aria-label":`Refresh Kanban`,children:[(0,v.jsx)(n,{size:14,className:c?`is-spinning`:void 0}),`Refresh`]})]})]})}function z({project:e,board:t,boardCount:n}){return(0,v.jsxs)(`section`,{className:`hq-kanban-summary`,children:[(0,v.jsxs)(`div`,{className:`hq-kanban-heading`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsxs)(`span`,{children:[e?.projectName??`Project`,` · Kanban`]}),(0,v.jsx)(`h2`,{children:t.title}),t.description?(0,v.jsx)(`p`,{children:t.description}):null]}),(0,v.jsxs)(`div`,{className:`hq-kanban-board-meta`,children:[(0,v.jsxs)(`span`,{className:`hq-mono`,children:[`rev `,t.revision]}),(0,v.jsx)(`span`,{children:W(t.updatedAt)}),t.activePresence>0?(0,v.jsxs)(`span`,{className:`hq-pill active`,children:[t.activePresence,` active`]}):null]})]}),t.tags.length>0?(0,v.jsx)(`div`,{className:`hq-kanban-tags`,children:t.tags.map(e=>(0,v.jsx)(`span`,{className:`hq-pill info`,children:e},e))}):null,(0,v.jsxs)(`div`,{className:`hq-kanban-stats`,children:[(0,v.jsx)(B,{label:`Boards`,value:n}),(0,v.jsx)(B,{label:`Tasks`,value:t.taskCount}),(0,v.jsx)(B,{label:`Active`,value:t.activeTaskCount,tone:`active`}),(0,v.jsx)(B,{label:`Blocked`,value:t.blockedTaskCount,tone:`blocked`}),(0,v.jsx)(B,{label:`Done`,value:t.completedTaskCount,tone:`done`})]})]})}function B({label:e,value:t,tone:n}){return(0,v.jsxs)(`div`,{className:`hq-kanban-stat`,"data-tone":n,children:[(0,v.jsx)(`strong`,{children:t}),(0,v.jsx)(`span`,{children:e})]})}function V({board:e,onTaskClick:t,selectedTaskId:n}){return e.columns.length===0?(0,v.jsx)(`div`,{className:`hq-empty`,children:`This board does not have any columns yet.`}):(0,v.jsx)(`section`,{className:`hq-kanban-board`,"aria-label":`${e.title} Kanban board`,style:{"--hq-kanban-columns":Math.max(1,e.columns.length)},children:e.columns.map(e=>{let r=e.wipLimit!==void 0&&e.tasks.filter(e=>e.status!==`completed`).length>e.wipLimit;return(0,v.jsxs)(`div`,{className:`hq-kanban-column`,"data-over-limit":r,children:[(0,v.jsxs)(`header`,{style:e.color?{borderTopColor:e.color}:void 0,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`strong`,{children:e.title}),e.wipLimit===void 0?null:(0,v.jsxs)(`span`,{children:[`WIP `,e.tasks.length,`/`,e.wipLimit]})]}),(0,v.jsx)(`span`,{className:`hq-kanban-column-count`,children:e.tasks.length})]}),(0,v.jsx)(`div`,{className:`hq-kanban-column-body`,children:e.tasks.length===0?(0,v.jsx)(`div`,{className:`hq-kanban-column-empty`,children:`No cards`}):e.tasks.map(e=>(0,v.jsx)(H,{task:e,isSelected:e.id===n,onClick:()=>t(e.id)},e.id))})]},e.id)})})}function H({task:e,isSelected:n=!1,onClick:i}){return(0,v.jsxs)(`button`,{type:`button`,className:`hq-kanban-task`,"data-priority":e.priority,"data-selected":n,onClick:i,children:[(0,v.jsxs)(`div`,{className:`hq-kanban-task-topline`,children:[(0,v.jsx)(`span`,{className:`hq-pill ${e.status}`,children:e.status.replaceAll(`_`,` `)}),(0,v.jsx)(`span`,{className:`hq-kanban-priority ${e.priority}`,children:e.priority})]}),(0,v.jsx)(`h3`,{children:e.title}),e.description?(0,v.jsx)(`p`,{children:e.description}):null,e.labels.length>0?(0,v.jsx)(`div`,{className:`hq-kanban-task-labels`,children:e.labels.slice(0,4).map(e=>(0,v.jsx)(`span`,{children:e},e))}):null,(0,v.jsxs)(`footer`,{children:[e.assignee?(0,v.jsxs)(`span`,{title:e.assignmentStatus??`assigned`,children:[(0,v.jsx)(c,{size:12}),e.assignee]}):null,e.dependsOn.length>0?(0,v.jsxs)(`span`,{title:`${e.dependsOn.length} dependencies`,children:[(0,v.jsx)(f,{size:12}),e.dependsOn.length]}):null,e.dueDate?(0,v.jsxs)(`span`,{title:`Due ${new Date(e.dueDate).toLocaleString()}`,children:[(0,v.jsx)(t,{size:12}),U(e.dueDate)]}):null,e.status===`completed`?(0,v.jsx)(r,{size:13,className:`is-done`}):null]})]})}function U(e){let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleDateString(void 0,{month:`short`,day:`numeric`}):e}function W(e){let t=Date.parse(e);if(!Number.isFinite(t))return e;let n=Math.max(0,Math.floor((Date.now()-t)/1e3));if(n<10)return`just now`;if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}export{L as KanbanView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Kt as n,N as r,O as i,R as a,T as o,Yt as s,Zt as c,f as l,mt as u,x as d,z as f}from"./icons-I81S_8cW.js";import{i as p}from"./markdown-C4I0Caum.js";import{c as m,n as h,o as g,p as _,u as v}from"./index-C5Ihi44B.js";import{c as ee,l as te,s as y,t as b,u as x}from"./fleet-topology-I_zBJHSw.js";var S=e(c(),1);function C(e,t,n){if(e===null||t===null)return null;let r=(e.liveSessions??[]).find(e=>e.sessionId===t);if(r===void 0)return null;let i=e.sessions.find(e=>e.sessionId===t)?.clientId,a=r.clientId??i,o=e.clients.find(e=>e.connected&&e.clientId===a),s=e.clients.filter(e=>e.connected&&e.machineId===r.machineId&&e.projectId===r.projectId&&(r.pid===void 0||e.pid===r.pid)),c=(o?.capabilities.includes(`control.receive`)===!0?o:void 0)??s.find(e=>e.kind===r.clientKind&&e.capabilities.includes(`control.receive`))??s.find(e=>e.capabilities.includes(`control.receive`))??o??s[0],l=n===null?null:r.agents.find(e=>e.id===n)??null,u=n===null||n===`leader`?`leader`:n,d=e.clients.some(e=>e.connected&&e.projectId===r.projectId&&e.capabilities.includes(`mailbox.serve`));return{session:r,client:c??null,agent:l,recipient:u,controllable:c?.capabilities.includes(`control.receive`)===!0,mailboxServeActive:d}}var w=p();function T(e){let t=b(e),n=[],r=new Map,i=new Map,a=new Map,o=e=>`machine:${e.machineId}`,s=e=>`project:${e.machineId}:${e.projectId}`;for(let e of t.nodes){if(e.kind!==`machine`)continue;let t={id:e.id,label:e.label,sub:e.sub,projects:[]};r.set(e.id,t),n.push(t)}for(let e of t.nodes){if(e.kind!==`project`)continue;let t=r.get(o(e));if(t===void 0)continue;let n={id:e.id,label:e.label,clients:[]};i.set(e.id,n),t.projects.push(n)}for(let e of t.nodes){if(e.kind!==`terminal`||e.sessionId===void 0||e.serviceMode!==void 0)continue;let t=i.get(s(e));if(t===void 0)continue;let n={clientId:e.clientId,sessionId:e.sessionId,label:e.label,clientKind:e.clientKind,status:e.status,synthetic:e.isSyntheticSession===!0,agents:[]};a.set(e.sessionId,n),t.clients.push(n)}for(let e of t.nodes){if(e.kind!==`agent`||e.sessionId===void 0||e.agentId===void 0)continue;let t=a.get(e.sessionId);t!==void 0&&t.agents.push({id:e.agentId,label:e.label,status:e.status})}return n.map(e=>({...e,projects:e.projects.filter(e=>e.clients.length>0)})).filter(e=>e.projects.length>0)}function E(e){return e===`active`||e===`running`||e===`streaming`?`active`:e===`waiting_user`?`warn`:e===`error`||e===`stale`||e===`closing`?`error`:`idle`}function D({snapshot:e,selectedSessionId:r,selectedAgentId:i}){let o=(0,S.useMemo)(()=>T(e),[e]),[s,c]=(0,S.useState)(new Set),d=e=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return o.length===0?(0,w.jsx)(`div`,{className:`hq-fleetnav`,children:(0,w.jsx)(`div`,{className:`hq-empty hq-pad-md`,children:`No live sessions. Open a WrongStack CLI/TUI/WebUI connected to HQ.`})}):(0,w.jsx)(`div`,{className:`hq-fleetnav`,role:`tree`,"aria-label":`Fleet navigator`,children:o.map(e=>{let o=!s.has(e.id);return(0,w.jsxs)(`div`,{className:`hq-nav-machine`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`hq-nav-row machine`,onClick:()=>d(e.id),"aria-expanded":o,children:[(0,w.jsx)(t,{size:12,className:`hq-nav-caret`+(o?` open`:``)}),(0,w.jsx)(a,{size:13}),(0,w.jsx)(`span`,{className:`hq-nav-label`,title:e.sub??e.label,children:e.label})]}),o&&e.projects.map(e=>{let a=!s.has(e.id);return(0,w.jsxs)(`div`,{className:`hq-nav-project`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`hq-nav-row project`,onClick:()=>d(e.id),"aria-expanded":a,children:[(0,w.jsx)(t,{size:12,className:`hq-nav-caret`+(a?` open`:``)}),(0,w.jsx)(u,{size:13}),(0,w.jsx)(`span`,{className:`hq-nav-label`,title:e.label,children:e.label})]}),a&&e.clients.map(e=>{let a=!s.has(e.sessionId),o=r===e.sessionId&&i===null;return(0,w.jsxs)(`div`,{className:`hq-nav-client`,children:[(0,w.jsxs)(`div`,{className:`hq-nav-clientrow`,children:[e.agents.length>0?(0,w.jsx)(`button`,{type:`button`,className:`hq-nav-caretbtn`,onClick:()=>d(e.sessionId),"aria-label":a?`Collapse`:`Expand`,children:(0,w.jsx)(t,{size:12,className:`hq-nav-caret`+(a?` open`:``)})}):(0,w.jsx)(`span`,{className:`hq-nav-caretbtn`}),(0,w.jsxs)(`button`,{type:`button`,className:`hq-nav-row client`+(o?` selected`:``),disabled:e.synthetic,onClick:()=>{e.synthetic||(v.getState().selectSession(e.sessionId),e.clientId!==void 0&&v.getState().selectClient(e.clientId))},title:e.synthetic?`waiting for session telemetry`:e.label,children:[(0,w.jsx)(`span`,{className:`hq-nav-dot `+E(e.status)}),(0,w.jsx)(l,{size:12}),(0,w.jsx)(`span`,{className:`hq-nav-label`,children:e.label}),e.agents.length>0&&(0,w.jsx)(`span`,{className:`hq-nav-count`,children:e.agents.length})]})]}),a&&e.agents.map(t=>{let a=r===e.sessionId&&i===t.id;return(0,w.jsxs)(`button`,{type:`button`,className:`hq-nav-row agent`+(a?` selected`:``),onClick:()=>{v.getState().selectAgent(e.sessionId,t.id),e.clientId!==void 0&&v.getState().selectClient(e.clientId)},title:t.label,children:[(0,w.jsx)(`span`,{className:`hq-nav-dot `+E(t.status)}),(0,w.jsx)(n,{size:12}),(0,w.jsx)(`span`,{className:`hq-nav-label`,children:t.label})]},t.id)})]},e.sessionId)})]},e.id)})]},e.id)})})}function O(e){return e===`completed`?`active`:e===`failed`||e===`rejected`?`error`:e===`delivered`||e===`accepted`?`info`:`warn`}function k({receipt:e,lifecycle:t}){let n=new Date(e.createdAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),i=(0,w.jsx)(`span`,{className:`hq-pill ${O(t)}`,children:t});return e.type===`abort`?(0,w.jsx)(`div`,{className:`hq-chat-turn system hq-command-turn`,"data-command-id":e.commandId,children:(0,w.jsxs)(`span`,{className:`hq-chat-system-line`,children:[(0,w.jsx)(r,{size:12}),` `,e.preview,` `,i,(0,w.jsx)(`span`,{className:`hq-chat-clock`,children:n})]})}):(0,w.jsx)(`div`,{className:`hq-chat-turn user hq-command-turn`,"data-command-id":e.commandId,children:(0,w.jsxs)(`div`,{className:`hq-chat-bubble user`,children:[(0,w.jsxs)(`div`,{className:`hq-chat-role`,children:[`you → `,e.target,` · `,e.type,` `,i,(0,w.jsx)(`span`,{className:`hq-chat-clock`,children:n})]}),(0,w.jsx)(`div`,{className:`hq-chat-prose`,children:e.preview})]})})}function A(){let{selectedSessionId:e,selectedAgentId:t,snapshot:a,commandStatuses:c}=v(_(e=>({selectedSessionId:e.selectedSessionId,selectedAgentId:e.selectedAgentId,snapshot:e.snapshot,commandStatuses:e.commandStatuses}))),l=e,u=t,p=u!==null,b=g().console,[T,E]=(0,S.useState)(b.delivery),[O,A]=(0,S.useState)(b.subject),[M,N]=(0,S.useState)(b.body),[P,F]=(0,S.useState)(!1),[I,L]=(0,S.useState)(null),[ne,R]=(0,S.useState)(!1),[z,B]=(0,S.useState)(!1),[V,H]=(0,S.useState)([]),U=te(l,u),{entries:W,meta:G,stats:K}=U,q=(0,S.useMemo)(()=>V.filter(e=>{if(e.type===`abort`)return!0;let t=Date.parse(e.createdAt);return!W.some(n=>n.role===`user`&&n.text.trim()===e.preview&&Math.abs(Date.parse(n.ts)-t)<12e4)}),[W,V]);(0,S.useEffect)(()=>{if(!U.pinned||q.length===0)return;let e=window.requestAnimationFrame(()=>{U.listRef.current?.scrollToIndex(W.length+q.length-1,{align:`end`})});return()=>window.cancelAnimationFrame(e)},[U.listRef,U.pinned,W.length,q.length]);let J=()=>{U.jumpToLatest(),window.requestAnimationFrame(()=>{U.listRef.current?.scrollToIndex(W.length+q.length-1,{align:`end`})})},Y=(0,S.useMemo)(()=>C(a,l,u),[u,l,a]),X=Y?.agent??null,Z=Y?.recipient===`leader`,Q=X?.name??(Z?`Leader agent`:Y?.recipient??`agent`);(0,S.useEffect)(()=>{let e=Y?.client?.clientId;e!==void 0&&v.getState().selectClient(e),L(null),R(!1),B(!1),H([])},[Y?.client?.clientId,l,u]);let $=async()=>{if(Y?.client===null||Y?.client===void 0||!Y.controllable||M.trim().length===0)return;F(!0),L(null);let e=M.trim();try{let t=await m(Y.client.clientId,T,{to:Y.recipient,subject:O.trim()||`HQ ${T}`,body:e,priority:T===`steer`?`high`:`normal`});N(``),h({body:``}),H(n=>[...n,{commandId:t.commandId,type:T,target:Q,preview:e,createdAt:new Date().toISOString()}].slice(-8)),L({tone:`ok`,text:`${T} queued for ${Q} · ${t.commandId}`})}catch(e){L({tone:`error`,text:e instanceof Error?e.message:String(e)})}finally{F(!1)}},re=async()=>{if(Y?.client!==null&&Y?.client!==void 0){F(!0),L(null);try{let e=await m(Y.client.clientId,`abort`,{target:Y.recipient});if(H(t=>[...t,{commandId:e.commandId,type:`abort`,target:Q,preview:`Interrupt ${Q}`,createdAt:new Date().toISOString()}].slice(-8)),Z&&z){let e=await m(Y.client.clientId,`abort`,{target:`fleet`});H(t=>[...t,{commandId:e.commandId,type:`abort`,target:`all subagents`,preview:`Interrupt every subagent on this client`,createdAt:new Date().toISOString()}].slice(-8))}L({tone:`ok`,text:Z&&z?`Leader interrupt queued; all subagents will be interrupted too.`:`${Q} interrupt queued.`}),R(!1)}catch(e){L({tone:`error`,text:e instanceof Error?e.message:String(e)})}finally{F(!1)}}};return(0,w.jsxs)(`div`,{className:`hq-console-shell`,children:[(0,w.jsxs)(`header`,{className:`hq-console-overview`,children:[(0,w.jsxs)(`div`,{className:`hq-console-overview-copy`,children:[(0,w.jsx)(`span`,{className:`hq-console-live-dot`,"data-live":Y!==null,"aria-hidden":`true`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`span`,{children:`Live transcript`}),(0,w.jsx)(`strong`,{children:l===null?`Select an endpoint`:p?X?.name??u:G.projectName??Q}),(0,w.jsx)(`small`,{children:l===null?`Choose a client or agent from the fleet navigator`:Y?.controllable===!0?`${Q} · control channel ready`:`${Q} · transcript is read-only`})]})]}),(0,w.jsxs)(`fieldset`,{className:`hq-console-overview-metrics`,"aria-label":`Transcript totals`,children:[(0,w.jsx)(j,{label:`turns`,value:K.turns+q.length}),(0,w.jsx)(j,{label:`tools`,value:K.tools}),(0,w.jsx)(j,{label:`running`,value:K.running,tone:K.running>0?`active`:void 0}),(0,w.jsx)(j,{label:`errors`,value:K.errors,tone:K.errors>0?`error`:void 0})]})]}),(0,w.jsx)(D,{snapshot:a??null,selectedSessionId:l,selectedAgentId:u}),(0,w.jsxs)(`div`,{className:`hq-console`,children:[(0,w.jsxs)(`div`,{className:`hq-chat-header`,children:[(0,w.jsx)(f,{size:15,className:`hq-chat-header-icon`}),(0,w.jsx)(`span`,{className:`hq-card-title hq-title-inline`,children:`Console`}),p&&(0,w.jsxs)(`span`,{className:`hq-pill active`,children:[(0,w.jsx)(n,{size:12}),` `,X?.name??u]}),G.projectName!==void 0&&!p&&(0,w.jsx)(`span`,{className:`hq-pill`,children:G.projectName}),Y!==null&&(0,w.jsxs)(`span`,{className:`hq-pill info`,title:Y.client?.clientId,children:[Y.session.hostname??Y.session.machineId,` ·`,` `,Y.session.clientKind.toUpperCase()]}),Y?.mailboxServeActive===!0&&(0,w.jsx)(`span`,{className:`hq-pill active`,children:`mailbox serve`}),G.source!==void 0&&(0,w.jsx)(`span`,{className:`hq-pill`,title:G.source===`disk`?`disk = full history replayed from this machine`:`stream = live ring only (remote or not yet persisted)`,children:G.source===`disk`?`full history`:`live ring`}),(0,w.jsxs)(`span`,{className:`hq-chat-counts`,children:[(0,w.jsxs)(`span`,{className:`hq-pill`,children:[K.turns+q.length,` turns`]}),(0,w.jsxs)(`span`,{className:`hq-pill`,children:[K.tools,` tools`]}),K.running>0&&(0,w.jsxs)(`span`,{className:`hq-pill running`,children:[K.running,` running`]}),K.errors>0&&(0,w.jsxs)(`span`,{className:`hq-pill error`,children:[K.errors,` err`]}),!p&&!U.full&&G.total>W.length&&(0,w.jsxs)(`button`,{type:`button`,className:`hq-btn secondary hq-chat-fullbtn`,onClick:()=>U.setFull(!0),title:`History is truncated — load all ${G.total} turns`,children:[(0,w.jsx)(o,{size:12}),` load all `,G.total]})]})]}),l===null?(0,w.jsxs)(`div`,{className:`hq-console-empty`,children:[(0,w.jsx)(`span`,{"aria-hidden":`true`,children:(0,w.jsx)(f,{size:24})}),(0,w.jsx)(`strong`,{children:`Choose a conversation`}),(0,w.jsx)(`small`,{children:`Pick a live client or agent from the fleet navigator to inspect its transcript.`})]}):U.loading&&W.length===0&&q.length===0?(0,w.jsx)(`div`,{className:`hq-empty`,children:p?`Loading agent history…`:`Loading transcript…`}):U.error===null?(0,w.jsxs)(`div`,{className:`hq-chat-scroll`,children:[W.length===0&&q.length===0?(0,w.jsx)(`div`,{className:`hq-empty`,children:p?`No messages from ${X?.name??u??`this agent`} yet.`:`No transcript entries yet.`}):(0,w.jsxs)(x,{ref:U.listRef,onScroll:U.onScroll,className:`hq-chat-vlist`,children:[W.map((e,t)=>(0,w.jsx)(`div`,{className:`hq-chat-rowpad`,children:(0,w.jsx)(y,{entry:e,running:U.isRunningAt(e,t)})},ee(e,t))),q.map(e=>{let t=c.find(t=>t.commandId===e.commandId),n=t?.ackStatus??t?.status??`queued`;return(0,w.jsx)(`div`,{className:`hq-chat-rowpad`,"aria-live":`polite`,children:(0,w.jsx)(k,{receipt:e,lifecycle:n})},`receipt:${e.commandId}`)})]}),!U.pinned&&(W.length>0||q.length>0)&&(0,w.jsx)(`button`,{type:`button`,className:`hq-chat-jump`,onClick:J,title:`Jump to latest`,children:(0,w.jsx)(s,{size:14})})]}):(0,w.jsxs)(`div`,{className:`hq-empty`,children:[`Error: `,U.error]}),l!==null&&(0,w.jsxs)(`div`,{className:`hq-console-composer`,children:[(0,w.jsxs)(`div`,{className:`hq-console-composer-head`,children:[(0,w.jsxs)(`span`,{children:[(0,w.jsx)(i,{size:13}),` Send to `,(0,w.jsx)(`strong`,{children:Q})]}),(0,w.jsx)(`span`,{className:`hq-pill ${Y?.controllable===!0?`active`:`error`}`,children:Y?.controllable===!0?`control live`:`read-only client`})]}),(0,w.jsxs)(`div`,{className:`hq-console-compose-row`,children:[(0,w.jsxs)(`select`,{className:`hq-select hq-console-delivery`,"aria-label":`Message delivery mode`,value:T,onChange:e=>{let t=e.target.value;E(t),h({delivery:t})},children:[(0,w.jsx)(`option`,{value:`steer`,children:`Steer now`}),(0,w.jsx)(`option`,{value:`btw`,children:`BTW / FYI`}),(0,w.jsx)(`option`,{value:`queue`,children:`Queue next`})]}),(0,w.jsx)(`input`,{className:`hq-input hq-console-subject`,"aria-label":`Message subject`,placeholder:`HQ ${T} (optional subject)`,value:O,onChange:e=>{A(e.target.value),h({subject:e.target.value})}}),(0,w.jsxs)(`button`,{type:`button`,className:`hq-btn danger hq-console-interrupt`,disabled:P||Y?.controllable!==!0,onClick:()=>{B(!1),R(!0)},children:[(0,w.jsx)(r,{size:13}),` Interrupt`]})]}),(0,w.jsxs)(`div`,{className:`hq-console-compose-row hq-console-message-row`,children:[(0,w.jsx)(`textarea`,{className:`hq-textarea hq-console-message`,"aria-label":`Message ${Q}`,placeholder:`Message ${Q}…`,rows:2,value:M,onChange:e=>{N(e.target.value),h({body:e.target.value})},onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),$())}}),(0,w.jsxs)(`button`,{type:`button`,className:`hq-btn primary hq-console-send`,disabled:P||M.trim().length===0||Y?.controllable!==!0,onClick:()=>void $(),children:[(0,w.jsx)(d,{size:13}),` `,P?`Queueing…`:`Send`]})]}),(0,w.jsxs)(`div`,{className:`hq-console-compose-foot`,children:[(0,w.jsx)(`span`,{children:`Ctrl+Enter sends · steer interrupts at the next safe turn`}),I!==null&&(0,w.jsx)(`span`,{className:`hq-console-status ${I.tone}`,children:I.text})]})]})]}),ne&&Y!==null&&(0,w.jsxs)(`div`,{className:`hq-confirm-layer`,role:`presentation`,children:[(0,w.jsx)(`button`,{type:`button`,className:`hq-confirm-scrim`,"aria-label":`Cancel interrupt`,onClick:()=>R(!1)}),(0,w.jsxs)(`section`,{className:`hq-confirm-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`hq-interrupt-title`,children:[(0,w.jsx)(r,{size:22,className:`hq-confirm-danger`}),(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h2`,{id:`hq-interrupt-title`,children:[`Interrupt `,Q,`?`]}),(0,w.jsx)(`p`,{children:`The current run will stop at its cancellation boundary.`})]}),Z&&(0,w.jsxs)(`label`,{className:`hq-confirm-check`,children:[(0,w.jsx)(`input`,{type:`checkbox`,checked:z,onChange:e=>B(e.target.checked)}),`Also interrupt every subagent on this client`]}),(0,w.jsxs)(`div`,{className:`hq-confirm-actions`,children:[(0,w.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,onClick:()=>R(!1),children:`Cancel`}),(0,w.jsxs)(`button`,{type:`button`,className:`hq-btn danger`,disabled:P,onClick:()=>void re(),children:[(0,w.jsx)(r,{size:13}),` Confirm interrupt`]})]})]})]})]})}function j({label:e,value:t,tone:n}){return(0,w.jsxs)(`div`,{className:`hq-console-overview-metric`,"data-tone":n,children:[(0,w.jsx)(`strong`,{children:t}),(0,w.jsx)(`span`,{children:e})]})}export{A as LiveConsoleView};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Kt as n,N as r,O as i,R as a,T as o,Yt as s,Zt as c,f as l,mt as u,x as d,z as f}from"./icons-Cxo3pc0p.js";import{i as p}from"./markdown-jMopG_H4.js";import{c as m,n as h,o as g,p as _,u as v}from"./index-BYuL7DL0.js";import{c as ee,l as te,s as y,t as b,u as x}from"./fleet-topology-BupZawpq.js";var S=e(c(),1);function C(e,t,n){if(e===null||t===null)return null;let r=(e.liveSessions??[]).find(e=>e.sessionId===t);if(r===void 0)return null;let i=e.sessions.find(e=>e.sessionId===t)?.clientId,a=r.clientId??i,o=e.clients.find(e=>e.connected&&e.clientId===a),s=e.clients.filter(e=>e.connected&&e.machineId===r.machineId&&e.projectId===r.projectId&&(r.pid===void 0||e.pid===r.pid)),c=(o?.capabilities.includes(`control.receive`)===!0?o:void 0)??s.find(e=>e.kind===r.clientKind&&e.capabilities.includes(`control.receive`))??s.find(e=>e.capabilities.includes(`control.receive`))??o??s[0],l=n===null?null:r.agents.find(e=>e.id===n)??null,u=n===null||n===`leader`?`leader`:n,d=e.clients.some(e=>e.connected&&e.projectId===r.projectId&&e.capabilities.includes(`mailbox.serve`));return{session:r,client:c??null,agent:l,recipient:u,controllable:c?.capabilities.includes(`control.receive`)===!0,mailboxServeActive:d}}var w=p();function T(e){let t=b(e),n=[],r=new Map,i=new Map,a=new Map,o=e=>`machine:${e.machineId}`,s=e=>`project:${e.machineId}:${e.projectId}`;for(let e of t.nodes){if(e.kind!==`machine`)continue;let t={id:e.id,label:e.label,sub:e.sub,projects:[]};r.set(e.id,t),n.push(t)}for(let e of t.nodes){if(e.kind!==`project`)continue;let t=r.get(o(e));if(t===void 0)continue;let n={id:e.id,label:e.label,clients:[]};i.set(e.id,n),t.projects.push(n)}for(let e of t.nodes){if(e.kind!==`terminal`||e.sessionId===void 0||e.serviceMode!==void 0)continue;let t=i.get(s(e));if(t===void 0)continue;let n={clientId:e.clientId,sessionId:e.sessionId,label:e.label,clientKind:e.clientKind,status:e.status,synthetic:e.isSyntheticSession===!0,agents:[]};a.set(e.sessionId,n),t.clients.push(n)}for(let e of t.nodes){if(e.kind!==`agent`||e.sessionId===void 0||e.agentId===void 0)continue;let t=a.get(e.sessionId);t!==void 0&&t.agents.push({id:e.agentId,label:e.label,status:e.status})}return n.map(e=>({...e,projects:e.projects.filter(e=>e.clients.length>0)})).filter(e=>e.projects.length>0)}function E(e){return e===`active`||e===`running`||e===`streaming`?`active`:e===`waiting_user`?`warn`:e===`error`||e===`stale`||e===`closing`?`error`:`idle`}function D({snapshot:e,selectedSessionId:r,selectedAgentId:i}){let o=(0,S.useMemo)(()=>T(e),[e]),[s,c]=(0,S.useState)(new Set),d=e=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return o.length===0?(0,w.jsx)(`div`,{className:`hq-fleetnav`,children:(0,w.jsx)(`div`,{className:`hq-empty hq-pad-md`,children:`No live sessions. Open a WrongStack CLI/TUI/WebUI connected to HQ.`})}):(0,w.jsx)(`div`,{className:`hq-fleetnav`,role:`tree`,"aria-label":`Fleet navigator`,children:o.map(e=>{let o=!s.has(e.id);return(0,w.jsxs)(`div`,{className:`hq-nav-machine`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`hq-nav-row machine`,onClick:()=>d(e.id),"aria-expanded":o,children:[(0,w.jsx)(t,{size:12,className:`hq-nav-caret`+(o?` open`:``)}),(0,w.jsx)(a,{size:13}),(0,w.jsx)(`span`,{className:`hq-nav-label`,title:e.sub??e.label,children:e.label})]}),o&&e.projects.map(e=>{let a=!s.has(e.id);return(0,w.jsxs)(`div`,{className:`hq-nav-project`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`hq-nav-row project`,onClick:()=>d(e.id),"aria-expanded":a,children:[(0,w.jsx)(t,{size:12,className:`hq-nav-caret`+(a?` open`:``)}),(0,w.jsx)(u,{size:13}),(0,w.jsx)(`span`,{className:`hq-nav-label`,title:e.label,children:e.label})]}),a&&e.clients.map(e=>{let a=!s.has(e.sessionId),o=r===e.sessionId&&i===null;return(0,w.jsxs)(`div`,{className:`hq-nav-client`,children:[(0,w.jsxs)(`div`,{className:`hq-nav-clientrow`,children:[e.agents.length>0?(0,w.jsx)(`button`,{type:`button`,className:`hq-nav-caretbtn`,onClick:()=>d(e.sessionId),"aria-label":a?`Collapse`:`Expand`,children:(0,w.jsx)(t,{size:12,className:`hq-nav-caret`+(a?` open`:``)})}):(0,w.jsx)(`span`,{className:`hq-nav-caretbtn`}),(0,w.jsxs)(`button`,{type:`button`,className:`hq-nav-row client`+(o?` selected`:``),disabled:e.synthetic,onClick:()=>{e.synthetic||(v.getState().selectSession(e.sessionId),e.clientId!==void 0&&v.getState().selectClient(e.clientId))},title:e.synthetic?`waiting for session telemetry`:e.label,children:[(0,w.jsx)(`span`,{className:`hq-nav-dot `+E(e.status)}),(0,w.jsx)(l,{size:12}),(0,w.jsx)(`span`,{className:`hq-nav-label`,children:e.label}),e.agents.length>0&&(0,w.jsx)(`span`,{className:`hq-nav-count`,children:e.agents.length})]})]}),a&&e.agents.map(t=>{let a=r===e.sessionId&&i===t.id;return(0,w.jsxs)(`button`,{type:`button`,className:`hq-nav-row agent`+(a?` selected`:``),onClick:()=>{v.getState().selectAgent(e.sessionId,t.id),e.clientId!==void 0&&v.getState().selectClient(e.clientId)},title:t.label,children:[(0,w.jsx)(`span`,{className:`hq-nav-dot `+E(t.status)}),(0,w.jsx)(n,{size:12}),(0,w.jsx)(`span`,{className:`hq-nav-label`,children:t.label})]},t.id)})]},e.sessionId)})]},e.id)})]},e.id)})})}function O(e){return e===`completed`?`active`:e===`failed`||e===`rejected`?`error`:e===`delivered`||e===`accepted`?`info`:`warn`}function k({receipt:e,lifecycle:t}){let n=new Date(e.createdAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),i=(0,w.jsx)(`span`,{className:`hq-pill ${O(t)}`,children:t});return e.type===`abort`?(0,w.jsx)(`div`,{className:`hq-chat-turn system hq-command-turn`,"data-command-id":e.commandId,children:(0,w.jsxs)(`span`,{className:`hq-chat-system-line`,children:[(0,w.jsx)(r,{size:12}),` `,e.preview,` `,i,(0,w.jsx)(`span`,{className:`hq-chat-clock`,children:n})]})}):(0,w.jsx)(`div`,{className:`hq-chat-turn user hq-command-turn`,"data-command-id":e.commandId,children:(0,w.jsxs)(`div`,{className:`hq-chat-bubble user`,children:[(0,w.jsxs)(`div`,{className:`hq-chat-role`,children:[`you → `,e.target,` · `,e.type,` `,i,(0,w.jsx)(`span`,{className:`hq-chat-clock`,children:n})]}),(0,w.jsx)(`div`,{className:`hq-chat-prose`,children:e.preview})]})})}function A(){let{selectedSessionId:e,selectedAgentId:t,snapshot:a,commandStatuses:c}=v(_(e=>({selectedSessionId:e.selectedSessionId,selectedAgentId:e.selectedAgentId,snapshot:e.snapshot,commandStatuses:e.commandStatuses}))),l=e,u=t,p=u!==null,b=g().console,[T,E]=(0,S.useState)(b.delivery),[O,A]=(0,S.useState)(b.subject),[M,N]=(0,S.useState)(b.body),[P,F]=(0,S.useState)(!1),[I,L]=(0,S.useState)(null),[ne,R]=(0,S.useState)(!1),[z,B]=(0,S.useState)(!1),[V,H]=(0,S.useState)([]),U=te(l,u),{entries:W,meta:G,stats:K}=U,q=(0,S.useMemo)(()=>V.filter(e=>{if(e.type===`abort`)return!0;let t=Date.parse(e.createdAt);return!W.some(n=>n.role===`user`&&n.text.trim()===e.preview&&Math.abs(Date.parse(n.ts)-t)<12e4)}),[W,V]);(0,S.useEffect)(()=>{if(!U.pinned||q.length===0)return;let e=window.requestAnimationFrame(()=>{U.listRef.current?.scrollToIndex(W.length+q.length-1,{align:`end`})});return()=>window.cancelAnimationFrame(e)},[U.listRef,U.pinned,W.length,q.length]);let J=()=>{U.jumpToLatest(),window.requestAnimationFrame(()=>{U.listRef.current?.scrollToIndex(W.length+q.length-1,{align:`end`})})},Y=(0,S.useMemo)(()=>C(a,l,u),[u,l,a]),X=Y?.agent??null,Z=Y?.recipient===`leader`,Q=X?.name??(Z?`Leader agent`:Y?.recipient??`agent`);(0,S.useEffect)(()=>{let e=Y?.client?.clientId;e!==void 0&&v.getState().selectClient(e),L(null),R(!1),B(!1),H([])},[Y?.client?.clientId,l,u]);let $=async()=>{if(Y?.client===null||Y?.client===void 0||!Y.controllable||M.trim().length===0)return;F(!0),L(null);let e=M.trim();try{let t=await m(Y.client.clientId,T,{to:Y.recipient,subject:O.trim()||`HQ ${T}`,body:e,priority:T===`steer`?`high`:`normal`});N(``),h({body:``}),H(n=>[...n,{commandId:t.commandId,type:T,target:Q,preview:e,createdAt:new Date().toISOString()}].slice(-8)),L({tone:`ok`,text:`${T} queued for ${Q} · ${t.commandId}`})}catch(e){L({tone:`error`,text:e instanceof Error?e.message:String(e)})}finally{F(!1)}},re=async()=>{if(Y?.client!==null&&Y?.client!==void 0){F(!0),L(null);try{let e=await m(Y.client.clientId,`abort`,{target:Y.recipient});if(H(t=>[...t,{commandId:e.commandId,type:`abort`,target:Q,preview:`Interrupt ${Q}`,createdAt:new Date().toISOString()}].slice(-8)),Z&&z){let e=await m(Y.client.clientId,`abort`,{target:`fleet`});H(t=>[...t,{commandId:e.commandId,type:`abort`,target:`all subagents`,preview:`Interrupt every subagent on this client`,createdAt:new Date().toISOString()}].slice(-8))}L({tone:`ok`,text:Z&&z?`Leader interrupt queued; all subagents will be interrupted too.`:`${Q} interrupt queued.`}),R(!1)}catch(e){L({tone:`error`,text:e instanceof Error?e.message:String(e)})}finally{F(!1)}}};return(0,w.jsxs)(`div`,{className:`hq-console-shell`,children:[(0,w.jsxs)(`header`,{className:`hq-console-overview`,children:[(0,w.jsxs)(`div`,{className:`hq-console-overview-copy`,children:[(0,w.jsx)(`span`,{className:`hq-console-live-dot`,"data-live":Y!==null,"aria-hidden":`true`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`span`,{children:`Live transcript`}),(0,w.jsx)(`strong`,{children:l===null?`Select an endpoint`:p?X?.name??u:G.projectName??Q}),(0,w.jsx)(`small`,{children:l===null?`Choose a client or agent from the fleet navigator`:Y?.controllable===!0?`${Q} · control channel ready`:`${Q} · transcript is read-only`})]})]}),(0,w.jsxs)(`fieldset`,{className:`hq-console-overview-metrics`,"aria-label":`Transcript totals`,children:[(0,w.jsx)(j,{label:`turns`,value:K.turns+q.length}),(0,w.jsx)(j,{label:`tools`,value:K.tools}),(0,w.jsx)(j,{label:`running`,value:K.running,tone:K.running>0?`active`:void 0}),(0,w.jsx)(j,{label:`errors`,value:K.errors,tone:K.errors>0?`error`:void 0})]})]}),(0,w.jsx)(D,{snapshot:a??null,selectedSessionId:l,selectedAgentId:u}),(0,w.jsxs)(`div`,{className:`hq-console`,children:[(0,w.jsxs)(`div`,{className:`hq-chat-header`,children:[(0,w.jsx)(f,{size:15,className:`hq-chat-header-icon`}),(0,w.jsx)(`span`,{className:`hq-card-title hq-title-inline`,children:`Console`}),p&&(0,w.jsxs)(`span`,{className:`hq-pill active`,children:[(0,w.jsx)(n,{size:12}),` `,X?.name??u]}),G.projectName!==void 0&&!p&&(0,w.jsx)(`span`,{className:`hq-pill`,children:G.projectName}),Y!==null&&(0,w.jsxs)(`span`,{className:`hq-pill info`,title:Y.client?.clientId,children:[Y.session.hostname??Y.session.machineId,` ·`,` `,Y.session.clientKind.toUpperCase()]}),Y?.mailboxServeActive===!0&&(0,w.jsx)(`span`,{className:`hq-pill active`,children:`mailbox serve`}),G.source!==void 0&&(0,w.jsx)(`span`,{className:`hq-pill`,title:G.source===`disk`?`disk = full history replayed from this machine`:`stream = live ring only (remote or not yet persisted)`,children:G.source===`disk`?`full history`:`live ring`}),(0,w.jsxs)(`span`,{className:`hq-chat-counts`,children:[(0,w.jsxs)(`span`,{className:`hq-pill`,children:[K.turns+q.length,` turns`]}),(0,w.jsxs)(`span`,{className:`hq-pill`,children:[K.tools,` tools`]}),K.running>0&&(0,w.jsxs)(`span`,{className:`hq-pill running`,children:[K.running,` running`]}),K.errors>0&&(0,w.jsxs)(`span`,{className:`hq-pill error`,children:[K.errors,` err`]}),!p&&!U.full&&G.total>W.length&&(0,w.jsxs)(`button`,{type:`button`,className:`hq-btn secondary hq-chat-fullbtn`,onClick:()=>U.setFull(!0),title:`History is truncated — load all ${G.total} turns`,children:[(0,w.jsx)(o,{size:12}),` load all `,G.total]})]})]}),l===null?(0,w.jsxs)(`div`,{className:`hq-console-empty`,children:[(0,w.jsx)(`span`,{"aria-hidden":`true`,children:(0,w.jsx)(f,{size:24})}),(0,w.jsx)(`strong`,{children:`Choose a conversation`}),(0,w.jsx)(`small`,{children:`Pick a live client or agent from the fleet navigator to inspect its transcript.`})]}):U.loading&&W.length===0&&q.length===0?(0,w.jsx)(`div`,{className:`hq-empty`,children:p?`Loading agent history…`:`Loading transcript…`}):U.error===null?(0,w.jsxs)(`div`,{className:`hq-chat-scroll`,children:[W.length===0&&q.length===0?(0,w.jsx)(`div`,{className:`hq-empty`,children:p?`No messages from ${X?.name??u??`this agent`} yet.`:`No transcript entries yet.`}):(0,w.jsxs)(x,{ref:U.listRef,onScroll:U.onScroll,className:`hq-chat-vlist`,children:[W.map((e,t)=>(0,w.jsx)(`div`,{className:`hq-chat-rowpad`,children:(0,w.jsx)(y,{entry:e,running:U.isRunningAt(e,t)})},ee(e,t))),q.map(e=>{let t=c.find(t=>t.commandId===e.commandId),n=t?.ackStatus??t?.status??`queued`;return(0,w.jsx)(`div`,{className:`hq-chat-rowpad`,"aria-live":`polite`,children:(0,w.jsx)(k,{receipt:e,lifecycle:n})},`receipt:${e.commandId}`)})]}),!U.pinned&&(W.length>0||q.length>0)&&(0,w.jsx)(`button`,{type:`button`,className:`hq-chat-jump`,onClick:J,title:`Jump to latest`,children:(0,w.jsx)(s,{size:14})})]}):(0,w.jsxs)(`div`,{className:`hq-empty`,children:[`Error: `,U.error]}),l!==null&&(0,w.jsxs)(`div`,{className:`hq-console-composer`,children:[(0,w.jsxs)(`div`,{className:`hq-console-composer-head`,children:[(0,w.jsxs)(`span`,{children:[(0,w.jsx)(i,{size:13}),` Send to `,(0,w.jsx)(`strong`,{children:Q})]}),(0,w.jsx)(`span`,{className:`hq-pill ${Y?.controllable===!0?`active`:`error`}`,children:Y?.controllable===!0?`control live`:`read-only client`})]}),(0,w.jsxs)(`div`,{className:`hq-console-compose-row`,children:[(0,w.jsxs)(`select`,{className:`hq-select hq-console-delivery`,"aria-label":`Message delivery mode`,value:T,onChange:e=>{let t=e.target.value;E(t),h({delivery:t})},children:[(0,w.jsx)(`option`,{value:`steer`,children:`Steer now`}),(0,w.jsx)(`option`,{value:`btw`,children:`BTW / FYI`}),(0,w.jsx)(`option`,{value:`queue`,children:`Queue next`})]}),(0,w.jsx)(`input`,{className:`hq-input hq-console-subject`,"aria-label":`Message subject`,placeholder:`HQ ${T} (optional subject)`,value:O,onChange:e=>{A(e.target.value),h({subject:e.target.value})}}),(0,w.jsxs)(`button`,{type:`button`,className:`hq-btn danger hq-console-interrupt`,disabled:P||Y?.controllable!==!0,onClick:()=>{B(!1),R(!0)},children:[(0,w.jsx)(r,{size:13}),` Interrupt`]})]}),(0,w.jsxs)(`div`,{className:`hq-console-compose-row hq-console-message-row`,children:[(0,w.jsx)(`textarea`,{className:`hq-textarea hq-console-message`,"aria-label":`Message ${Q}`,placeholder:`Message ${Q}…`,rows:2,value:M,onChange:e=>{N(e.target.value),h({body:e.target.value})},onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),$())}}),(0,w.jsxs)(`button`,{type:`button`,className:`hq-btn primary hq-console-send`,disabled:P||M.trim().length===0||Y?.controllable!==!0,onClick:()=>void $(),children:[(0,w.jsx)(d,{size:13}),` `,P?`Queueing…`:`Send`]})]}),(0,w.jsxs)(`div`,{className:`hq-console-compose-foot`,children:[(0,w.jsx)(`span`,{children:`Ctrl+Enter sends · steer interrupts at the next safe turn`}),I!==null&&(0,w.jsx)(`span`,{className:`hq-console-status ${I.tone}`,children:I.text})]})]})]}),ne&&Y!==null&&(0,w.jsxs)(`div`,{className:`hq-confirm-layer`,role:`presentation`,children:[(0,w.jsx)(`button`,{type:`button`,className:`hq-confirm-scrim`,"aria-label":`Cancel interrupt`,onClick:()=>R(!1)}),(0,w.jsxs)(`section`,{className:`hq-confirm-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`hq-interrupt-title`,children:[(0,w.jsx)(r,{size:22,className:`hq-confirm-danger`}),(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h2`,{id:`hq-interrupt-title`,children:[`Interrupt `,Q,`?`]}),(0,w.jsx)(`p`,{children:`The current run will stop at its cancellation boundary.`})]}),Z&&(0,w.jsxs)(`label`,{className:`hq-confirm-check`,children:[(0,w.jsx)(`input`,{type:`checkbox`,checked:z,onChange:e=>B(e.target.checked)}),`Also interrupt every subagent on this client`]}),(0,w.jsxs)(`div`,{className:`hq-confirm-actions`,children:[(0,w.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,onClick:()=>R(!1),children:`Cancel`}),(0,w.jsxs)(`button`,{type:`button`,className:`hq-btn danger`,disabled:P,onClick:()=>void re(),children:[(0,w.jsx)(r,{size:13}),` Confirm interrupt`]})]})]})]})]})}function j({label:e,value:t,tone:n}){return(0,w.jsxs)(`div`,{className:`hq-console-overview-metric`,"data-tone":n,children:[(0,w.jsx)(`strong`,{children:t}),(0,w.jsx)(`span`,{children:e})]})}export{A as LiveConsoleView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{B as t,D as n,H as r,It as i,P as a,S as o,U as s,V as c,Y as l,Z as u,Zt as d,_ as f,dt as p,et as m,k as h,l as g,rt as _,s as v}from"./icons-I81S_8cW.js";import{i as y}from"./markdown-C4I0Caum.js";import{a as b,d as x,l as S,o as C,u as w}from"./index-C5Ihi44B.js";import{t as T}from"./use-backfilled-events-CbvvmZr7.js";var E=e(d(),1),D=y(),O=[{value:`note`,label:`note — general information`},{value:`ask`,label:`ask — reply required`},{value:`assign`,label:`assign — work ownership`},{value:`steer`,label:`steer — redirect the current work`},{value:`btw`,label:`btw — FYI, no action required`},{value:`queue`,label:`queue — note for the next agent`},{value:`broadcast`,label:`broadcast — all agents in the project`},{value:`status`,label:`status — meaningful checkpoint`},{value:`result`,label:`result — completed output/evidence`},{value:`review`,label:`review — passive inspection request`}];function k({projects:e,sender:t}){let n=t??S,[r,i]=(0,E.useState)(!1),[a,o]=(0,E.useState)(``),[c,l]=(0,E.useState)(`steer`),[u,d]=(0,E.useState)(`leader`),[f,p]=(0,E.useState)(`normal`),[m,h]=(0,E.useState)(!1),[g,_]=(0,E.useState)(``),[v,y]=(0,E.useState)(``),[b,x]=(0,E.useState)({phase:`idle`}),C=a||e[0]?.projectId||``,w=b.phase!==`sending`&&v.trim().length>0&&C.length>0,T=async()=>{if(w){x({phase:`sending`});try{let e=await n({projectId:C,type:c,...c===`broadcast`?{}:{to:u.trim()||`leader`},subject:g.trim()||`HQ prompt`,body:v.trim(),priority:f,audience:m?`leaders`:`all`});x({phase:`sent`,messageId:e.messageId}),y(``)}catch(e){x({phase:`error`,message:e instanceof Error?e.message:String(e)})}}};return r?(0,D.jsxs)(`div`,{className:`hq-card hq-composer`,children:[(0,D.jsxs)(`div`,{className:`hq-row hq-row-baseline`,children:[(0,D.jsx)(`span`,{className:`hq-card-title hq-title-inline`,children:`Send to project mailbox`}),(0,D.jsx)(`span`,{className:`hq-composer-hint`,children:`lands in the mailbox file — picked up by the next agent, no live client needed`}),(0,D.jsx)(`button`,{type:`button`,className:`hq-toggle hq-ml-auto`,"aria-label":`Collapse composer`,onClick:()=>i(!1),children:`▾`})]}),(0,D.jsxs)(`div`,{className:`hq-composer-grid`,children:[(0,D.jsxs)(`label`,{className:`hq-composer-field`,children:[(0,D.jsx)(`span`,{children:`project`}),(0,D.jsx)(`select`,{className:`hq-select`,value:C,onChange:e=>o(e.target.value),children:e.map(e=>(0,D.jsx)(`option`,{value:e.projectId,children:e.label??e.projectId},e.projectId))})]}),(0,D.jsxs)(`label`,{className:`hq-composer-field`,children:[(0,D.jsx)(`span`,{children:`type`}),(0,D.jsx)(`select`,{className:`hq-select`,value:c,onChange:e=>l(e.target.value),children:O.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),c!==`broadcast`&&(0,D.jsxs)(`label`,{className:`hq-composer-field`,children:[(0,D.jsx)(`span`,{children:`to`}),(0,D.jsx)(`input`,{className:`hq-input`,value:u,placeholder:`leader`,onChange:e=>d(e.target.value)})]}),(0,D.jsxs)(`label`,{className:`hq-composer-field`,children:[(0,D.jsx)(`span`,{children:`audience`}),(0,D.jsxs)(`select`,{className:`hq-select`,value:m?`leaders`:`all`,onChange:e=>h(e.target.value===`leaders`),children:[(0,D.jsx)(`option`,{value:`all`,children:`all agents`}),(0,D.jsx)(`option`,{value:`leaders`,children:`leaders only — subagents cannot consume`})]})]}),(0,D.jsxs)(`label`,{className:`hq-composer-field`,children:[(0,D.jsx)(`span`,{children:`priority`}),(0,D.jsxs)(`select`,{className:`hq-select`,value:f,onChange:e=>p(e.target.value),children:[(0,D.jsx)(`option`,{value:`high`,children:`high`}),(0,D.jsx)(`option`,{value:`normal`,children:`normal`}),(0,D.jsx)(`option`,{value:`low`,children:`low`})]})]})]}),(0,D.jsx)(`input`,{className:`hq-input`,value:g,placeholder:`subject (optional)`,onChange:e=>_(e.target.value)}),(0,D.jsx)(`textarea`,{className:`hq-input hq-composer-body`,value:v,rows:3,placeholder:`Message body — e.g. “after the current task, run the full test suite”`,onChange:e=>y(e.target.value)}),(0,D.jsxs)(`div`,{className:`hq-row`,children:[(0,D.jsx)(`button`,{type:`button`,className:`hq-btn`,disabled:!w,onClick:()=>void T(),children:b.phase===`sending`?`Sending…`:`Send`}),b.phase===`sent`&&(0,D.jsxs)(`span`,{className:`hq-composer-status ok`,children:[`delivered`,b.messageId===void 0?``:` · ${b.messageId.slice(0,8)}`]}),b.phase===`error`&&(0,D.jsx)(`span`,{className:`hq-composer-status err`,title:b.message,children:b.message})]})]}):(0,D.jsxs)(`div`,{className:`hq-composer-bar`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`hq-btn`,disabled:e.length===0,title:e.length===0?`No projects reported yet — connect a client first`:`Write a message into a project mailbox (works with zero connected agents)`,onClick:()=>i(!0),children:[(0,D.jsx)(s,{size:13}),` Compose`]}),b.phase===`sent`&&(0,D.jsxs)(`span`,{className:`hq-composer-status ok`,children:[`delivered`,b.messageId===void 0?``:` · ${b.messageId.slice(0,8)}`]})]})}function A(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.mailboxId==`string`&&(t.scope===`project`||t.scope===`global`)&&Array.isArray(t.messages)&&Array.isArray(t.agents)&&typeof t.totals==`object`&&t.totals!==null}function j(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.mailboxId==`string`&&typeof t.action==`string`&&(t.message===void 0||typeof t.message==`object`)}function M(e,t){let n=e.get(t);return n===void 0&&(n={projectId:t,messages:[],countersFromSnapshot:!1,onlineAgentCount:0,highPriorityCount:0,unreadCount:0,incompleteCount:0},e.set(t,n)),n}function N(e){let t=0,n=0,r=0;for(let i of e){let e=i.message;e.priority===`high`&&(t+=1),e.completed||(r+=1,(e.readCount??0)===0&&(n+=1))}return{highPriorityCount:t,unreadCount:n,incompleteCount:r}}function P(e){let t=new Map;for(let n of e)(t.get(n.message.mailId)===void 0||n.source===`event`)&&t.set(n.message.mailId,n);return Array.from(t.values()).sort((e,t)=>t.message.timestamp.localeCompare(e.message.timestamp))}function F(e,t){let n=new Map;if(e!==null)for(let t of e.mailboxes){let e=M(n,t.projectId);e.mailboxId=t.mailboxId,e.scope=t.scope,e.onlineAgentCount=t.onlineAgentCount,e.highPriorityCount=t.highPriorityCount,e.unreadCount=t.unreadCount,e.incompleteCount=t.incompleteCount,e.countersFromSnapshot=!0}for(let e of t){if(e.type!==`mailbox.snapshot`||!A(e.payload))continue;let t=e.payload,r=M(n,e.projectId);r.mailboxId=t.mailboxId,r.scope=t.scope;for(let n of t.messages)r.messages.push({message:n,source:`snapshot`,key:`s:${e.id}:${n.messageId}`,projectId:e.projectId})}let r=new Map;for(let e of t){if(e.type!==`mailbox.event`||!j(e.payload))continue;let t=e.payload,i=M(n,e.projectId);i.mailboxId=t.mailboxId,i.scope=i.scope??`project`,t.message!==void 0&&!r.has(t.message.mailId)&&(r.set(t.message.mailId,i),i.messages.push({message:t.message,source:`event`,key:`e:${t.message.mailId}:${e.seq}`,projectId:e.projectId})),t.agent?.online&&(i.onlineAgentCount+=1)}for(let e of n.values())if(e.messages=P(e.messages),!e.countersFromSnapshot){let t=N(e.messages);e.highPriorityCount=t.highPriorityCount,e.unreadCount=t.unreadCount,e.incompleteCount=t.incompleteCount}let i=Array.from(n.values()).sort((e,t)=>{let n=e.messages[0]?.message.timestamp??``;return(t.messages[0]?.message.timestamp??``).localeCompare(n)});return{projects:i,hasAnyActivity:i.some(e=>e.messages.length>0)}}var I=Object.freeze({types:new Set,priorities:new Set,projectIds:new Set,includeCompleted:!0,query:``});function ee(e,t){switch(t.type){case`toggle-type`:{let n=new Set(e.types);return n.has(t.value)?n.delete(t.value):n.add(t.value),{...e,types:n}}case`toggle-priority`:{let n=new Set(e.priorities);return n.has(t.value)?n.delete(t.value):n.add(t.value),{...e,priorities:n}}case`toggle-project`:{let n=new Set(e.projectIds);return n.has(t.value)?n.delete(t.value):n.add(t.value),{...e,projectIds:n}}case`set-query`:return{...e,query:t.value};case`set-include-completed`:return{...e,includeCompleted:t.value};case`clear-all`:return I;default:return e}}function te(e,t={}){let n=t.includeCompleted??!0,r=t.types&&t.types.length>0?new Set(t.types):null,i=t.priorities&&t.priorities.length>0?new Set(t.priorities):null,a=t.projectIds&&t.projectIds.length>0?new Set(t.projectIds):null,o=t.query?.trim().toLowerCase()??``,s=t.limit??500,c=[];for(let t of e){let e=t.message;!n&&e.completed||r&&!r.has(e.type)||i&&!i.has(e.priority)||a||o.length>0&&!`${e.subject}\n${e.from}\n${e.to}\n${e.bodyPreview??``}`.toLowerCase().includes(o)||c.push({key:t.key,flat:t})}c.sort((e,t)=>{let n=t.flat.message.timestamp.localeCompare(e.flat.message.timestamp);return n===0?e.flat.message.mailId.localeCompare(t.flat.message.mailId):n});let l=c.length,u=l>s,d=u?c.slice(0,s):c;return{totalMatched:l,returned:d.length,truncated:u,entries:d}}function L(e,t,n={}){let{projectIds:r,...i}=n,a=F(e,t),o=[],s=r!==void 0&&r.length>0?new Set(r):null;for(let e of a.projects)s&&!s.has(e.projectId)||(o=o.concat(e.messages));return te(o,i)}function R(e){if(typeof e!=`object`||!e)return!1;let t=e;if(typeof t.error==`string`)return!0;if(typeof t.error!=`object`||t.error===null)return!1;let n=t.error;return typeof n.code==`string`&&typeof n.message==`string`}async function z(e){let t=`/api/mailbox/messages/${encodeURIComponent(e.mailId)}/action`,n=await x(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(n.status===401&&w.getState().markAuthRequired(),!n.ok){let e=`${n.status} ${n.statusText}`;try{let t=await n.json();R(t)&&(e=typeof t.error==`string`?t.error:`${t.error.code}: ${t.error.message}`)}catch{}throw Error(`mailbox action failed — ${e}`)}return await n.json()}var B={markRead:e=>z({...e,action:`mark-read`}),acknowledge:e=>z({...e,action:`acknowledge`}),reopen:e=>z({...e,action:`reopen`}),softDelete:e=>z({...e,action:`soft-delete`}),restore:e=>z({...e,action:`restore`})};function V({mailId:e,actorId:t,projectId:n,isDeleted:r=!1,onAction:i,disabled:a=!1}){let[o,s]=(0,E.useState)(null),[c,l]=(0,E.useState)(null),u=async(t,n)=>{if(!(a||o!==null)){s(t),l(null);try{await n(),i?.(e,t)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(null)}}},d={mailId:e,readerId:t,projectId:n};return(0,D.jsxs)(`div`,{className:`hq-msg-actions`,children:[!r&&(0,D.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:a||o!==null,onClick:()=>u(`mark-read`,()=>B.markRead(d)),children:o===`mark-read`?`…`:`Mark read`}),!r&&(0,D.jsx)(`button`,{type:`button`,className:`hq-btn`,disabled:a||o!==null,onClick:()=>u(`acknowledge`,()=>B.acknowledge(d)),children:o===`acknowledge`?`…`:`Acknowledge`}),!r&&(0,D.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:a||o!==null,onClick:()=>u(`reopen`,()=>B.reopen(d)),children:o===`reopen`?`…`:`Reopen`}),!r&&(0,D.jsx)(`button`,{type:`button`,className:`hq-btn danger`,disabled:a||o!==null,onClick:()=>u(`soft-delete`,()=>B.softDelete(d)),children:o===`soft-delete`?`…`:`Delete`}),r&&(0,D.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:a||o!==null,onClick:()=>u(`restore`,()=>B.restore(d)),children:o===`restore`?`…`:`Restore`}),c!==null&&(0,D.jsx)(`span`,{className:`hq-msg-action-error`,title:c,children:c})]})}function H(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function U(e){return e.length<=14?e:`${e.slice(0,8)}…${e.slice(-4)}`}var W={note:{icon:a,tone:`info`},ask:{icon:u,tone:`warn`},assign:{icon:h,tone:`warn`},steer:{icon:u,tone:`warn`},btw:{icon:t,tone:`info`},broadcast:{icon:c,tone:`info`},status:{icon:p,tone:`idle`},result:{icon:i,tone:`running`},review:{icon:o,tone:`info`},control:{icon:f,tone:`error`}};Object.keys(W);var G=`hq-operator`;function K({flat:e,defaultExpanded:t}){let[n,i]=(0,E.useState)(!!t),a=e.message,o=a.hasBody||a.bodyPreview!==void 0&&a.bodyPreview.length>0,s=W[a.type]??{icon:r,tone:`info`},c=s.icon,l=`${a.from} → ${a.to}`;return(0,D.jsxs)(`div`,{className:`hq-msg`+(a.completed?` done`:``),children:[(0,D.jsxs)(`div`,{className:`hq-msg-head`,children:[(0,D.jsx)(`span`,{className:`hq-msg-icon`,title:a.type,children:(0,D.jsx)(c,{size:13})}),(0,D.jsx)(`span`,{className:`hq-pill `+s.tone,children:a.type}),a.audience===`leaders`&&(0,D.jsx)(`span`,{className:`hq-pill info`,children:`leaders only`}),a.priority===`high`&&(0,D.jsx)(`span`,{className:`hq-pill error`,children:`high`}),a.priority===`low`&&(0,D.jsx)(`span`,{className:`hq-pill idle`,children:`low`}),(0,D.jsx)(`span`,{className:`hq-msg-subject`,title:a.subject,children:a.subject||`(no subject)`}),(0,D.jsx)(`span`,{className:`hq-mono hq-msg-route`,children:l}),(0,D.jsx)(`span`,{className:`hq-mono hq-msg-time`,title:a.timestamp,children:H(a.timestamp)}),(0,D.jsx)(`span`,{className:`hq-mono hq-msg-id`,children:U(a.messageId)}),(0,D.jsx)(`span`,{className:`hq-msg-flag `+(a.completed?`done`:`open`),children:a.completed?`completed${a.completedBy===void 0?``:` by ${a.completedBy}`}`:`open`}),o&&(0,D.jsx)(`button`,{type:`button`,className:`hq-toggle hq-msg-toggle`,onClick:()=>i(e=>!e),"aria-expanded":n,"aria-label":n?`Collapse body`:`Expand body`,children:n?`▾`:`▸`})]}),n&&(0,D.jsxs)(`div`,{className:`hq-msg-body`,children:[a.bodyPreview!==void 0&&a.bodyPreview.length>0?(0,D.jsx)(`pre`,{className:`hq-msg-pre`,children:a.bodyPreview}):(0,D.jsx)(`div`,{className:`hq-empty hq-pad-sm`,children:`(empty body)`}),a.outcomePreview!==void 0&&a.outcomePreview.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`hq-msg-sublabel`,children:`outcome`}),(0,D.jsx)(`pre`,{className:`hq-msg-pre`,children:a.outcomePreview})]}),(0,D.jsxs)(`div`,{className:`hq-msg-meta`,children:[(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:`source:`}),` `,e.source]}),a.replyTo!==void 0&&(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:`reply to:`}),` `,U(a.replyTo)]}),a.senderSessionId!==void 0&&(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:`sender session:`}),` `,U(a.senderSessionId)]}),(a.readCount??0)>0&&(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:`reads:`}),` `,a.readCount]}),a.unreadCount!==void 0&&a.unreadCount>0&&(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:`unread:`}),` `,a.unreadCount]}),a.task!==void 0&&(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:`task:`}),` `,a.task.taskId??`—`,a.task.agentName===void 0?``:` · ${a.task.agentName}`,a.task.status===void 0?``:` (${a.task.status})`]})]}),e.projectId!==void 0&&(0,D.jsx)(V,{mailId:a.mailId,actorId:G,projectId:e.projectId})]})]})}var q=[`ask`,`assign`,`steer`,`review`,`result`,`status`,`broadcast`,`note`,`btw`,`control`],J=[`high`,`normal`,`low`];function Y({snapshot:e,events:t}={}){let n=w(e=>e.snapshot),r=e===void 0?n:e,i=t===void 0?w.getState().events:t,a=C(),o=(0,E.useMemo)(()=>{let e=a.mailbox;return{types:new Set(e.types),priorities:new Set(e.priorities),projectIds:new Set,includeCompleted:e.includeCompleted,query:e.query}},[a.mailbox]),[s,c]=(0,E.useReducer)(ee,o);(0,E.useEffect)(()=>{b({query:s.query,types:Array.from(s.types),priorities:Array.from(s.priorities),includeCompleted:s.includeCompleted})},[s.query,s.types,s.priorities,s.includeCompleted]);let l=(0,E.useMemo)(()=>F(r??null,i).projects.map(e=>({projectId:e.projectId,count:e.messages.length})),[r,i]),u=(0,E.useMemo)(()=>L(r??null,i,{types:Array.from(s.types),priorities:Array.from(s.priorities),projectIds:Array.from(s.projectIds),includeCompleted:s.includeCompleted,query:s.query||void 0,limit:500}),[r,i,s]),d=s.types.size+s.priorities.size+s.projectIds.size+ +!s.includeCompleted+ +(s.query.trim().length>0);return(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`hq-card-title`,children:[`Live mailbox feed · `,u.returned,` of `,u.totalMatched,` message`,u.totalMatched===1?``:`s`,u.truncated?` · refined to fit`:``]}),(0,D.jsxs)(`div`,{className:`hq-card hq-mailbox-filterbar`,children:[(0,D.jsx)(`label`,{className:`hq-label`,htmlFor:`mailbox-live-query`,children:`Search`}),(0,D.jsx)(`input`,{id:`mailbox-live-query`,className:`hq-input`,value:s.query,onChange:e=>c({type:`set-query`,value:e.target.value}),placeholder:`subject / sender / recipient / body…`}),(0,D.jsx)(X,{title:`Types`,children:q.map(e=>(0,D.jsx)(Z,{selected:s.types.has(e),label:e,onClick:()=>c({type:`toggle-type`,value:e})},e))}),(0,D.jsx)(X,{title:`Priority`,children:J.map(e=>(0,D.jsx)(Z,{selected:s.priorities.has(e),label:e,tone:e===`high`?`error`:e===`low`?`idle`:`info`,onClick:()=>c({type:`toggle-priority`,value:e})},e))}),l.length>0&&(0,D.jsx)(X,{title:`Projects`,children:l.map(e=>(0,D.jsx)(Z,{selected:s.projectIds.has(e.projectId),label:`${e.projectId} (${e.count})`,onClick:()=>c({type:`toggle-project`,value:e.projectId})},e.projectId))}),(0,D.jsxs)(`div`,{className:`hq-row hq-mailbox-filter-actions`,children:[(0,D.jsxs)(`label`,{className:`hq-check`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:s.includeCompleted,onChange:e=>c({type:`set-include-completed`,value:e.target.checked})}),`include completed`]}),(0,D.jsxs)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:d===0,onClick:()=>c({type:`clear-all`}),children:[`Clear filters`,d>0?` (${d})`:``]})]})]}),u.entries.length===0?(0,D.jsx)(`div`,{className:`hq-empty`,children:`No mailbox activity matches the current filters.`}):(0,D.jsx)(`div`,{className:`hq-msg-list hq-live-feed`,children:u.entries.map((e,t)=>(0,D.jsx)(K,{flat:e.flat,defaultExpanded:t===0&&s.query.trim().length>0},e.key))})]})}function X({title:e,children:t}){return(0,D.jsxs)(`div`,{className:`hq-filter-section`,children:[(0,D.jsx)(`div`,{className:`hq-msg-sublabel`,children:e}),(0,D.jsx)(`div`,{className:`hq-filter-chip-row`,children:t})]})}function Z({selected:e,label:t,onClick:n,tone:r=`info`}){return(0,D.jsx)(`button`,{type:`button`,className:`hq-filter-chip hq-pill ${r}${e?` selected`:``}`,"aria-pressed":e,onClick:n,children:t})}function ne(){let e=w(e=>e.snapshot),[t,r]=(0,E.useState)(`live`),{events:i}=T(`mailbox.event`,300),a=i,{projects:o,hasAnyActivity:s}=(0,E.useMemo)(()=>F(e,a),[e,a]),c=e?.totals.unreadMailboxMessages??0,u=e?.totals.incompleteMailboxMessages??0,d=(e?.mailboxes??[]).reduce((e,t)=>e+t.messageCount,0),f=(e?.mailboxes??[]).reduce((e,t)=>e+t.highPriorityCount,0),p=(e?.mailboxes??[]).reduce((e,t)=>e+t.onlineAgentCount,0),h=(0,E.useMemo)(()=>{let t=new Map;for(let n of e?.projects??[])t.set(n.projectId,{projectId:n.projectId,label:n.projectName});for(let e of o)t.has(e.projectId)||t.set(e.projectId,{projectId:e.projectId});return Array.from(t.values())},[e,o]);return o.length===0&&h.length===0?(0,D.jsxs)(`div`,{className:`hq-mailbox-zero`,children:[(0,D.jsx)(`span`,{className:`hq-mailbox-zero-icon`,"aria-hidden":`true`,children:(0,D.jsx)(_,{size:26})}),(0,D.jsx)(`span`,{className:`hq-section-kicker`,children:`Coordination inbox`}),(0,D.jsx)(`h2`,{children:`Waiting for mailbox traffic`}),(0,D.jsx)(`p`,{children:`Connected projects, inter-agent messages and durable prompts will appear here as soon as a client reports mailbox activity.`})]}):(0,D.jsxs)(`div`,{className:`hq-screen hq-mailbox-screen`,children:[(0,D.jsxs)(`section`,{className:`hq-screen-hero hq-mailbox-hero`,"aria-label":`Mailbox command summary`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`hq-section-kicker`,children:`Coordination inbox`}),(0,D.jsx)(`h2`,{children:c>0?`${c} message${c===1?``:`s`} ${c===1?`needs`:`need`} review`:`Coordination is clear`}),(0,D.jsx)(`p`,{children:`Live cross-project traffic, durable prompts and unresolved coordination work share one operator inbox.`}),(0,D.jsxs)(`div`,{className:`hq-mailbox-hero-state`,children:[(0,D.jsxs)(`span`,{className:`hq-pill active`,children:[(0,D.jsx)(n,{size:11}),` live sync`]}),(0,D.jsxs)(`span`,{className:`hq-mono hq-text-dim`,children:[`Mailbox Activity — `,o.length,` project`,o.length===1?``:`s`,` ·`,` `,c,` unread · `,u,` incomplete`,s?` · detailed messages available`:``]})]})]}),(0,D.jsxs)(`div`,{className:`hq-hero-metrics`,children:[(0,D.jsx)(Q,{label:`messages`,value:d}),(0,D.jsx)(Q,{label:`unread`,value:c,tone:c>0?`warn`:`ok`}),(0,D.jsx)(Q,{label:`high priority`,value:f,tone:f>0?`error`:`ok`}),(0,D.jsx)(Q,{label:`online agents`,value:p,tone:p>0?`ok`:void 0})]})]}),(0,D.jsxs)(`div`,{className:`hq-mailbox-command-strip`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`strong`,{children:`Durable delivery`}),(0,D.jsx)(`span`,{children:`Write directly to a project mailbox, even when no agent is currently connected.`})]}),(0,D.jsx)(k,{projects:h})]}),(0,D.jsxs)(`div`,{className:`hq-mailbox-workspace-head`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`hq-section-kicker`,children:`Message workspace`}),(0,D.jsx)(`strong`,{children:t===`live`?`Unified timeline`:`Project channels`})]}),(0,D.jsxs)(`div`,{className:`hq-mailbox-modebar`,role:`tablist`,"aria-label":`Mailbox view mode`,children:[(0,D.jsxs)(`button`,{type:`button`,role:`tab`,className:`hq-btn secondary`+(t===`live`?` hq-btn-selected`:``),"aria-selected":t===`live`,onClick:()=>r(`live`),children:[(0,D.jsx)(l,{size:13}),` Live feed`]}),(0,D.jsxs)(`button`,{type:`button`,role:`tab`,className:`hq-btn secondary`+(t===`grouped`?` hq-btn-selected`:``),"aria-selected":t===`grouped`,onClick:()=>r(`grouped`),children:[(0,D.jsx)(m,{size:13}),` Grouped by project`]})]})]}),(0,D.jsx)(`div`,{className:`hq-mailbox-workspace`,children:t===`live`?(0,D.jsx)(Y,{snapshot:e,events:a}):o.map(e=>(0,D.jsx)(re,{group:e},e.projectId))})]})}function Q({label:e,value:t,tone:n}){return(0,D.jsxs)(`div`,{className:`hq-hero-metric hq-mailbox-metric`,"data-tone":n,children:[(0,D.jsx)(n===`error`?g:e===`online agents`?v:_,{size:13}),(0,D.jsx)(`strong`,{children:t}),(0,D.jsx)(`span`,{children:e})]})}function re({group:e}){let[t,n]=(0,E.useState)(!0);return(0,D.jsxs)(`div`,{className:`hq-card hq-mailbox-project-card`,children:[(0,D.jsxs)(`div`,{className:`hq-row hq-row-baseline`,children:[(0,D.jsx)(`button`,{type:`button`,className:`hq-toggle`,onClick:()=>n(e=>!e),"aria-label":t?`Collapse project messages`:`Expand project messages`,children:t?`▾`:`▸`}),(0,D.jsx)(`span`,{className:`hq-text-bright`,children:e.projectId}),e.scope!==void 0&&(0,D.jsx)(`span`,{className:`hq-pill info`,children:e.scope}),e.mailboxId!==void 0&&(0,D.jsx)(`span`,{className:`hq-mono hq-text-dim`,children:e.mailboxId}),(0,D.jsxs)(`span`,{className:`hq-mono hq-text-dim hq-ml-auto`,children:[e.messages.length,` message`,e.messages.length===1?``:`s`]})]}),(0,D.jsxs)(`div`,{className:`hq-grid hq-mt-8`,style:{gridTemplateColumns:`repeat(5,1fr)`},children:[(0,D.jsx)($,{label:`messages`,value:e.messages.length}),(0,D.jsx)($,{label:`unread`,value:e.unreadCount,accent:e.unreadCount>0?`amber`:void 0}),(0,D.jsx)($,{label:`incomplete`,value:e.incompleteCount,accent:e.incompleteCount>0?`red`:void 0}),(0,D.jsx)($,{label:`high-priority`,value:e.highPriorityCount,accent:e.highPriorityCount>0?`red`:void 0}),(0,D.jsx)($,{label:`online agents`,value:e.onlineAgentCount,accent:e.onlineAgentCount>0?`green`:void 0})]}),t&&e.messages.length>0&&(0,D.jsx)(`div`,{className:`hq-msg-list hq-mt-12`,children:e.messages.map(e=>(0,D.jsx)(K,{flat:e},e.key))}),t&&e.messages.length===0&&(0,D.jsx)(`div`,{className:`hq-empty hq-cockpit-empty`,children:`Snapshot counters reported for this project, but no detailed mailbox events have streamed yet.`})]})}function $({label:e,value:t,accent:n}){return(0,D.jsxs)(`div`,{className:`hq-text-center`,children:[(0,D.jsx)(`div`,{className:`hq-stat-num`,style:{color:n===`amber`?`var(--amber)`:n===`red`?`var(--red)`:n===`green`?`var(--green)`:`var(--text)`},children:t}),(0,D.jsx)(`div`,{className:`hq-stat-label`,children:e})]})}export{ne as MailboxView};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{B as t,D as n,H as r,It as i,P as a,S as o,U as s,V as c,Y as l,Z as u,Zt as d,_ as f,dt as p,et as m,k as h,l as g,rt as _,s as v}from"./icons-Cxo3pc0p.js";import{i as y}from"./markdown-jMopG_H4.js";import{a as b,d as x,l as S,o as C,u as w}from"./index-BYuL7DL0.js";import{t as T}from"./use-backfilled-events-CnQ_BlHx.js";var E=e(d(),1),D=y(),O=[{value:`note`,label:`note — general information`},{value:`ask`,label:`ask — reply required`},{value:`assign`,label:`assign — work ownership`},{value:`steer`,label:`steer — redirect the current work`},{value:`btw`,label:`btw — FYI, no action required`},{value:`queue`,label:`queue — note for the next agent`},{value:`broadcast`,label:`broadcast — all agents in the project`},{value:`status`,label:`status — meaningful checkpoint`},{value:`result`,label:`result — completed output/evidence`},{value:`review`,label:`review — passive inspection request`}];function k({projects:e,sender:t}){let n=t??S,[r,i]=(0,E.useState)(!1),[a,o]=(0,E.useState)(``),[c,l]=(0,E.useState)(`steer`),[u,d]=(0,E.useState)(`leader`),[f,p]=(0,E.useState)(`normal`),[m,h]=(0,E.useState)(!1),[g,_]=(0,E.useState)(``),[v,y]=(0,E.useState)(``),[b,x]=(0,E.useState)({phase:`idle`}),C=a||e[0]?.projectId||``,w=b.phase!==`sending`&&v.trim().length>0&&C.length>0,T=async()=>{if(w){x({phase:`sending`});try{let e=await n({projectId:C,type:c,...c===`broadcast`?{}:{to:u.trim()||`leader`},subject:g.trim()||`HQ prompt`,body:v.trim(),priority:f,audience:m?`leaders`:`all`});x({phase:`sent`,messageId:e.messageId}),y(``)}catch(e){x({phase:`error`,message:e instanceof Error?e.message:String(e)})}}};return r?(0,D.jsxs)(`div`,{className:`hq-card hq-composer`,children:[(0,D.jsxs)(`div`,{className:`hq-row hq-row-baseline`,children:[(0,D.jsx)(`span`,{className:`hq-card-title hq-title-inline`,children:`Send to project mailbox`}),(0,D.jsx)(`span`,{className:`hq-composer-hint`,children:`lands in the mailbox file — picked up by the next agent, no live client needed`}),(0,D.jsx)(`button`,{type:`button`,className:`hq-toggle hq-ml-auto`,"aria-label":`Collapse composer`,onClick:()=>i(!1),children:`▾`})]}),(0,D.jsxs)(`div`,{className:`hq-composer-grid`,children:[(0,D.jsxs)(`label`,{className:`hq-composer-field`,children:[(0,D.jsx)(`span`,{children:`project`}),(0,D.jsx)(`select`,{className:`hq-select`,value:C,onChange:e=>o(e.target.value),children:e.map(e=>(0,D.jsx)(`option`,{value:e.projectId,children:e.label??e.projectId},e.projectId))})]}),(0,D.jsxs)(`label`,{className:`hq-composer-field`,children:[(0,D.jsx)(`span`,{children:`type`}),(0,D.jsx)(`select`,{className:`hq-select`,value:c,onChange:e=>l(e.target.value),children:O.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),c!==`broadcast`&&(0,D.jsxs)(`label`,{className:`hq-composer-field`,children:[(0,D.jsx)(`span`,{children:`to`}),(0,D.jsx)(`input`,{className:`hq-input`,value:u,placeholder:`leader`,onChange:e=>d(e.target.value)})]}),(0,D.jsxs)(`label`,{className:`hq-composer-field`,children:[(0,D.jsx)(`span`,{children:`audience`}),(0,D.jsxs)(`select`,{className:`hq-select`,value:m?`leaders`:`all`,onChange:e=>h(e.target.value===`leaders`),children:[(0,D.jsx)(`option`,{value:`all`,children:`all agents`}),(0,D.jsx)(`option`,{value:`leaders`,children:`leaders only — subagents cannot consume`})]})]}),(0,D.jsxs)(`label`,{className:`hq-composer-field`,children:[(0,D.jsx)(`span`,{children:`priority`}),(0,D.jsxs)(`select`,{className:`hq-select`,value:f,onChange:e=>p(e.target.value),children:[(0,D.jsx)(`option`,{value:`high`,children:`high`}),(0,D.jsx)(`option`,{value:`normal`,children:`normal`}),(0,D.jsx)(`option`,{value:`low`,children:`low`})]})]})]}),(0,D.jsx)(`input`,{className:`hq-input`,value:g,placeholder:`subject (optional)`,onChange:e=>_(e.target.value)}),(0,D.jsx)(`textarea`,{className:`hq-input hq-composer-body`,value:v,rows:3,placeholder:`Message body — e.g. “after the current task, run the full test suite”`,onChange:e=>y(e.target.value)}),(0,D.jsxs)(`div`,{className:`hq-row`,children:[(0,D.jsx)(`button`,{type:`button`,className:`hq-btn`,disabled:!w,onClick:()=>void T(),children:b.phase===`sending`?`Sending…`:`Send`}),b.phase===`sent`&&(0,D.jsxs)(`span`,{className:`hq-composer-status ok`,children:[`delivered`,b.messageId===void 0?``:` · ${b.messageId.slice(0,8)}`]}),b.phase===`error`&&(0,D.jsx)(`span`,{className:`hq-composer-status err`,title:b.message,children:b.message})]})]}):(0,D.jsxs)(`div`,{className:`hq-composer-bar`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`hq-btn`,disabled:e.length===0,title:e.length===0?`No projects reported yet — connect a client first`:`Write a message into a project mailbox (works with zero connected agents)`,onClick:()=>i(!0),children:[(0,D.jsx)(s,{size:13}),` Compose`]}),b.phase===`sent`&&(0,D.jsxs)(`span`,{className:`hq-composer-status ok`,children:[`delivered`,b.messageId===void 0?``:` · ${b.messageId.slice(0,8)}`]})]})}function A(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.mailboxId==`string`&&(t.scope===`project`||t.scope===`global`)&&Array.isArray(t.messages)&&Array.isArray(t.agents)&&typeof t.totals==`object`&&t.totals!==null}function j(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.mailboxId==`string`&&typeof t.action==`string`&&(t.message===void 0||typeof t.message==`object`)}function M(e,t){let n=e.get(t);return n===void 0&&(n={projectId:t,messages:[],countersFromSnapshot:!1,onlineAgentCount:0,highPriorityCount:0,unreadCount:0,incompleteCount:0},e.set(t,n)),n}function N(e){let t=0,n=0,r=0;for(let i of e){let e=i.message;e.priority===`high`&&(t+=1),e.completed||(r+=1,(e.readCount??0)===0&&(n+=1))}return{highPriorityCount:t,unreadCount:n,incompleteCount:r}}function P(e){let t=new Map;for(let n of e)(t.get(n.message.mailId)===void 0||n.source===`event`)&&t.set(n.message.mailId,n);return Array.from(t.values()).sort((e,t)=>t.message.timestamp.localeCompare(e.message.timestamp))}function F(e,t){let n=new Map;if(e!==null)for(let t of e.mailboxes){let e=M(n,t.projectId);e.mailboxId=t.mailboxId,e.scope=t.scope,e.onlineAgentCount=t.onlineAgentCount,e.highPriorityCount=t.highPriorityCount,e.unreadCount=t.unreadCount,e.incompleteCount=t.incompleteCount,e.countersFromSnapshot=!0}for(let e of t){if(e.type!==`mailbox.snapshot`||!A(e.payload))continue;let t=e.payload,r=M(n,e.projectId);r.mailboxId=t.mailboxId,r.scope=t.scope;for(let n of t.messages)r.messages.push({message:n,source:`snapshot`,key:`s:${e.id}:${n.messageId}`,projectId:e.projectId})}let r=new Map;for(let e of t){if(e.type!==`mailbox.event`||!j(e.payload))continue;let t=e.payload,i=M(n,e.projectId);i.mailboxId=t.mailboxId,i.scope=i.scope??`project`,t.message!==void 0&&!r.has(t.message.mailId)&&(r.set(t.message.mailId,i),i.messages.push({message:t.message,source:`event`,key:`e:${t.message.mailId}:${e.seq}`,projectId:e.projectId})),t.agent?.online&&(i.onlineAgentCount+=1)}for(let e of n.values())if(e.messages=P(e.messages),!e.countersFromSnapshot){let t=N(e.messages);e.highPriorityCount=t.highPriorityCount,e.unreadCount=t.unreadCount,e.incompleteCount=t.incompleteCount}let i=Array.from(n.values()).sort((e,t)=>{let n=e.messages[0]?.message.timestamp??``;return(t.messages[0]?.message.timestamp??``).localeCompare(n)});return{projects:i,hasAnyActivity:i.some(e=>e.messages.length>0)}}var I=Object.freeze({types:new Set,priorities:new Set,projectIds:new Set,includeCompleted:!0,query:``});function ee(e,t){switch(t.type){case`toggle-type`:{let n=new Set(e.types);return n.has(t.value)?n.delete(t.value):n.add(t.value),{...e,types:n}}case`toggle-priority`:{let n=new Set(e.priorities);return n.has(t.value)?n.delete(t.value):n.add(t.value),{...e,priorities:n}}case`toggle-project`:{let n=new Set(e.projectIds);return n.has(t.value)?n.delete(t.value):n.add(t.value),{...e,projectIds:n}}case`set-query`:return{...e,query:t.value};case`set-include-completed`:return{...e,includeCompleted:t.value};case`clear-all`:return I;default:return e}}function te(e,t={}){let n=t.includeCompleted??!0,r=t.types&&t.types.length>0?new Set(t.types):null,i=t.priorities&&t.priorities.length>0?new Set(t.priorities):null,a=t.projectIds&&t.projectIds.length>0?new Set(t.projectIds):null,o=t.query?.trim().toLowerCase()??``,s=t.limit??500,c=[];for(let t of e){let e=t.message;!n&&e.completed||r&&!r.has(e.type)||i&&!i.has(e.priority)||a||o.length>0&&!`${e.subject}\n${e.from}\n${e.to}\n${e.bodyPreview??``}`.toLowerCase().includes(o)||c.push({key:t.key,flat:t})}c.sort((e,t)=>{let n=t.flat.message.timestamp.localeCompare(e.flat.message.timestamp);return n===0?e.flat.message.mailId.localeCompare(t.flat.message.mailId):n});let l=c.length,u=l>s,d=u?c.slice(0,s):c;return{totalMatched:l,returned:d.length,truncated:u,entries:d}}function L(e,t,n={}){let{projectIds:r,...i}=n,a=F(e,t),o=[],s=r!==void 0&&r.length>0?new Set(r):null;for(let e of a.projects)s&&!s.has(e.projectId)||(o=o.concat(e.messages));return te(o,i)}function R(e){if(typeof e!=`object`||!e)return!1;let t=e;if(typeof t.error==`string`)return!0;if(typeof t.error!=`object`||t.error===null)return!1;let n=t.error;return typeof n.code==`string`&&typeof n.message==`string`}async function z(e){let t=`/api/mailbox/messages/${encodeURIComponent(e.mailId)}/action`,n=await x(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(n.status===401&&w.getState().markAuthRequired(),!n.ok){let e=`${n.status} ${n.statusText}`;try{let t=await n.json();R(t)&&(e=typeof t.error==`string`?t.error:`${t.error.code}: ${t.error.message}`)}catch{}throw Error(`mailbox action failed — ${e}`)}return await n.json()}var B={markRead:e=>z({...e,action:`mark-read`}),acknowledge:e=>z({...e,action:`acknowledge`}),reopen:e=>z({...e,action:`reopen`}),softDelete:e=>z({...e,action:`soft-delete`}),restore:e=>z({...e,action:`restore`})};function V({mailId:e,actorId:t,projectId:n,isDeleted:r=!1,onAction:i,disabled:a=!1}){let[o,s]=(0,E.useState)(null),[c,l]=(0,E.useState)(null),u=async(t,n)=>{if(!(a||o!==null)){s(t),l(null);try{await n(),i?.(e,t)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(null)}}},d={mailId:e,readerId:t,projectId:n};return(0,D.jsxs)(`div`,{className:`hq-msg-actions`,children:[!r&&(0,D.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:a||o!==null,onClick:()=>u(`mark-read`,()=>B.markRead(d)),children:o===`mark-read`?`…`:`Mark read`}),!r&&(0,D.jsx)(`button`,{type:`button`,className:`hq-btn`,disabled:a||o!==null,onClick:()=>u(`acknowledge`,()=>B.acknowledge(d)),children:o===`acknowledge`?`…`:`Acknowledge`}),!r&&(0,D.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:a||o!==null,onClick:()=>u(`reopen`,()=>B.reopen(d)),children:o===`reopen`?`…`:`Reopen`}),!r&&(0,D.jsx)(`button`,{type:`button`,className:`hq-btn danger`,disabled:a||o!==null,onClick:()=>u(`soft-delete`,()=>B.softDelete(d)),children:o===`soft-delete`?`…`:`Delete`}),r&&(0,D.jsx)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:a||o!==null,onClick:()=>u(`restore`,()=>B.restore(d)),children:o===`restore`?`…`:`Restore`}),c!==null&&(0,D.jsx)(`span`,{className:`hq-msg-action-error`,title:c,children:c})]})}function H(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function U(e){return e.length<=14?e:`${e.slice(0,8)}…${e.slice(-4)}`}var W={note:{icon:a,tone:`info`},ask:{icon:u,tone:`warn`},assign:{icon:h,tone:`warn`},steer:{icon:u,tone:`warn`},btw:{icon:t,tone:`info`},broadcast:{icon:c,tone:`info`},status:{icon:p,tone:`idle`},result:{icon:i,tone:`running`},review:{icon:o,tone:`info`},control:{icon:f,tone:`error`}};Object.keys(W);var G=`hq-operator`;function K({flat:e,defaultExpanded:t}){let[n,i]=(0,E.useState)(!!t),a=e.message,o=a.hasBody||a.bodyPreview!==void 0&&a.bodyPreview.length>0,s=W[a.type]??{icon:r,tone:`info`},c=s.icon,l=`${a.from} → ${a.to}`;return(0,D.jsxs)(`div`,{className:`hq-msg`+(a.completed?` done`:``),children:[(0,D.jsxs)(`div`,{className:`hq-msg-head`,children:[(0,D.jsx)(`span`,{className:`hq-msg-icon`,title:a.type,children:(0,D.jsx)(c,{size:13})}),(0,D.jsx)(`span`,{className:`hq-pill `+s.tone,children:a.type}),a.audience===`leaders`&&(0,D.jsx)(`span`,{className:`hq-pill info`,children:`leaders only`}),a.priority===`high`&&(0,D.jsx)(`span`,{className:`hq-pill error`,children:`high`}),a.priority===`low`&&(0,D.jsx)(`span`,{className:`hq-pill idle`,children:`low`}),(0,D.jsx)(`span`,{className:`hq-msg-subject`,title:a.subject,children:a.subject||`(no subject)`}),(0,D.jsx)(`span`,{className:`hq-mono hq-msg-route`,children:l}),(0,D.jsx)(`span`,{className:`hq-mono hq-msg-time`,title:a.timestamp,children:H(a.timestamp)}),(0,D.jsx)(`span`,{className:`hq-mono hq-msg-id`,children:U(a.messageId)}),(0,D.jsx)(`span`,{className:`hq-msg-flag `+(a.completed?`done`:`open`),children:a.completed?`completed${a.completedBy===void 0?``:` by ${a.completedBy}`}`:`open`}),o&&(0,D.jsx)(`button`,{type:`button`,className:`hq-toggle hq-msg-toggle`,onClick:()=>i(e=>!e),"aria-expanded":n,"aria-label":n?`Collapse body`:`Expand body`,children:n?`▾`:`▸`})]}),n&&(0,D.jsxs)(`div`,{className:`hq-msg-body`,children:[a.bodyPreview!==void 0&&a.bodyPreview.length>0?(0,D.jsx)(`pre`,{className:`hq-msg-pre`,children:a.bodyPreview}):(0,D.jsx)(`div`,{className:`hq-empty hq-pad-sm`,children:`(empty body)`}),a.outcomePreview!==void 0&&a.outcomePreview.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`hq-msg-sublabel`,children:`outcome`}),(0,D.jsx)(`pre`,{className:`hq-msg-pre`,children:a.outcomePreview})]}),(0,D.jsxs)(`div`,{className:`hq-msg-meta`,children:[(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:`source:`}),` `,e.source]}),a.replyTo!==void 0&&(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:`reply to:`}),` `,U(a.replyTo)]}),a.senderSessionId!==void 0&&(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:`sender session:`}),` `,U(a.senderSessionId)]}),(a.readCount??0)>0&&(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:`reads:`}),` `,a.readCount]}),a.unreadCount!==void 0&&a.unreadCount>0&&(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:`unread:`}),` `,a.unreadCount]}),a.task!==void 0&&(0,D.jsxs)(`span`,{children:[(0,D.jsx)(`strong`,{children:`task:`}),` `,a.task.taskId??`—`,a.task.agentName===void 0?``:` · ${a.task.agentName}`,a.task.status===void 0?``:` (${a.task.status})`]})]}),e.projectId!==void 0&&(0,D.jsx)(V,{mailId:a.mailId,actorId:G,projectId:e.projectId})]})]})}var q=[`ask`,`assign`,`steer`,`review`,`result`,`status`,`broadcast`,`note`,`btw`,`control`],J=[`high`,`normal`,`low`];function Y({snapshot:e,events:t}={}){let n=w(e=>e.snapshot),r=e===void 0?n:e,i=t===void 0?w.getState().events:t,a=C(),o=(0,E.useMemo)(()=>{let e=a.mailbox;return{types:new Set(e.types),priorities:new Set(e.priorities),projectIds:new Set,includeCompleted:e.includeCompleted,query:e.query}},[a.mailbox]),[s,c]=(0,E.useReducer)(ee,o);(0,E.useEffect)(()=>{b({query:s.query,types:Array.from(s.types),priorities:Array.from(s.priorities),includeCompleted:s.includeCompleted})},[s.query,s.types,s.priorities,s.includeCompleted]);let l=(0,E.useMemo)(()=>F(r??null,i).projects.map(e=>({projectId:e.projectId,count:e.messages.length})),[r,i]),u=(0,E.useMemo)(()=>L(r??null,i,{types:Array.from(s.types),priorities:Array.from(s.priorities),projectIds:Array.from(s.projectIds),includeCompleted:s.includeCompleted,query:s.query||void 0,limit:500}),[r,i,s]),d=s.types.size+s.priorities.size+s.projectIds.size+ +!s.includeCompleted+ +(s.query.trim().length>0);return(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`hq-card-title`,children:[`Live mailbox feed · `,u.returned,` of `,u.totalMatched,` message`,u.totalMatched===1?``:`s`,u.truncated?` · refined to fit`:``]}),(0,D.jsxs)(`div`,{className:`hq-card hq-mailbox-filterbar`,children:[(0,D.jsx)(`label`,{className:`hq-label`,htmlFor:`mailbox-live-query`,children:`Search`}),(0,D.jsx)(`input`,{id:`mailbox-live-query`,className:`hq-input`,value:s.query,onChange:e=>c({type:`set-query`,value:e.target.value}),placeholder:`subject / sender / recipient / body…`}),(0,D.jsx)(X,{title:`Types`,children:q.map(e=>(0,D.jsx)(Z,{selected:s.types.has(e),label:e,onClick:()=>c({type:`toggle-type`,value:e})},e))}),(0,D.jsx)(X,{title:`Priority`,children:J.map(e=>(0,D.jsx)(Z,{selected:s.priorities.has(e),label:e,tone:e===`high`?`error`:e===`low`?`idle`:`info`,onClick:()=>c({type:`toggle-priority`,value:e})},e))}),l.length>0&&(0,D.jsx)(X,{title:`Projects`,children:l.map(e=>(0,D.jsx)(Z,{selected:s.projectIds.has(e.projectId),label:`${e.projectId} (${e.count})`,onClick:()=>c({type:`toggle-project`,value:e.projectId})},e.projectId))}),(0,D.jsxs)(`div`,{className:`hq-row hq-mailbox-filter-actions`,children:[(0,D.jsxs)(`label`,{className:`hq-check`,children:[(0,D.jsx)(`input`,{type:`checkbox`,checked:s.includeCompleted,onChange:e=>c({type:`set-include-completed`,value:e.target.checked})}),`include completed`]}),(0,D.jsxs)(`button`,{type:`button`,className:`hq-btn secondary`,disabled:d===0,onClick:()=>c({type:`clear-all`}),children:[`Clear filters`,d>0?` (${d})`:``]})]})]}),u.entries.length===0?(0,D.jsx)(`div`,{className:`hq-empty`,children:`No mailbox activity matches the current filters.`}):(0,D.jsx)(`div`,{className:`hq-msg-list hq-live-feed`,children:u.entries.map((e,t)=>(0,D.jsx)(K,{flat:e.flat,defaultExpanded:t===0&&s.query.trim().length>0},e.key))})]})}function X({title:e,children:t}){return(0,D.jsxs)(`div`,{className:`hq-filter-section`,children:[(0,D.jsx)(`div`,{className:`hq-msg-sublabel`,children:e}),(0,D.jsx)(`div`,{className:`hq-filter-chip-row`,children:t})]})}function Z({selected:e,label:t,onClick:n,tone:r=`info`}){return(0,D.jsx)(`button`,{type:`button`,className:`hq-filter-chip hq-pill ${r}${e?` selected`:``}`,"aria-pressed":e,onClick:n,children:t})}function ne(){let e=w(e=>e.snapshot),[t,r]=(0,E.useState)(`live`),{events:i}=T(`mailbox.event`,300),a=i,{projects:o,hasAnyActivity:s}=(0,E.useMemo)(()=>F(e,a),[e,a]),c=e?.totals.unreadMailboxMessages??0,u=e?.totals.incompleteMailboxMessages??0,d=(e?.mailboxes??[]).reduce((e,t)=>e+t.messageCount,0),f=(e?.mailboxes??[]).reduce((e,t)=>e+t.highPriorityCount,0),p=(e?.mailboxes??[]).reduce((e,t)=>e+t.onlineAgentCount,0),h=(0,E.useMemo)(()=>{let t=new Map;for(let n of e?.projects??[])t.set(n.projectId,{projectId:n.projectId,label:n.projectName});for(let e of o)t.has(e.projectId)||t.set(e.projectId,{projectId:e.projectId});return Array.from(t.values())},[e,o]);return o.length===0&&h.length===0?(0,D.jsxs)(`div`,{className:`hq-mailbox-zero`,children:[(0,D.jsx)(`span`,{className:`hq-mailbox-zero-icon`,"aria-hidden":`true`,children:(0,D.jsx)(_,{size:26})}),(0,D.jsx)(`span`,{className:`hq-section-kicker`,children:`Coordination inbox`}),(0,D.jsx)(`h2`,{children:`Waiting for mailbox traffic`}),(0,D.jsx)(`p`,{children:`Connected projects, inter-agent messages and durable prompts will appear here as soon as a client reports mailbox activity.`})]}):(0,D.jsxs)(`div`,{className:`hq-screen hq-mailbox-screen`,children:[(0,D.jsxs)(`section`,{className:`hq-screen-hero hq-mailbox-hero`,"aria-label":`Mailbox command summary`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`hq-section-kicker`,children:`Coordination inbox`}),(0,D.jsx)(`h2`,{children:c>0?`${c} message${c===1?``:`s`} ${c===1?`needs`:`need`} review`:`Coordination is clear`}),(0,D.jsx)(`p`,{children:`Live cross-project traffic, durable prompts and unresolved coordination work share one operator inbox.`}),(0,D.jsxs)(`div`,{className:`hq-mailbox-hero-state`,children:[(0,D.jsxs)(`span`,{className:`hq-pill active`,children:[(0,D.jsx)(n,{size:11}),` live sync`]}),(0,D.jsxs)(`span`,{className:`hq-mono hq-text-dim`,children:[`Mailbox Activity — `,o.length,` project`,o.length===1?``:`s`,` ·`,` `,c,` unread · `,u,` incomplete`,s?` · detailed messages available`:``]})]})]}),(0,D.jsxs)(`div`,{className:`hq-hero-metrics`,children:[(0,D.jsx)(Q,{label:`messages`,value:d}),(0,D.jsx)(Q,{label:`unread`,value:c,tone:c>0?`warn`:`ok`}),(0,D.jsx)(Q,{label:`high priority`,value:f,tone:f>0?`error`:`ok`}),(0,D.jsx)(Q,{label:`online agents`,value:p,tone:p>0?`ok`:void 0})]})]}),(0,D.jsxs)(`div`,{className:`hq-mailbox-command-strip`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`strong`,{children:`Durable delivery`}),(0,D.jsx)(`span`,{children:`Write directly to a project mailbox, even when no agent is currently connected.`})]}),(0,D.jsx)(k,{projects:h})]}),(0,D.jsxs)(`div`,{className:`hq-mailbox-workspace-head`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`hq-section-kicker`,children:`Message workspace`}),(0,D.jsx)(`strong`,{children:t===`live`?`Unified timeline`:`Project channels`})]}),(0,D.jsxs)(`div`,{className:`hq-mailbox-modebar`,role:`tablist`,"aria-label":`Mailbox view mode`,children:[(0,D.jsxs)(`button`,{type:`button`,role:`tab`,className:`hq-btn secondary`+(t===`live`?` hq-btn-selected`:``),"aria-selected":t===`live`,onClick:()=>r(`live`),children:[(0,D.jsx)(l,{size:13}),` Live feed`]}),(0,D.jsxs)(`button`,{type:`button`,role:`tab`,className:`hq-btn secondary`+(t===`grouped`?` hq-btn-selected`:``),"aria-selected":t===`grouped`,onClick:()=>r(`grouped`),children:[(0,D.jsx)(m,{size:13}),` Grouped by project`]})]})]}),(0,D.jsx)(`div`,{className:`hq-mailbox-workspace`,children:t===`live`?(0,D.jsx)(Y,{snapshot:e,events:a}):o.map(e=>(0,D.jsx)(re,{group:e},e.projectId))})]})}function Q({label:e,value:t,tone:n}){return(0,D.jsxs)(`div`,{className:`hq-hero-metric hq-mailbox-metric`,"data-tone":n,children:[(0,D.jsx)(n===`error`?g:e===`online agents`?v:_,{size:13}),(0,D.jsx)(`strong`,{children:t}),(0,D.jsx)(`span`,{children:e})]})}function re({group:e}){let[t,n]=(0,E.useState)(!0);return(0,D.jsxs)(`div`,{className:`hq-card hq-mailbox-project-card`,children:[(0,D.jsxs)(`div`,{className:`hq-row hq-row-baseline`,children:[(0,D.jsx)(`button`,{type:`button`,className:`hq-toggle`,onClick:()=>n(e=>!e),"aria-label":t?`Collapse project messages`:`Expand project messages`,children:t?`▾`:`▸`}),(0,D.jsx)(`span`,{className:`hq-text-bright`,children:e.projectId}),e.scope!==void 0&&(0,D.jsx)(`span`,{className:`hq-pill info`,children:e.scope}),e.mailboxId!==void 0&&(0,D.jsx)(`span`,{className:`hq-mono hq-text-dim`,children:e.mailboxId}),(0,D.jsxs)(`span`,{className:`hq-mono hq-text-dim hq-ml-auto`,children:[e.messages.length,` message`,e.messages.length===1?``:`s`]})]}),(0,D.jsxs)(`div`,{className:`hq-grid hq-mt-8`,style:{gridTemplateColumns:`repeat(5,1fr)`},children:[(0,D.jsx)($,{label:`messages`,value:e.messages.length}),(0,D.jsx)($,{label:`unread`,value:e.unreadCount,accent:e.unreadCount>0?`amber`:void 0}),(0,D.jsx)($,{label:`incomplete`,value:e.incompleteCount,accent:e.incompleteCount>0?`red`:void 0}),(0,D.jsx)($,{label:`high-priority`,value:e.highPriorityCount,accent:e.highPriorityCount>0?`red`:void 0}),(0,D.jsx)($,{label:`online agents`,value:e.onlineAgentCount,accent:e.onlineAgentCount>0?`green`:void 0})]}),t&&e.messages.length>0&&(0,D.jsx)(`div`,{className:`hq-msg-list hq-mt-12`,children:e.messages.map(e=>(0,D.jsx)(K,{flat:e},e.key))}),t&&e.messages.length===0&&(0,D.jsx)(`div`,{className:`hq-empty hq-cockpit-empty`,children:`Snapshot counters reported for this project, but no detailed mailbox events have streamed yet.`})]})}function $({label:e,value:t,accent:n}){return(0,D.jsxs)(`div`,{className:`hq-text-center`,children:[(0,D.jsx)(`div`,{className:`hq-stat-num`,style:{color:n===`amber`?`var(--amber)`:n===`red`?`var(--red)`:n===`green`?`var(--green)`:`var(--text)`},children:t}),(0,D.jsx)(`div`,{className:`hq-stat-label`,children:e})]})}export{ne as MailboxView};
|