@useorgx/openclaw-plugin 0.7.23 → 0.7.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dashboard/dist/assets/{m2smti3F.js → B6VftyY6.js} +1 -1
  2. package/dashboard/dist/assets/B6VftyY6.js.br +0 -0
  3. package/dashboard/dist/assets/B6VftyY6.js.gz +0 -0
  4. package/dashboard/dist/assets/{D-FuHfT8.js → BANQdlC4.js} +1 -1
  5. package/dashboard/dist/assets/BANQdlC4.js.br +0 -0
  6. package/dashboard/dist/assets/BANQdlC4.js.gz +0 -0
  7. package/dashboard/dist/assets/{DDCPrZRt.js → BPL4CL3c.js} +1 -1
  8. package/dashboard/dist/assets/BPL4CL3c.js.br +0 -0
  9. package/dashboard/dist/assets/BPL4CL3c.js.gz +0 -0
  10. package/dashboard/dist/assets/{D0PN5_vY.js → BZCkOZ20.js} +1 -1
  11. package/dashboard/dist/assets/BZCkOZ20.js.br +0 -0
  12. package/dashboard/dist/assets/BZCkOZ20.js.gz +0 -0
  13. package/dashboard/dist/assets/{DNQ-iFO2.js → B_LdOJUa.js} +1 -1
  14. package/dashboard/dist/assets/B_LdOJUa.js.br +0 -0
  15. package/dashboard/dist/assets/B_LdOJUa.js.gz +0 -0
  16. package/dashboard/dist/assets/Bfp-wdwb.css +1 -0
  17. package/dashboard/dist/assets/Bfp-wdwb.css.br +0 -0
  18. package/dashboard/dist/assets/{C1u2SGin.css.gz → Bfp-wdwb.css.gz} +0 -0
  19. package/dashboard/dist/assets/{CZXS5i_5.js → BvFcH_Iy.js} +1 -1
  20. package/dashboard/dist/assets/BvFcH_Iy.js.br +0 -0
  21. package/dashboard/dist/assets/BvFcH_Iy.js.gz +0 -0
  22. package/dashboard/dist/assets/C0i7ABUU.js +212 -0
  23. package/dashboard/dist/assets/C0i7ABUU.js.br +0 -0
  24. package/dashboard/dist/assets/C0i7ABUU.js.gz +0 -0
  25. package/dashboard/dist/assets/CFB0MM7j.js +1 -0
  26. package/dashboard/dist/assets/CFB0MM7j.js.br +0 -0
  27. package/dashboard/dist/assets/CFB0MM7j.js.gz +0 -0
  28. package/dashboard/dist/assets/{OlLPtzdz.js → CQSRb1yu.js} +1 -1
  29. package/dashboard/dist/assets/CQSRb1yu.js.br +0 -0
  30. package/dashboard/dist/assets/CQSRb1yu.js.gz +0 -0
  31. package/dashboard/dist/assets/{CbVWL74-.js → CUoQoSm-.js} +1 -1
  32. package/dashboard/dist/assets/CUoQoSm-.js.br +0 -0
  33. package/dashboard/dist/assets/CUoQoSm-.js.gz +0 -0
  34. package/dashboard/dist/assets/Ckd1R1iE.js +1 -0
  35. package/dashboard/dist/assets/Ckd1R1iE.js.br +0 -0
  36. package/dashboard/dist/assets/Ckd1R1iE.js.gz +0 -0
  37. package/dashboard/dist/assets/{DhPuHPK7.js → CqRNb2EL.js} +1 -1
  38. package/dashboard/dist/assets/CqRNb2EL.js.br +0 -0
  39. package/dashboard/dist/assets/CqRNb2EL.js.gz +0 -0
  40. package/dashboard/dist/assets/{CGJiHCIx.js → DClUc9rw.js} +1 -1
  41. package/dashboard/dist/assets/DClUc9rw.js.br +0 -0
  42. package/dashboard/dist/assets/DClUc9rw.js.gz +0 -0
  43. package/dashboard/dist/assets/DF2PMTwT.js +1 -0
  44. package/dashboard/dist/assets/DF2PMTwT.js.br +0 -0
  45. package/dashboard/dist/assets/DF2PMTwT.js.gz +0 -0
  46. package/dashboard/dist/assets/{RN4M9u9W.js → DJYl7gyA.js} +1 -1
  47. package/dashboard/dist/assets/DJYl7gyA.js.br +0 -0
  48. package/dashboard/dist/assets/DJYl7gyA.js.gz +0 -0
  49. package/dashboard/dist/assets/{BrMXbzQ-.js → DZtNMX0t.js} +1 -1
  50. package/dashboard/dist/assets/DZtNMX0t.js.br +0 -0
  51. package/dashboard/dist/assets/DZtNMX0t.js.gz +0 -0
  52. package/dashboard/dist/assets/{LOFrVoPD.js → DlEa8PI0.js} +1 -1
  53. package/dashboard/dist/assets/DlEa8PI0.js.br +0 -0
  54. package/dashboard/dist/assets/DlEa8PI0.js.gz +0 -0
  55. package/dashboard/dist/assets/M4QxcXjh.js +1 -0
  56. package/dashboard/dist/assets/M4QxcXjh.js.br +0 -0
  57. package/dashboard/dist/assets/M4QxcXjh.js.gz +0 -0
  58. package/dashboard/dist/assets/{nra1yvJX.js → MrW1ixGx.js} +1 -1
  59. package/dashboard/dist/assets/MrW1ixGx.js.br +0 -0
  60. package/dashboard/dist/assets/MrW1ixGx.js.gz +0 -0
  61. package/dashboard/dist/index.html +2 -2
  62. package/dashboard/dist/index.html.br +0 -0
  63. package/dashboard/dist/index.html.gz +0 -0
  64. package/dist/activity-store.js +68 -8
  65. package/dist/contracts/shared-types.d.ts +28 -0
  66. package/dist/http/helpers/auto-continue-engine.js +235 -32
  67. package/dist/http/helpers/triage-mapper.js +285 -6
  68. package/dist/http/helpers/value-utils.d.ts +1 -0
  69. package/dist/http/helpers/value-utils.js +17 -0
  70. package/dist/http/index.js +89 -3
  71. package/dist/http/routes/live-triage.js +6 -1
  72. package/dist/http/routes/mission-control-actions.d.ts +9 -0
  73. package/dist/http/routes/mission-control-actions.js +157 -7
  74. package/dist/http/routes/mission-control-read.d.ts +9 -0
  75. package/dist/http/routes/mission-control-read.js +33 -0
  76. package/dist/stores/sqlite-state.d.ts +1 -1
  77. package/dist/stores/sqlite-state.js +153 -2
  78. package/package.json +1 -1
  79. package/dashboard/dist/assets/9gFmK3Kr.js +0 -1
  80. package/dashboard/dist/assets/9gFmK3Kr.js.br +0 -0
  81. package/dashboard/dist/assets/9gFmK3Kr.js.gz +0 -0
  82. package/dashboard/dist/assets/BrMXbzQ-.js.br +0 -0
  83. package/dashboard/dist/assets/BrMXbzQ-.js.gz +0 -0
  84. package/dashboard/dist/assets/C1u2SGin.css +0 -1
  85. package/dashboard/dist/assets/C1u2SGin.css.br +0 -0
  86. package/dashboard/dist/assets/CGJiHCIx.js.br +0 -0
  87. package/dashboard/dist/assets/CGJiHCIx.js.gz +0 -0
  88. package/dashboard/dist/assets/CSd4rSuU.js +0 -212
  89. package/dashboard/dist/assets/CSd4rSuU.js.br +0 -0
  90. package/dashboard/dist/assets/CSd4rSuU.js.gz +0 -0
  91. package/dashboard/dist/assets/CZXS5i_5.js.br +0 -0
  92. package/dashboard/dist/assets/CZXS5i_5.js.gz +0 -0
  93. package/dashboard/dist/assets/CbVWL74-.js.br +0 -0
  94. package/dashboard/dist/assets/CbVWL74-.js.gz +0 -0
  95. package/dashboard/dist/assets/D-FuHfT8.js.br +0 -0
  96. package/dashboard/dist/assets/D-FuHfT8.js.gz +0 -0
  97. package/dashboard/dist/assets/D0PN5_vY.js.br +0 -0
  98. package/dashboard/dist/assets/D0PN5_vY.js.gz +0 -0
  99. package/dashboard/dist/assets/DDCPrZRt.js.br +0 -0
  100. package/dashboard/dist/assets/DDCPrZRt.js.gz +0 -0
  101. package/dashboard/dist/assets/DNQ-iFO2.js.br +0 -0
  102. package/dashboard/dist/assets/DNQ-iFO2.js.gz +0 -0
  103. package/dashboard/dist/assets/DhPuHPK7.js.br +0 -0
  104. package/dashboard/dist/assets/DhPuHPK7.js.gz +0 -0
  105. package/dashboard/dist/assets/Dhz7qPtn.js +0 -1
  106. package/dashboard/dist/assets/Dhz7qPtn.js.br +0 -0
  107. package/dashboard/dist/assets/Dhz7qPtn.js.gz +0 -0
  108. package/dashboard/dist/assets/LOFrVoPD.js.br +0 -0
  109. package/dashboard/dist/assets/LOFrVoPD.js.gz +0 -0
  110. package/dashboard/dist/assets/OlLPtzdz.js.br +0 -0
  111. package/dashboard/dist/assets/OlLPtzdz.js.gz +0 -0
  112. package/dashboard/dist/assets/RN4M9u9W.js.br +0 -0
  113. package/dashboard/dist/assets/RN4M9u9W.js.gz +0 -0
  114. package/dashboard/dist/assets/VCHu272d.js +0 -1
  115. package/dashboard/dist/assets/VCHu272d.js.br +0 -0
  116. package/dashboard/dist/assets/VCHu272d.js.gz +0 -0
  117. package/dashboard/dist/assets/m2smti3F.js.br +0 -0
  118. package/dashboard/dist/assets/m2smti3F.js.gz +0 -0
  119. package/dashboard/dist/assets/nra1yvJX.js.br +0 -0
  120. package/dashboard/dist/assets/nra1yvJX.js.gz +0 -0
  121. package/dashboard/dist/assets/qLX6NZ-J.js +0 -1
  122. package/dashboard/dist/assets/qLX6NZ-J.js.br +0 -0
  123. package/dashboard/dist/assets/qLX6NZ-J.js.gz +0 -0
@@ -1 +1 @@
1
- import{f as t}from"./CSd4rSuU.js";const e={QUEUED:"queued",RUNNING:"running",BLOCKED:"blocked",IDLE:"idle",COMPLETED:"completed"};function n(r){switch(r){case e.RUNNING:return"border-teal-300/35 bg-teal-400/[0.12] text-teal-100";case e.BLOCKED:return"border-amber-300/35 bg-amber-400/[0.12] text-amber-100";case e.IDLE:return"border-strong bg-white/[0.05] text-secondary";default:return"border-[#BFFF00]/30 bg-[#BFFF00]/12 text-[#E1FFB2]"}}function c(r){switch(r){case e.RUNNING:return"Running";case e.BLOCKED:return"Needs input";case e.IDLE:return"Idle";case e.COMPLETED:return"Completed";case e.QUEUED:return"Queued";default:return r.replace(/_/g," ")}}function o(r){switch(r){case e.QUEUED:case e.IDLE:return 0;case e.BLOCKED:return 1;case e.RUNNING:return 2;case e.COMPLETED:return 3;default:return 4}}function i(r){switch(r){case e.RUNNING:return"from-teal-300/0 via-teal-300/60 to-teal-300/0";case e.BLOCKED:return"from-amber-300/0 via-amber-300/55 to-amber-300/0";case e.IDLE:return"from-white/0 via-white/35 to-white/0";default:return"from-[#BFFF00]/0 via-[#BFFF00]/70 to-[#BFFF00]/0"}}function s(r){switch(r){case e.RUNNING:return"Current";case e.BLOCKED:return"Blocked on";default:return"Next"}}function E(r){switch(r){case e.RUNNING:return t.lime;case e.BLOCKED:return t.red;case e.IDLE:return t.iris;case e.QUEUED:return t.teal;default:return t.amber}}function d(r){switch(r){case e.RUNNING:return{background:`linear-gradient(to right, ${t.lime}, ${t.teal})`};case e.BLOCKED:return{background:`linear-gradient(to right, ${t.red}, ${t.amber})`};case e.IDLE:return{background:`linear-gradient(to right, ${t.iris}99, transparent)`};default:return{background:`linear-gradient(to right, ${t.lime}B3, ${t.teal}66)`}}}function l(r,a){if(a)return"Scope Under Review";switch(r){case e.COMPLETED:return"Completed Scope";case e.RUNNING:return"Current Work";case e.BLOCKED:return"Blocked Work";default:return"Next Work"}}function N(r){return r.some(a=>a.queueState===e.RUNNING)?e.RUNNING:r.some(a=>a.queueState===e.BLOCKED)?e.BLOCKED:r.some(a=>a.queueState===e.QUEUED)?e.QUEUED:r.some(a=>a.queueState===e.IDLE)?e.IDLE:e.COMPLETED}export{e as Q,c as a,n as b,i as c,N as d,s as e,d as f,E as g,o as q,l as w};
1
+ import{f as t}from"./C0i7ABUU.js";const e={QUEUED:"queued",RUNNING:"running",BLOCKED:"blocked",IDLE:"idle",COMPLETED:"completed"};function n(r){switch(r){case e.RUNNING:return"border-teal-300/35 bg-teal-400/[0.12] text-teal-100";case e.BLOCKED:return"border-amber-300/35 bg-amber-400/[0.12] text-amber-100";case e.IDLE:return"border-strong bg-white/[0.05] text-secondary";default:return"border-[#BFFF00]/30 bg-[#BFFF00]/12 text-[#E1FFB2]"}}function c(r){switch(r){case e.RUNNING:return"Running";case e.BLOCKED:return"Needs input";case e.IDLE:return"Idle";case e.COMPLETED:return"Completed";case e.QUEUED:return"Queued";default:return r.replace(/_/g," ")}}function o(r){switch(r){case e.QUEUED:case e.IDLE:return 0;case e.BLOCKED:return 1;case e.RUNNING:return 2;case e.COMPLETED:return 3;default:return 4}}function i(r){switch(r){case e.RUNNING:return"from-teal-300/0 via-teal-300/60 to-teal-300/0";case e.BLOCKED:return"from-amber-300/0 via-amber-300/55 to-amber-300/0";case e.IDLE:return"from-white/0 via-white/35 to-white/0";default:return"from-[#BFFF00]/0 via-[#BFFF00]/70 to-[#BFFF00]/0"}}function s(r){switch(r){case e.RUNNING:return"Current";case e.BLOCKED:return"Blocked on";default:return"Next"}}function E(r){switch(r){case e.RUNNING:return t.lime;case e.BLOCKED:return t.red;case e.IDLE:return t.iris;case e.QUEUED:return t.teal;default:return t.amber}}function d(r){switch(r){case e.RUNNING:return{background:`linear-gradient(to right, ${t.lime}, ${t.teal})`};case e.BLOCKED:return{background:`linear-gradient(to right, ${t.red}, ${t.amber})`};case e.IDLE:return{background:`linear-gradient(to right, ${t.iris}99, transparent)`};default:return{background:`linear-gradient(to right, ${t.lime}B3, ${t.teal}66)`}}}function l(r,a){if(a)return"Scope Under Review";switch(r){case e.COMPLETED:return"Completed Scope";case e.RUNNING:return"Current Work";case e.BLOCKED:return"Blocked Work";default:return"Next Work"}}function N(r){return r.some(a=>a.queueState===e.RUNNING)?e.RUNNING:r.some(a=>a.queueState===e.BLOCKED)?e.BLOCKED:r.some(a=>a.queueState===e.QUEUED)?e.QUEUED:r.some(a=>a.queueState===e.IDLE)?e.IDLE:e.COMPLETED}export{e as Q,c as a,n as b,i as c,N as d,s as e,d as f,E as g,o as q,l as w};
@@ -0,0 +1 @@
1
+ import{r as x,j as e}from"./Dj2k1r16.js";import{A,m as N}from"./eeHXe_OQ.js";function w(s){switch(s){case"decision_required":return"Decision required";case"blocked_intervention":return"Blocked — needs intervention";case"review_required":return"Review required";case"failure_diagnostic":return"Failure diagnostic";default:return s}}function g(s){switch(s){case"critical":return"#FF6B6B";case"high":return"#F5B700";case"medium":return"#0AD4C4";default:return"#8B8FA3"}}function k(s){const t=s.intervention,n=new Set;if(!t)return n.add("Intervention brief"),Array.from(n);const r=Array.isArray(t.evidence)&&t.evidence.length>0||s.proofBundle.artifactRefs.length>0||s.proofBundle.logRefs.length>0||s.proofBundle.prRefs.length>0||s.proofBundle.fileChanges.length>0,a=Array.isArray(t.scopeHierarchy)&&t.scopeHierarchy.length>0,o=!!t.requiredAction||!!t.recommendedAction;return s.kind==="decision_required"||s.kind==="review_required"?(!t.decisionPrompt&&!t.decisionSummary&&n.add("Decision prompt"),(!Array.isArray(t.decisionOptions)||t.decisionOptions.length===0)&&n.add("Decision options"),o||n.add("Recommended action"),r||n.add("Supporting evidence"),a||n.add("Affected scope"),Array.from(n)):(!t.blockerReason&&!s.summary&&n.add("Blocker reason"),o||n.add("Required action"),!t.waitingOn&&!t.currentRunState&&n.add("What is blocked"),r||n.add("Supporting evidence"),a||n.add("Affected scope"),Array.from(n))}function C({missing:s}){return s.length===0?null:e.jsxs("div",{className:"rounded-xl border border-amber-300/20 bg-amber-300/[0.08] px-3.5 py-3",children:[e.jsx("p",{className:"text-micro font-semibold uppercase tracking-wider text-amber-100",children:"Signal incomplete"}),e.jsx("p",{className:"mt-1 text-caption text-amber-50/90",children:"This intervention is missing context the operator needs to act cleanly."}),e.jsx("ul",{className:"mt-2 space-y-0.5",children:s.map(t=>e.jsxs("li",{className:"text-caption text-amber-100/85",children:["- ",t]},t))}),e.jsx("p",{className:"mt-2 text-micro text-amber-100/60",children:"Raw diagnostics remain available under Technical details."})]})}function j({children:s}){return e.jsx("h4",{className:"text-micro font-semibold uppercase tracking-wider text-muted mb-1.5",children:s})}function B({item:s}){const t=s.proofBundle;return t.artifactRefs.length>0||t.fileChanges.length>0||t.prRefs.length>0||t.logRefs.length>0||t.decisionRefs.length>0?e.jsxs("div",{children:[e.jsx(j,{children:"Proof"}),e.jsxs("div",{className:"space-y-1",children:[t.prRefs.map((r,a)=>e.jsx(m,{icon:"pr",label:r},`pr-${a}`)),t.fileChanges.map((r,a)=>e.jsx(m,{icon:"file",label:r},`file-${a}`)),t.artifactRefs.map((r,a)=>e.jsx(m,{icon:"artifact",label:r},`art-${a}`)),t.logRefs.map((r,a)=>e.jsx(m,{icon:"log",label:r},`log-${a}`)),t.decisionRefs.map((r,a)=>e.jsx(m,{icon:"decision",label:r},`dec-${a}`))]})]}):null}function m({icon:s,label:t}){const n=s==="pr"?"⎇":s==="file"?"◇":s==="log"?"▸":s==="decision"?"◈":"▪";return e.jsxs("div",{className:"flex items-center gap-2 rounded bg-white/[0.03] px-2 py-1 text-caption text-secondary",children:[e.jsx("span",{className:"text-muted flex-shrink-0 w-4 text-center",children:n}),e.jsx("span",{className:"truncate",children:t})]})}function D({item:s}){const{impact:t}=s;return t.initiativeCount===0&&t.workstreamCount===0&&t.downstreamBlockedCount===0?null:e.jsxs("div",{children:[e.jsx(j,{children:"Impact if ignored"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.initiativeCount>0&&e.jsx(y,{label:`${t.initiativeCount} initiative${t.initiativeCount>1?"s":""}`}),t.workstreamCount>0&&e.jsx(y,{label:`${t.workstreamCount} workstream${t.workstreamCount>1?"s":""}`}),t.downstreamBlockedCount>0&&e.jsx(y,{label:`${t.downstreamBlockedCount} blocked downstream`,tone:"red"})]})]})}function R({item:s}){const t=s.intervention;return!t||!(!!t.blockerReason||!!t.decisionPrompt||!!t.decisionSummary||!!t.waitingOn||!!t.requiredAction||!!t.recommendedAction||!!t.requiredActor||!!t.errorCode||!!t.errorCategory||!!t.currentRunState||!!t.impactIfDelayed||typeof t.retryable=="boolean"||Array.isArray(t.suggestedActions)&&t.suggestedActions.length>0||Array.isArray(t.nextActions)&&t.nextActions.length>0||Array.isArray(t.scopeHierarchy)&&t.scopeHierarchy.length>0||Array.isArray(t.decisionOptions)&&t.decisionOptions.length>0||Array.isArray(t.evidence)&&t.evidence.length>0||Array.isArray(t.artifacts)&&t.artifacts.length>0||Array.isArray(t.updatesApplied)&&t.updatesApplied.length>0||typeof t.taskUpdateCount=="number"||typeof t.milestoneUpdateCount=="number")?null:e.jsxs("div",{children:[e.jsx(j,{children:"Intervention brief"}),e.jsxs("div",{className:"space-y-2 rounded-lg border border-white/[0.08] bg-white/[0.02] px-3 py-2.5",children:[Array.isArray(t.scopeHierarchy)&&t.scopeHierarchy.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Scope"}),e.jsx("p",{className:"text-caption text-primary",children:t.scopeHierarchy.join(" › ")})]}),t.decisionPrompt&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Decision prompt"}),e.jsx("p",{className:"text-caption text-primary",children:t.decisionPrompt}),t.decisionSummary&&e.jsx("p",{className:"mt-1 text-caption text-secondary",children:t.decisionSummary})]}),t.blockerReason&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Blocker"}),e.jsx("p",{className:"text-caption text-primary",children:t.blockerReason})]}),t.requiredAction&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Required action"}),e.jsx("p",{className:"text-caption text-[#7AEDE5]",children:t.requiredAction})]}),t.recommendedAction&&t.recommendedAction!==t.requiredAction&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Recommended"}),e.jsx("p",{className:"text-caption text-[#7AEDE5]",children:t.recommendedAction})]}),t.waitingOn&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Waiting on"}),e.jsx("p",{className:"text-caption text-secondary",children:t.waitingOn})]}),(t.currentRunState||t.impactIfDelayed)&&e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[t.currentRunState&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Run state"}),e.jsx("p",{className:"text-caption text-secondary",children:t.currentRunState})]}),t.impactIfDelayed&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Impact if delayed"}),e.jsx("p",{className:"text-caption text-secondary",children:t.impactIfDelayed})]})]}),(t.errorCode||t.errorCategory||typeof t.retryable=="boolean")&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.errorCode&&e.jsxs("span",{className:"rounded bg-white/[0.06] px-1.5 py-0.5 text-micro text-secondary",children:["Error: ",t.errorCode]}),t.errorCategory&&e.jsxs("span",{className:"rounded bg-white/[0.06] px-1.5 py-0.5 text-micro text-secondary",children:["Category: ",t.errorCategory]}),typeof t.retryable=="boolean"&&e.jsx("span",{className:"rounded bg-white/[0.06] px-1.5 py-0.5 text-micro text-secondary",children:t.retryable?"Retryable":"Non-retryable"})]}),Array.isArray(t.decisionOptions)&&t.decisionOptions.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Options"}),e.jsx("div",{className:"mt-1.5 space-y-1.5",children:t.decisionOptions.slice(0,6).map((r,a)=>e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-black/[0.18] px-2.5 py-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"text-caption font-medium text-primary",children:r.label}),r.recommended?e.jsx("span",{className:"rounded-full bg-[#0AD4C4]/12 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-[#7AEDE5]",children:"Recommended"}):null]}),r.description?e.jsx("p",{className:"mt-1 text-caption text-secondary",children:r.description}):null,r.consequences?e.jsx("p",{className:"mt-1 text-micro text-muted",children:r.consequences}):null]},`${r.id??r.label}-${a}`))})]}),((t.taskUpdateCount??0)>0||(t.milestoneUpdateCount??0)>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[(t.taskUpdateCount??0)>0&&e.jsxs("span",{className:"rounded bg-[#0AD4C4]/12 px-1.5 py-0.5 text-micro text-[#7AEDE5]",children:[t.taskUpdateCount," task update",t.taskUpdateCount===1?"":"s"]}),(t.milestoneUpdateCount??0)>0&&e.jsxs("span",{className:"rounded bg-[#0AD4C4]/12 px-1.5 py-0.5 text-micro text-[#7AEDE5]",children:[t.milestoneUpdateCount," milestone update",t.milestoneUpdateCount===1?"":"s"]})]}),Array.isArray(t.updatesApplied)&&t.updatesApplied.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Updates applied"}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:t.updatesApplied.slice(0,4).map(r=>e.jsxs("li",{className:"text-caption text-secondary",children:["- ",r]},r))})]}),Array.isArray(t.artifacts)&&t.artifacts.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Artifacts"}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:t.artifacts.slice(0,4).map(r=>e.jsxs("li",{className:"text-caption text-secondary",children:["- ",r]},r))})]}),Array.isArray(t.evidence)&&t.evidence.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Evidence"}),e.jsx("div",{className:"mt-1.5 space-y-1.5",children:t.evidence.slice(0,4).map((r,a)=>e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-black/[0.18] px-2.5 py-2",children:[e.jsx("p",{className:"text-caption font-medium text-primary",children:r.title}),r.summary?e.jsx("p",{className:"mt-1 text-caption text-secondary",children:r.summary}):null,(r.url||r.pointer)&&e.jsxs("p",{className:"mt-1 text-micro text-muted",children:[r.url?e.jsx("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",className:"text-[#7AEDE5] transition-colors hover:text-white",children:"Open source"}):r.pointer,r.url&&r.pointer?` · ${r.pointer}`:null]})]},`${r.title}-${a}`))})]}),Array.isArray(t.suggestedActions)&&t.suggestedActions.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Suggested actions"}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:t.suggestedActions.slice(0,4).map(r=>e.jsxs("li",{className:"text-caption text-secondary",children:["- ",r]},r))})]}),Array.isArray(t.nextActions)&&t.nextActions.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-micro uppercase tracking-wider text-muted",children:"Next up"}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:t.nextActions.slice(0,4).map(r=>e.jsxs("li",{className:"text-caption text-secondary",children:["- ",r]},r))})]})]})]})}function y({label:s,tone:t="amber"}){const n=t==="red"?"bg-[#FF6B6B]/14":"bg-[#F5B700]/14",r=t==="red"?"text-[#FFA8A8]":"text-[#FFE7A8]";return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-micro font-medium ${n} ${r}`,children:s})}function S({triageAction:s,onPerform:t,isActing:n}){const[r,a]=x.useState(!1),[o,u]=x.useState(""),f=s.action==="approve"||s.action==="autofix",h=s.action==="dismiss",l=f?"bg-[#0AD4C4]/20 text-[#7AEDE5] hover:bg-[#0AD4C4]/30":h?"bg-[#FF6B6B]/14 text-[#FFA8A8] hover:bg-[#FF6B6B]/20":"bg-white/[0.08] text-secondary hover:bg-white/[0.12]";return s.available?s.requiresNote&&r?e.jsxs("div",{className:"flex flex-col gap-1.5 w-full",children:[e.jsx("textarea",{value:o,onChange:p=>u(p.target.value),placeholder:"Add a note...",className:"w-full rounded-lg border border-subtle bg-white/[0.04] px-2.5 py-1.5 text-caption text-primary placeholder:text-muted resize-none",rows:2}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>t(s.action,o,s.optionId??void 0),disabled:n,className:`rounded-lg px-3 py-1 text-caption font-medium transition-colors disabled:opacity-40 ${l}`,children:"Confirm"}),e.jsx("button",{type:"button",onClick:()=>a(!1),className:"text-caption text-muted hover:text-secondary",children:"Cancel"})]})]}):e.jsxs("button",{type:"button",onClick:()=>{s.requiresNote?a(!0):t(s.action,void 0,s.optionId??void 0)},disabled:n,className:`rounded-lg px-3 py-1.5 text-caption font-medium transition-colors disabled:opacity-40 ${l}`,title:s.consequences,children:[e.jsx("span",{children:s.label}),e.jsxs("span",{className:"ml-1 text-micro opacity-60",children:["— ",s.consequences]})]}):e.jsx("button",{type:"button",disabled:!0,className:"rounded-lg px-3 py-1.5 text-caption font-medium opacity-30 bg-white/[0.06] text-muted cursor-not-allowed",title:"Not available",children:s.label})}function E({item:s}){const[t,n]=x.useState(!1),r=[["ID",s.id],["Kind",s.kind],["Dedupe key",s.dedupeKey],["Source system",s.sourceSystem],["Conflict source",s.conflictSource],["Agent ID",s.agentId],["Source decision",s.sourceDecisionId],["Source activity",s.sourceActivityId],["First seen",s.firstSeenAt],["Last seen",s.lastSeenAt],["Created",s.createdAt]].filter(([,a])=>a!=null);return e.jsxs("div",{className:"border-t border-subtle pt-2",children:[e.jsxs("button",{type:"button",onClick:()=>n(a=>!a),className:"flex w-full items-center justify-between text-micro font-semibold uppercase tracking-wider text-muted hover:text-secondary transition-colors",children:[e.jsx("span",{children:"Technical details"}),e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`transition-transform ${t?"rotate-180":""}`,children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),t&&e.jsx("div",{className:"mt-2 space-y-0.5",children:r.map(([a,o])=>e.jsxs("div",{className:"flex gap-2 text-micro",children:[e.jsx("span",{className:"text-muted w-28 flex-shrink-0",children:a}),e.jsx("span",{className:"text-secondary truncate",children:o})]},a))})]})}function $({item:s,actions:t,onClose:n,onNavigate:r,currentIndex:a,totalCount:o,decisions:u}){const f=x.useRef(null),h=x.useCallback(c=>{if(!s)return;const i=s.actionContract.find(d=>d.action===c&&typeof d.optionId=="string"&&d.optionId.trim().length>0);return typeof(i==null?void 0:i.optionId)=="string"?i.optionId:void 0},[s]);x.useEffect(()=>{if(!s)return;const c=i=>{var b;const d=(b=i.target)==null?void 0:b.tagName;if(!(d==="INPUT"||d==="TEXTAREA"))switch(i.key){case"j":case"ArrowRight":i.preventDefault(),r==null||r(1);break;case"k":case"ArrowLeft":i.preventDefault(),r==null||r(-1);break;case"a":i.preventDefault(),l("approve");break;case"d":i.preventDefault(),l("dismiss");break;case"r":i.preventDefault(),l("retry");break;case"s":i.preventDefault(),l("snooze");break;case"Escape":i.preventDefault(),n();break}};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s,r,n]);const l=x.useCallback(async(c,i,d)=>{if(s)try{await t.performAction(s.id,c,{note:i,optionId:d??h(c)}),r==null||r(1)}catch{}},[s,t,r,h]);if(!s)return null;const p=s.sourceDecisionId&&Array.isArray(u)?u.find(c=>c.id===s.sourceDecisionId)??null:null,v=k(s);return e.jsx(A,{mode:"wait",children:e.jsxs(N.div,{ref:f,initial:{opacity:0,x:44,scale:.985},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:-44,scale:.985},transition:{duration:.28},className:"flex h-full min-h-0 flex-col overflow-y-auto px-5 pb-5 pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>r(-1),className:"rounded p-1 text-muted hover:text-secondary hover:bg-white/[0.06] transition-colors",title:"Previous (k)",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"m15 18-6-6 6-6"})})}),e.jsx("button",{type:"button",onClick:()=>r(1),className:"rounded p-1 text-muted hover:text-secondary hover:bg-white/[0.06] transition-colors",title:"Next (j)",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})})]}),a!=null&&o!=null&&e.jsxs("span",{className:"text-micro text-muted tabular-nums",children:[a+1," of ",o]})]}),e.jsx("button",{type:"button",onClick:n,className:"rounded p-1 text-muted hover:text-secondary hover:bg-white/[0.06] transition-colors",title:"Close (Esc)",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})})]}),(s.initiativeTitle||s.workstreamTitle)&&e.jsx("p",{className:"text-micro text-muted mb-1",children:[s.initiativeTitle,s.workstreamTitle,s.taskTitle].filter(Boolean).join(" › ")}),e.jsxs("div",{className:"mb-4 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h3",{className:"text-heading font-semibold text-primary",children:s.title}),e.jsx("span",{className:"flex-shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider",style:{backgroundColor:`${g(s.severity)}20`,color:g(s.severity)},children:w(s.kind)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-caption text-secondary",children:[s.agentId&&e.jsx("span",{className:"rounded bg-white/[0.06] px-1.5 py-0.5 text-micro font-medium text-secondary",children:s.agentId}),s.occurrenceCount>1&&e.jsxs("span",{className:"text-micro text-muted",children:["x",s.occurrenceCount," occurrences"]})]}),e.jsx("p",{className:"text-body text-secondary leading-relaxed",children:s.summary}),(p==null?void 0:p.recommendedAction)&&e.jsxs("p",{className:"text-caption text-[#7AEDE5]",children:["Recommended: ",p.recommendedAction]})]}),e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-white/[0.06] to-transparent mb-4"}),e.jsxs("div",{className:"space-y-4 mb-4",children:[e.jsx(C,{missing:v}),e.jsx(R,{item:s}),e.jsx(B,{item:s})]}),e.jsx("div",{className:"mb-4",children:e.jsx(D,{item:s})}),e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"space-y-1.5",children:s.actionContract.map(c=>e.jsx(S,{triageAction:c,onPerform:l,isActing:t.isActing},c.action))}),s.recommendedAction&&e.jsxs("p",{className:"mt-2 text-micro text-[#7AEDE5]",children:["Recommended: ",s.recommendedAction]})]}),e.jsx(E,{item:s}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-x-3 gap-y-1 text-micro text-muted opacity-60",children:[e.jsx("span",{children:"j/k nav"}),e.jsx("span",{children:"a approve"}),e.jsx("span",{children:"d dismiss"}),e.jsx("span",{children:"r retry"}),e.jsx("span",{children:"s snooze"}),e.jsx("span",{children:"esc close"})]})]},s.id)})}export{$ as TriageDetailModal};
@@ -1 +1 @@
1
- import{r as o,j as t}from"./Dj2k1r16.js";import{i as L,b as C,Y as A,ae as M}from"./CSd4rSuU.js";function R(c){const i=Date.parse(c);if(!Number.isFinite(i))return null;const s=Date.now()-i,r=s<0,a=Math.abs(s),l=Math.round(a/6e4);if(l<1)return r?"soon":"just now";if(l<60)return r?`in ${l}m`:`${l}m ago`;const u=Math.round(a/36e5);if(u<48)return r?`in ${u}h`:`${u}h ago`;const p=Math.round(a/864e5);return p<30?r?`in ${p}d`:`${p}d ago`:new Date(i).toLocaleDateString()}async function T(c,i){const s=await fetch(c,i);if(!s.ok){const r=await s.json().catch(()=>null),a=typeof(r==null?void 0:r.error)=="string"&&r.error||typeof(r==null?void 0:r.message)=="string"&&r.message||`Request failed (${s.status})`;throw new Error(a)}return await s.json()}function J(c){const{entityType:i,entityId:s,authToken:r,embedMode:a,className:l,variant:u="default"}=c,[p,b]=o.useState(!0),[j,v]=o.useState(!1),[N,x]=o.useState(null),[E,S]=o.useState([]),[h,g]=o.useState(""),m=L(),y=o.useMemo(()=>{const e=encodeURIComponent(i),n=encodeURIComponent(s);return`/orgx/api/entities/${e}/${n}/comments`},[i,s]),f=o.useCallback(async()=>{if(m){S([]),x(null),b(!1);return}b(!0),x(null);try{const e=await T(y,{method:"GET",headers:C({authToken:r,embedMode:a})});S(Array.isArray(e.comments)?e.comments:[])}catch(e){x(e instanceof Error?e.message:String(e))}finally{b(!1)}},[r,m,a,y]);o.useEffect(()=>{f()},[f]);const w=o.useCallback(async()=>{if(m){g("");return}const e=h.trim();if(e){v(!0),x(null);try{await T(y,{method:"POST",headers:C({authToken:r,embedMode:a,contentTypeJson:!0}),body:JSON.stringify({body:e,commentType:"note",severity:"info",tags:[]})}),g(""),await f()}catch(n){x(n instanceof Error?n.message:String(n))}finally{v(!1)}}},[r,h,m,a,y,f]),_=o.useCallback(e=>{e.key==="Enter"&&(!e.metaKey&&!e.ctrlKey||(e.preventDefault(),w()))},[w]),d=u==="inline";return t.jsxs("div",{className:l,children:[t.jsxs("div",{className:d?"space-y-1":"space-y-2",children:[t.jsx("textarea",{value:h,onChange:e=>g(e.target.value),onKeyDown:_,placeholder:"Leave a note for humans or agents...",className:d?"min-h-[60px] w-full resize-y border-b border-white/[0.06] bg-transparent px-0 py-2 text-body text-bright outline-none placeholder:text-faint focus:border-white/15 transition-colors":"min-h-[96px] w-full resize-y rounded-xl border border-white/[0.10] bg-white/[0.03] px-4 py-3 text-body text-bright outline-none placeholder:text-faint focus:border-white/20 focus:bg-white/[0.05] transition-colors"}),t.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 ${d?"opacity-70":""}`,children:[t.jsx("p",{className:"text-caption text-muted",children:"Cmd/Ctrl+Enter to post. Visible to agents and collaborators."}),t.jsx("button",{type:"button",onClick:w,disabled:j||h.trim().length===0,className:d?"text-caption font-semibold text-primary hover:text-white transition-colors disabled:opacity-50":"inline-flex items-center justify-center rounded-full border border-strong bg-white/[0.05] px-3.5 py-1.5 text-caption font-semibold tracking-wide text-primary transition-colors hover:bg-white/[0.09] disabled:opacity-50 disabled:hover:bg-white/[0.05]",children:j?"Saving…":"Post note"})]})]}),N?t.jsx("div",{className:`mt-2 text-caption text-red-200 ${d?"":"rounded-xl border border-red-500/20 bg-red-500/10 px-3.5 py-2"}`,children:N}):null,p?t.jsx("div",{className:"mt-2 text-body text-muted",children:"Loading notes…"}):E.length===0?t.jsx(A,{icon:"inbox",headline:"No notes yet",description:m?"Notes are unavailable in demo mode.":"Add a note to keep context for your team and agents.",className:"py-6"}):t.jsx("div",{className:`mt-2 space-y-2 ${d?"divide-y divide-white/[0.06]":"space-y-3"}`,children:E.map(e=>{const n=e.created_at?R(e.created_at):null,k=e.author_name??(e.author_type==="agent"?e.author_id:"Unknown");if(d)return t.jsxs("div",{className:"pt-2 first:pt-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-micro text-muted",children:[t.jsx("span",{className:"font-medium text-secondary",children:k}),n?t.jsx("span",{title:M(e.created_at),children:n}):null]}),t.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-body leading-relaxed text-primary",children:e.body})]},e.id);const D=e.comment_type??"note",$=typeof e.severity=="string"?e.severity:"info";return t.jsxs("div",{className:"rounded-2xl border border-white/[0.10] bg-white/[0.02] px-4 py-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-body font-semibold text-bright",children:k}),t.jsx("span",{className:"rounded-full border border-strong bg-white/[0.06] px-2 py-0.5 text-micro uppercase tracking-[0.08em] text-secondary",children:e.author_type}),t.jsx("span",{className:"rounded-full border border-strong px-2 py-0.5 text-micro uppercase tracking-[0.08em] text-secondary",children:D}),$!=="info"?t.jsx("span",{className:"rounded-full border border-strong px-2 py-0.5 text-micro uppercase tracking-[0.08em] text-secondary",children:$}):null]}),n?t.jsx("span",{className:"text-caption text-muted",title:M(e.created_at),children:n}):null]}),t.jsx("p",{className:"mt-2 whitespace-pre-wrap text-body leading-relaxed text-primary",children:e.body})]},e.id)})})]})}export{J as E};
1
+ import{r as o,j as t}from"./Dj2k1r16.js";import{i as L,b as C,Y as A,ae as M}from"./C0i7ABUU.js";function R(c){const i=Date.parse(c);if(!Number.isFinite(i))return null;const s=Date.now()-i,r=s<0,a=Math.abs(s),l=Math.round(a/6e4);if(l<1)return r?"soon":"just now";if(l<60)return r?`in ${l}m`:`${l}m ago`;const u=Math.round(a/36e5);if(u<48)return r?`in ${u}h`:`${u}h ago`;const p=Math.round(a/864e5);return p<30?r?`in ${p}d`:`${p}d ago`:new Date(i).toLocaleDateString()}async function T(c,i){const s=await fetch(c,i);if(!s.ok){const r=await s.json().catch(()=>null),a=typeof(r==null?void 0:r.error)=="string"&&r.error||typeof(r==null?void 0:r.message)=="string"&&r.message||`Request failed (${s.status})`;throw new Error(a)}return await s.json()}function J(c){const{entityType:i,entityId:s,authToken:r,embedMode:a,className:l,variant:u="default"}=c,[p,b]=o.useState(!0),[j,v]=o.useState(!1),[N,x]=o.useState(null),[E,S]=o.useState([]),[h,g]=o.useState(""),m=L(),y=o.useMemo(()=>{const e=encodeURIComponent(i),n=encodeURIComponent(s);return`/orgx/api/entities/${e}/${n}/comments`},[i,s]),f=o.useCallback(async()=>{if(m){S([]),x(null),b(!1);return}b(!0),x(null);try{const e=await T(y,{method:"GET",headers:C({authToken:r,embedMode:a})});S(Array.isArray(e.comments)?e.comments:[])}catch(e){x(e instanceof Error?e.message:String(e))}finally{b(!1)}},[r,m,a,y]);o.useEffect(()=>{f()},[f]);const w=o.useCallback(async()=>{if(m){g("");return}const e=h.trim();if(e){v(!0),x(null);try{await T(y,{method:"POST",headers:C({authToken:r,embedMode:a,contentTypeJson:!0}),body:JSON.stringify({body:e,commentType:"note",severity:"info",tags:[]})}),g(""),await f()}catch(n){x(n instanceof Error?n.message:String(n))}finally{v(!1)}}},[r,h,m,a,y,f]),_=o.useCallback(e=>{e.key==="Enter"&&(!e.metaKey&&!e.ctrlKey||(e.preventDefault(),w()))},[w]),d=u==="inline";return t.jsxs("div",{className:l,children:[t.jsxs("div",{className:d?"space-y-1":"space-y-2",children:[t.jsx("textarea",{value:h,onChange:e=>g(e.target.value),onKeyDown:_,placeholder:"Leave a note for humans or agents...",className:d?"min-h-[60px] w-full resize-y border-b border-white/[0.06] bg-transparent px-0 py-2 text-body text-bright outline-none placeholder:text-faint focus:border-white/15 transition-colors":"min-h-[96px] w-full resize-y rounded-xl border border-white/[0.10] bg-white/[0.03] px-4 py-3 text-body text-bright outline-none placeholder:text-faint focus:border-white/20 focus:bg-white/[0.05] transition-colors"}),t.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 ${d?"opacity-70":""}`,children:[t.jsx("p",{className:"text-caption text-muted",children:"Cmd/Ctrl+Enter to post. Visible to agents and collaborators."}),t.jsx("button",{type:"button",onClick:w,disabled:j||h.trim().length===0,className:d?"text-caption font-semibold text-primary hover:text-white transition-colors disabled:opacity-50":"inline-flex items-center justify-center rounded-full border border-strong bg-white/[0.05] px-3.5 py-1.5 text-caption font-semibold tracking-wide text-primary transition-colors hover:bg-white/[0.09] disabled:opacity-50 disabled:hover:bg-white/[0.05]",children:j?"Saving…":"Post note"})]})]}),N?t.jsx("div",{className:`mt-2 text-caption text-red-200 ${d?"":"rounded-xl border border-red-500/20 bg-red-500/10 px-3.5 py-2"}`,children:N}):null,p?t.jsx("div",{className:"mt-2 text-body text-muted",children:"Loading notes…"}):E.length===0?t.jsx(A,{icon:"inbox",headline:"No notes yet",description:m?"Notes are unavailable in demo mode.":"Add a note to keep context for your team and agents.",className:"py-6"}):t.jsx("div",{className:`mt-2 space-y-2 ${d?"divide-y divide-white/[0.06]":"space-y-3"}`,children:E.map(e=>{const n=e.created_at?R(e.created_at):null,k=e.author_name??(e.author_type==="agent"?e.author_id:"Unknown");if(d)return t.jsxs("div",{className:"pt-2 first:pt-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-micro text-muted",children:[t.jsx("span",{className:"font-medium text-secondary",children:k}),n?t.jsx("span",{title:M(e.created_at),children:n}):null]}),t.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-body leading-relaxed text-primary",children:e.body})]},e.id);const D=e.comment_type??"note",$=typeof e.severity=="string"?e.severity:"info";return t.jsxs("div",{className:"rounded-2xl border border-white/[0.10] bg-white/[0.02] px-4 py-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-body font-semibold text-bright",children:k}),t.jsx("span",{className:"rounded-full border border-strong bg-white/[0.06] px-2 py-0.5 text-micro uppercase tracking-[0.08em] text-secondary",children:e.author_type}),t.jsx("span",{className:"rounded-full border border-strong px-2 py-0.5 text-micro uppercase tracking-[0.08em] text-secondary",children:D}),$!=="info"?t.jsx("span",{className:"rounded-full border border-strong px-2 py-0.5 text-micro uppercase tracking-[0.08em] text-secondary",children:$}):null]}),n?t.jsx("span",{className:"text-caption text-muted",title:M(e.created_at),children:n}):null]}),t.jsx("p",{className:"mt-2 whitespace-pre-wrap text-body leading-relaxed text-primary",children:e.body})]},e.id)})})]})}export{J as E};
@@ -1 +1 @@
1
- import{r as a,j as e}from"./Dj2k1r16.js";import{f as i}from"./CSd4rSuU.js";import{A as m,m as x}from"./eeHXe_OQ.js";function f({message:l,durationMs:s=5e3,onUndo:d,onExpire:r}){const[t,c]=a.useState(!0),o=a.useRef();a.useEffect(()=>(o.current=setTimeout(()=>{c(!1),r()},s),()=>clearTimeout(o.current)),[s,r]);const n=()=>{clearTimeout(o.current),c(!1),d()};return e.jsx(m,{children:t&&e.jsx(x.div,{initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},transition:{duration:.22,ease:[.22,1,.36,1]},className:"fixed bottom-6 left-1/2 z-50 -translate-x-1/2",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-xl px-4 py-2.5 shadow-lg",style:{backgroundColor:i.cardBgElevated,border:`1px solid ${i.cardBorderStrong}`},children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:i.lime,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6 9 17l-5-5"})}),e.jsx("span",{className:"text-body text-primary",children:l}),e.jsx("button",{onClick:n,className:"ml-1 rounded-md px-2.5 py-1 text-caption font-semibold transition-colors hover:bg-white/[0.08]",style:{color:i.lime},children:"Undo"}),e.jsx("div",{className:"absolute bottom-0 left-3 right-3 h-0.5 overflow-hidden rounded-full",children:e.jsx("div",{className:"h-full origin-left rounded-full",style:{backgroundColor:i.lime,opacity:.4,animation:`undoCountdown ${s}ms linear forwards`}})})]})})})}function y(){const[l,s]=a.useState([]),d=o=>{const n=`undo-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;return s(u=>[...u,{...o,id:n}]),n},r=o=>{s(n=>n.filter(u=>u.id!==o))},t=l[0]??null;return{enqueue:d,ToastRenderer:()=>t?e.jsx(f,{message:t.message,onUndo:()=>{t.onUndo(),r(t.id)},onExpire:()=>{t.onCommit(),r(t.id)}},t.id):null}}export{y as u};
1
+ import{r as a,j as e}from"./Dj2k1r16.js";import{f as i}from"./C0i7ABUU.js";import{A as m,m as x}from"./eeHXe_OQ.js";function f({message:l,durationMs:s=5e3,onUndo:d,onExpire:r}){const[t,c]=a.useState(!0),o=a.useRef();a.useEffect(()=>(o.current=setTimeout(()=>{c(!1),r()},s),()=>clearTimeout(o.current)),[s,r]);const n=()=>{clearTimeout(o.current),c(!1),d()};return e.jsx(m,{children:t&&e.jsx(x.div,{initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},transition:{duration:.22,ease:[.22,1,.36,1]},className:"fixed bottom-6 left-1/2 z-50 -translate-x-1/2",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-xl px-4 py-2.5 shadow-lg",style:{backgroundColor:i.cardBgElevated,border:`1px solid ${i.cardBorderStrong}`},children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:i.lime,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6 9 17l-5-5"})}),e.jsx("span",{className:"text-body text-primary",children:l}),e.jsx("button",{onClick:n,className:"ml-1 rounded-md px-2.5 py-1 text-caption font-semibold transition-colors hover:bg-white/[0.08]",style:{color:i.lime},children:"Undo"}),e.jsx("div",{className:"absolute bottom-0 left-3 right-3 h-0.5 overflow-hidden rounded-full",children:e.jsx("div",{className:"h-full origin-left rounded-full",style:{backgroundColor:i.lime,opacity:.4,animation:`undoCountdown ${s}ms linear forwards`}})})]})})})}function y(){const[l,s]=a.useState([]),d=o=>{const n=`undo-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;return s(u=>[...u,{...o,id:n}]),n},r=o=>{s(n=>n.filter(u=>u.id!==o))},t=l[0]??null;return{enqueue:d,ToastRenderer:()=>t?e.jsx(f,{message:t.message,onUndo:()=>{t.onUndo(),r(t.id)},onExpire:()=>{t.onCommit(),r(t.id)}},t.id):null}}export{y as u};
@@ -0,0 +1 @@
1
+ import{r as c,j as e}from"./Dj2k1r16.js";import{H as es,u as ts,L as y,P as ss,C as ae,J as yt,Y as ns,D as S,w as jt,A as St,E as Se,Z as Ct,y as rs,f as Xe,h as tt,F as vt,G as is,U as as}from"./C0i7ABUU.js";import{S as D}from"./BZCkOZ20.js";import{A as je,m as _,u as It,R as os,b as ls,a as cs}from"./eeHXe_OQ.js";import{Q as m,d as ds,q as De,a as kt,b as Nt,c as qt,e as Ye}from"./CUoQoSm-.js";async function $t(s,r){var h;const i=await(await fetch(s,r)).json().catch(()=>null),x=((h=i==null?void 0:i.data)==null?void 0:h.url)??(i==null?void 0:i.url)??null;if(typeof x=="string"&&x.trim())return x.trim();throw new Error((i==null?void 0:i.error)??"Billing link unavailable")}async function us(s){var x;const r=((x=s==null?void 0:s.actions)==null?void 0:x.checkout)??"/orgx/api/billing/checkout",l=((s==null?void 0:s.requiredPlan)??"starter").trim().toLowerCase()||"starter",i=await $t(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({planId:l})});window.open(i,"_blank","noopener,noreferrer")}async function ms(s){var i;const r=((i=s==null?void 0:s.actions)==null?void 0:i.portal)??"/orgx/api/billing/portal",l=await $t(r,{method:"POST"});window.open(l,"_blank","noopener,noreferrer")}function xs(s){return s==="success"?"border-emerald-400/30 bg-[#0A1210]/95 text-emerald-100":s==="warning"?"border-amber-300/30 bg-[#12100A]/95 text-amber-100":s==="error"?"border-red-400/32 bg-[#120A0A]/95 text-red-100":s==="info"?"border-cyan-300/28 bg-[#0A1012]/95 text-cyan-100":"border-strong bg-[#0B0F16]/95 text-primary"}function ps({open:s,tone:r="neutral",title:l,message:i=null,className:x,primaryAction:h=null,secondaryAction:g=null,onDismiss:w=null,autoDismissMs:q=null}){return c.useEffect(()=>{if(!s||!w||!q)return;const L=window.setTimeout(()=>w(),q);return()=>window.clearTimeout(L)},[q,w,s,l,i]),e.jsx(je,{initial:!1,children:s?e.jsx(_.div,{initial:{opacity:0,y:-8,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.985},transition:{duration:.2,ease:[.22,1,.36,1]},className:`pointer-events-none ${x??""}`,children:e.jsxs("div",{className:`pointer-events-none min-w-[220px] max-w-[420px] rounded-xl border px-3 py-2 shadow-[0_16px_36px_rgba(0,0,0,0.42)] backdrop-blur ${xs(r)}`,children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-caption font-semibold",children:l}),i?e.jsx("p",{className:"mt-0.5 text-caption opacity-85",children:i}):null]}),w?e.jsx("button",{type:"button",onClick:w,className:"pointer-events-auto inline-flex h-6 w-6 items-center justify-center rounded-md text-current/70 transition-colors hover:bg-white/[0.08] hover:text-current","aria-label":"Dismiss toast",title:"Dismiss",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"m6 6 12 12"})]})}):null]}),h||g?e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[g?e.jsx("button",{type:"button",onClick:g.onClick,className:"pointer-events-auto h-7 rounded-md border border-strong bg-white/[0.06] px-2.5 text-micro font-semibold text-current transition-colors hover:bg-white/[0.12]",children:g.label}):null,h?e.jsx("button",{type:"button",onClick:h.onClick,className:"pointer-events-auto h-7 rounded-md border border-white/25 bg-white/[0.14] px-2.5 text-micro font-semibold text-current transition-colors hover:bg-white/[0.2]",children:h.label}):null]}):null]})}):null})}function Tt({className:s=""}){return e.jsx("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,className:s,children:e.jsx("path",{d:"M7 5.4v9.2c0 .7.75 1.15 1.38.83l7.6-4.6a.95.95 0 0 0 0-1.62l-7.6-4.64A.95.95 0 0 0 7 5.4Z",fill:"currentColor"})})}function hs({className:s=""}){return e.jsxs("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,className:s,children:[e.jsx("path",{d:"M6.2 9.4V6.7c0-.7.5-1.2 1.1-1.2s1.1.5 1.1 1.2v2.2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e.jsx("path",{d:"M8.4 8.9V5.8c0-.7.5-1.3 1.1-1.3s1.1.6 1.1 1.3v3",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e.jsx("path",{d:"M10.6 8.9V6.2c0-.7.5-1.3 1.1-1.3s1.1.6 1.1 1.3v3.2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e.jsx("path",{d:"M12.8 9.6V7.2c0-.7.5-1.2 1.1-1.2s1.1.5 1.1 1.2v4.2c0 2.7-1.9 4.6-4.6 4.6H9.2c-2.1 0-3.7-1-4.6-2.8l-.9-1.7c-.3-.6 0-1.4.6-1.7.6-.3 1.3 0 1.6.6l.7 1.4",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]})}function fs({className:s=""}){return e.jsxs("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,className:s,children:[e.jsx("path",{d:"M6.4 9.2V7.4c0-.7.5-1.2 1.1-1.2s1.1.5 1.1 1.2v1.3",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e.jsx("path",{d:"M8.6 8.9V7c0-.7.5-1.2 1.1-1.2s1.1.5 1.1 1.2v2",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e.jsx("path",{d:"M10.8 9.2V7.3c0-.7.5-1.2 1.1-1.2s1.1.5 1.1 1.2v2.6",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"}),e.jsx("path",{d:"M13 9.8V8.2c0-.7.5-1.2 1.1-1.2s1.1.5 1.1 1.2v3.6c0 2.4-1.7 4-4.1 4H9.7c-2 0-3.4-.9-4.2-2.5l-.8-1.4c-.3-.6 0-1.3.5-1.6.6-.3 1.2-.1 1.6.5l.6 1",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Oe(s){const r=typeof s.sliceTaskCount=="number"&&Number.isFinite(s.sliceTaskCount)?Math.max(0,Math.floor(s.sliceTaskCount)):null,l=s.sliceScope==="task"?"task":s.sliceScope==="milestone"?"milestone slice":"workstream slice",i=r&&r>0?`${r} ${r===1?"task":"tasks"}`:null;return s.queueState===m.RUNNING?i?`Executing ${i} in ${l}.`:"Execution in progress. Task detail will appear as the scheduler advances.":s.queueState===m.BLOCKED?s.blockReason?"Blocked while waiting for dependency resolution.":"Blocked. Waiting for dependency or review.":s.queueState===m.QUEUED?i?`Queued with ${i} in ${l}.`:"Queued at workstream scope. Task detail will populate after dispatch.":s.queueState===m.COMPLETED?"Completed. No queued tasks remain.":"Idle. Ready to dispatch when started."}function X(s){var r,l;return typeof s.canStartNow=="boolean"?s.canStartNow:s.queueState===m.RUNNING||s.queueState===m.BLOCKED||s.queueState===m.COMPLETED||((r=s.autoContinue)==null?void 0:r.status)==="running"||((l=s.autoContinue)==null?void 0:l.status)==="stopping"?!1:s.queueState===m.QUEUED||s.queueState===m.IDLE}function _e(s,r){var l,i,x;return r?"Already running":X(s)?((l=s.startReasonLabel)==null?void 0:l.trim())||"Start now":((i=s.startReasonLabel)==null?void 0:i.trim())||((x=s.blockReason)==null?void 0:x.trim())||"This workstream is not ready to start"}function Rt(s){const r=typeof s.initiativePriority=="string"?s.initiativePriority.trim().toLowerCase():"",l=typeof s.initiativePriorityNum=="number"&&Number.isFinite(s.initiativePriorityNum)?Math.max(1,Math.min(100,Math.round(s.initiativePriorityNum))):null,i=r==="urgent"||r==="high"||r==="medium"||r==="low"?r:l!==null?l<=12?"urgent":l<=30?"high":l<=60?"medium":"low":null;if(!i)return null;const x=i==="urgent"?"P1":i==="high"?"P2":i==="medium"?"P3":"P4",h=i==="urgent"?"Urgent":i==="high"?"High":i==="medium"?"Medium":"Low",g=i==="urgent"?"border-red-300/35 bg-red-500/[0.14] text-red-100":i==="high"?"border-amber-300/35 bg-amber-500/[0.14] text-amber-100":i==="medium"?"border-lime/35 bg-lime/14 text-lime":"border-white/[0.2] bg-white/[0.08] text-white/70";return{shortLabel:`${x} ${h}`,longLabel:`Initiative priority ${h} (${x})`,toneClass:g}}function bs(s){const r=s.trim().toLowerCase();if(r.includes("timed out")||r.includes("timeout")||r.includes("request cancelled")||r.includes("signal is aborted"))return"Next Up is still syncing. Keep this panel open and it will repopulate automatically.";if(r.includes("unauthorized")||r.includes("forbidden")||r.includes("api key")||r.includes("auth"))return"Next Up is unavailable until OrgX authentication is reconnected in Settings.";if(r.includes("unknown api endpoint")||r.includes("route is unavailable"))return"This runtime is missing queue routes. Restart and update the plugin build.";const l=s.split("|").map(i=>i.trim()).filter(Boolean).map(i=>i.replace(/^[^:]+:\s*/,"").trim()).filter(Boolean).slice(0,2).join(" ");return tt(l||s)||"Next Up is temporarily unavailable."}function gs(s){const r=s.trim().toLowerCase();return r.includes("circular")||r.includes("timeline estimate")||r.includes("adjusted accordingly")?null:r.includes("timed out")||r.includes("timeout")||r.includes("request cancelled")||r.includes("signal is aborted")?"Signal is delayed right now. Queue data will appear as soon as sync catches up.":r.includes("fallback")?"Showing fallback queue data while full signal refreshes.":r.includes("unknown api endpoint")||r.includes("route is unavailable")?"Some queue controls are unavailable in this plugin build. Update and restart to restore full controls.":tt(s.trim())}function Ce(s,r,l){const i=typeof s=="string"?s.trim():"";if(i&&!vt(i))return S(i);const x=typeof r=="string"?r.trim():"";return x?vt(x)?`${l} ${is(x)}`:S(x):l}function Mt(s){const r=typeof s.runnerAgentName=="string"?s.runnerAgentName.trim():"";if(!r)return"Unassigned";const l=r.toLowerCase();return l==="undefined"||l==="null"||l==="main"&&(s.runnerAgentId==="unassigned"||s.runnerSource==="fallback")?"Unassigned":r}function Lt(s){return s.runnerSource==="inferred"?"inferred":null}function Et(s,r){const l=s.runnerSource==="assigned"?"assigned":s.runnerSource==="inferred"?"inferred":"fallback";return r==="Unassigned"?`Runner ${l}`:`${r} · ${l}`}function he(s,r){return!s||s.trim().length===0?r:tt(s.trim())||r}function et(s){return!s||typeof s!="object"||Array.isArray(s)?null:s}function ze(s,r){var L;const l=S(s.workstreamTitle),i=et(r),x=i&&typeof i.message=="string"?S(i.message):null;if(x)return x;const h=i&&typeof i.outcome=="string"?i.outcome:null;if(h==="slice_completed")return`${l} completed before the queue refreshed.`;if(h==="slice_blocked")return((L=s.startReasonLabel)==null?void 0:L.trim())||`${l} needs your input before it can continue.`;if(h==="fallback_started")return`Dispatched ${l} using fallback runner.`;if(h==="dispatch_pending")return`Dispatching ${l}; waiting for slice start…`;const g=i&&typeof i.dispatchMode=="string"?i.dispatchMode:null,w=et(i==null?void 0:i.run);return(w&&typeof w.stopReason=="string"?w.stopReason:w&&typeof w.stop_reason=="string"?w.stop_reason:null)==="budget_exhausted"?`Dispatch acknowledged for ${l}, but autopilot stopped: budget exhausted.`:g==="pending"?`Dispatching ${l}; waiting for slice start…`:g==="fallback"?`Dispatched ${l} using fallback runner.`:`Dispatched ${l}.`}function Bt(s,r){const l=S(s.initiativeTitle),i=S(s.workstreamTitle),x=et(r),h=x&&typeof x.outcome=="string"?x.outcome:null;if(h==="blocked")return`${i} started under autopilot, but it immediately needs your input.`;if(h==="completed")return`${i} completed immediately under autopilot in ${l}.`;if(h==="error")return`${i} hit an error before autopilot could continue ${l}.`;if(h==="pending")return`Autopilot is preparing the next slice for ${l}.`;if(h==="started")return`Autopilot started ${i} in ${l}.`;const g=x&&typeof x.message=="string"?S(x.message):null;return g||`Auto enabled for ${l}.`}function Pt({className:s=""}){return e.jsxs("svg",{viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,className:s,children:[e.jsx("circle",{cx:"4.5",cy:"10",r:"1.4",fill:"currentColor"}),e.jsx("circle",{cx:"10",cy:"10",r:"1.4",fill:"currentColor"}),e.jsx("circle",{cx:"15.5",cy:"10",r:"1.4",fill:"currentColor"})]})}function ws({compact:s}){const r=s?3:6;return e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 px-1 pt-1 text-micro uppercase tracking-[0.12em] text-muted",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-lime/70 status-breathe"}),e.jsx("span",{children:"Calibrating queue"})]}),Array.from({length:r}).map((l,i)=>e.jsxs("div",{className:"nextup-skeleton-card rounded-2xl border border-white/[0.08] bg-white/[0.02] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2.5",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5",children:[e.jsx(D,{className:"h-8 w-8 rounded-full"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(D,{className:"h-3 w-40 rounded-md"}),e.jsx(D,{className:"mt-2 h-4 w-56 rounded-md"})]})]}),e.jsx(D,{className:"h-5 w-16 rounded-full"})]}),e.jsxs("div",{className:"mt-3 rounded-lg border border-white/[0.07] bg-black/[0.18] px-2.5 py-2",children:[e.jsx(D,{className:"h-3 w-14 rounded"}),e.jsx(D,{className:"mt-2 h-3 w-full rounded"}),e.jsx(D,{className:"mt-2 h-3 w-3/5 rounded"})]}),e.jsxs("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:[e.jsx(D,{className:"h-8 w-24 rounded-full"}),e.jsx(D,{className:"h-8 w-20 rounded-full"}),e.jsx(D,{className:"h-8 w-24 rounded-full"})]})]},`nextup-skeleton-${i}`))]})}function ys({initiativeId:s=null,projectId:r=null,authToken:l=null,embedMode:i=!1,title:x="Next Up",showHeader:h=!0,compact:g=!1,className:w,disableEnterAnimation:q=!1,allowCompactToggle:L=!1,onToggleCompact:fe,onOpenInitiative:$,onOpenSettings:E,onUpgradeGate:z,onOpenSliceDetail:G,selectionEnabled:W=!0,panelStyle:Ie="card",showQueueSettings:qe=!0,queueModel:$e,queueActions:Ge,onPlayWorkstream:V,snapshotVersion:Te=null,excludeRunning:F=!1}){var wt;const[oe,be]=c.useState(g);c.useEffect(()=>be(g),[g]);const d=L&&!fe?oe:g,le=t=>{fe?fe(t):be(t)},[U,j]=c.useState(null),[k,Y]=c.useState("workstream"),ce="bottom",[C,de]=c.useState(null),[B,O]=c.useState(null),[u,ee]=c.useState(null),[H,ue]=c.useState(new Set),[Re,me]=c.useState(null),[ge,we]=c.useState(!1),[Ut,Me]=c.useState(!1),K=It(),st=c.useRef(null),nt=c.useRef(null),rt=c.useRef(null),At=es({initiativeId:s,projectId:r,limit:40,authToken:l,embedMode:i,enabled:!$e,snapshotVersion:Te,zoomLevel:k}),Dt=$e??At,{items:xe,degraded:te,isLoading:T,isFetching:it,isFetchingNextPage:Le,hasNextPage:Ke,error:Ee,refetch:_t,fetchNextPage:at,playWorkstream:zt,startWorkstreamAutoContinue:ot,initiativeGroups:Qe,milestoneGroups:We}=Dt,Gt=ts({authToken:l,embedMode:i,projectId:r}),Z=Ge??Gt,A=t=>`${t.initiativeId}:${t.workstreamId}`,se=k==="workstream",Ve=c.useMemo(()=>K?{duration:.01}:y.surfaceSwitch,[K]),Q=c.useMemo(()=>xe.filter(t=>t.queueState!==m.RUNNING),[xe]),lt=c.useMemo(()=>{const t=xe.some(o=>o.queueState===m.RUNNING);return Q.length===0?t?m.RUNNING:"empty":Q.some(o=>o.queueState!==m.RUNNING&&o.queueState!==m.BLOCKED)?m.QUEUED:Q.some(o=>o.queueState===m.BLOCKED)?m.BLOCKED:t?m.RUNNING:m.QUEUED},[xe,Q]),ct=c.useMemo(()=>{if(!F)return Qe;const t=[];for(const o of Qe){const n=o.items.filter(a=>a.queueState!==m.RUNNING);n.length!==0&&t.push({...o,items:n,queueState:ds(n)})}return t},[F,Qe]),ye=c.useMemo(()=>[...ct].sort((t,o)=>{const n=De(t.queueState)-De(o.queueState);return n!==0?n:t.initiativeTitle.localeCompare(o.initiativeTitle)}),[ct]),dt=c.useMemo(()=>F?We.filter(t=>t.item.queueState!==m.RUNNING):We,[F,We]),ve=c.useMemo(()=>[...dt].sort((t,o)=>{const n=De(t.queueState)-De(o.queueState);if(n!==0)return n;const a=t.initiativeTitle.localeCompare(o.initiativeTitle);if(a!==0)return a;const p=t.workstreamTitle.localeCompare(o.workstreamTitle);return p!==0?p:t.milestoneTitle.localeCompare(o.milestoneTitle)}),[dt]),Fe=c.useMemo(()=>d?ye.slice(0,5):ye,[d,ye]),He=c.useMemo(()=>d?ve.slice(0,5):ve,[d,ve]),ut=c.useMemo(()=>k==="initiative"?ye.length:k==="milestone"?ve.length:Q.length,[Q.length,ye.length,ve.length,k]),Kt=[{value:"initiative",label:"Initiative"},{value:"workstream",label:"Workstream"},{value:"milestone",label:"Milestone"}],I=c.useMemo(()=>se?d?Q.slice(0,5):Q:[],[d,se,Q]),Qt=c.useMemo(()=>I.filter(t=>H.has(A(t))),[H,I]),[pe,mt]=c.useState([]),Ze=c.useRef([]),xt=c.useMemo(()=>{const t=new Map;for(const o of I)t.set(A(o),o);return t},[I]),R=c.useMemo(()=>I.map(A),[I]),Wt=c.useMemo(()=>R.join("|"),[R]);c.useEffect(()=>{mt(t=>{if(d)return[];const o=[],n=new Set(R);for(const a of t)n.has(a)&&o.push(a);for(const a of R)o.includes(a)||o.push(a);return o})},[d,Wt]),c.useEffect(()=>{Ze.current=pe},[pe]),c.useEffect(()=>{Re&&(R.includes(Re)||me(null))},[Re,R]),c.useEffect(()=>{ue(t=>{if(t.size===0)return t;const o=new Set(I.map(A)),n=new Set;for(const a of t)o.has(a)&&n.add(a);return n.size===t.size?t:n})},[I]),c.useEffect(()=>{if(!u)return;I.some(o=>A(o)===u)||ee(null)},[u,I]),c.useEffect(()=>{if(te.length===0){Me(!1);return}Me(!1)},[te]),c.useEffect(()=>{W&&!d&&H.size>0&&we(!1)},[d,H.size,W]),c.useEffect(()=>{if(!ge)return;const t=n=>{var p;const a=n.target;a&&((p=st.current)!=null&&p.contains(a)||we(!1))},o=n=>{n.key==="Escape"&&we(!1)};return document.addEventListener("mousedown",t),document.addEventListener("touchstart",t),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t),document.removeEventListener("keydown",o)}},[ge]),c.useEffect(()=>{if(!Ke)return;const t=nt.current,o=rt.current;if(!t||!o)return;const n=new IntersectionObserver(a=>{a.some(p=>p.isIntersecting)&&(T||Le||at().catch(()=>null))},{root:t,rootMargin:"220px 0px 220px 0px",threshold:0});return n.observe(o),()=>n.disconnect()},[at,Ke,Le,T]);const pt=async t=>{const o=A(t),n=S(t.workstreamTitle);try{await Z.remove({initiativeId:t.initiativeId,workstreamId:t.workstreamId}),ue(a=>{if(!a.has(o))return a;const p=new Set(a);return p.delete(o),p}),me(a=>a===o?null:a),j(`Removed ${n} from queue.`)}catch(a){const p=a instanceof Error?a.message:"";j(he(p,"Failed to remove from queue"))}},Vt=(t,o,n)=>{const a=d?R:pe.length>0?pe:R;ue(p=>{const b=new Set(p),P=Re;if(n&&P&&a.includes(P)){const v=a.indexOf(t),J=a.indexOf(P);if(v>=0&&J>=0){const[Ue,Ae]=v<J?[v,J]:[J,v];for(const Ne of a.slice(Ue,Ae+1))o?b.add(Ne):b.delete(Ne)}else o?b.add(t):b.delete(t)}else o?b.add(t):b.delete(t);return b}),me(t)},Ft=()=>{ue(new Set(R)),me(R.length>0?R[R.length-1]:null)},Ht=()=>{ue(new Set),me(null)},Je=async t=>{if(H.size===0){j("Select one or more queue items first.");return}const o=I.map(n=>({key:A(n),item:n})).filter(n=>H.has(n.key));if(o.length===0){j("Selected queue items are no longer visible.");return}O(`bulk:${t}`),j(null);try{const n=o.map(({item:v})=>({initiativeId:v.initiativeId,workstreamId:v.workstreamId})),a=await Z.bulk({action:t,items:n}),p=typeof(a==null?void 0:a.updated)=="number"?a.updated??0:0,b=typeof(a==null?void 0:a.failed)=="number"?a.failed??0:0,P=Array.isArray(a==null?void 0:a.errors)?a.errors.filter(v=>typeof v=="string").map(v=>v.trim()).filter(Boolean):[],N=t==="remove"?"removed":t==="move_top"?"moved to top":"moved to bottom";p===0&&b>0&&P.length>0?j(he(P[0],`${b} queue action${b===1?"":"s"} failed.`)):j(b>0?`${p} item${p===1?"":"s"} ${N}; ${b} failed.`:`${p} item${p===1?"":"s"} ${N}.`),ue(new Set),me(null)}catch(n){const a=n instanceof Error?n.message:"";j(he(a,"Bulk queue action failed"))}finally{O(null)}},Zt=async()=>{const t=Ze.current.map(o=>xt.get(o)).filter(Boolean).map(o=>({initiativeId:o.initiativeId,workstreamId:o.workstreamId}));t.length!==0&&await Z.reorder({order:t})},ne=async(t,o,n)=>{j(null),de(null),z==null||z(null),O(t);try{const a=await o();j(typeof n=="function"?n(a):n)}catch(a){if(a instanceof as)de(a),z==null||z(a);else{const p=a instanceof Error?a.message:"";j(he(p,"Action failed"))}}finally{O(null)}},Be=async t=>V?await V(t):await zt({initiativeId:t.initiativeId,workstreamId:t.workstreamId,agentId:t.runnerAgentId}),Pe=C?"upgrade":Ee?"error":U?"notice":null,ht=Ee?bs(Ee):null,ke=te.length>0?gs(te[0]):null,Jt=Pe!==null,Xt=te.length>0&&ke!==null&&!Ut&&u===null&&!ge,re=Qt.length,Yt=c.useMemo(()=>k==="initiative"?Fe.length>0:k==="milestone"?He.length>0:I.length>0,[Fe.length,I.length,He.length,k]),ft=W&&se&&!d&&re>0,bt=c.useMemo(()=>{let t=0;for(const o of xe)o.queueState===m.RUNNING&&t++;return t},[xe]),Ot=k==="initiative"?"No initiatives in the queue right now.":k==="milestone"?"No milestone slices in the queue right now.":bt>0?"No queued workstreams right now. Active execution has moved to In Progress.":te.length>0&&ke?"Queue signal is delayed right now.":"No queued workstreams right now.",gt=e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:Ft,className:"control-pill h-8 px-2.5 text-caption font-semibold",children:"Select all"}),e.jsx("button",{type:"button",onClick:Ht,disabled:H.size===0,className:"control-pill h-8 px-2.5 text-caption font-semibold disabled:opacity-45",children:"Clear"}),e.jsx("button",{type:"button",disabled:re===0||B==="bulk:move_top",onClick:()=>void Je("move_top"),className:"control-pill h-8 px-2.5 text-caption font-semibold disabled:opacity-45",children:"Move top"}),e.jsx("button",{type:"button",disabled:re===0||B==="bulk:move_bottom",onClick:()=>void Je("move_bottom"),className:"control-pill h-8 px-2.5 text-caption font-semibold disabled:opacity-45",children:"Move bottom"}),e.jsx("button",{type:"button",disabled:re===0||B==="bulk:remove",onClick:()=>void Je("remove"),className:"control-pill h-8 px-2.5 text-caption font-semibold disabled:opacity-45",children:"Remove"})]});return e.jsxs(ss,{surface:Ie==="card",className:`flex h-full min-h-0 flex-col overflow-hidden ${q?"":"card-enter"} ${Ie==="flat"?"!rounded-none !border-none !bg-transparent !shadow-none":""} ${w??""}`,children:[h?e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-subtle px-4 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("h2",{className:"truncate text-heading font-semibold text-white",children:x}),e.jsx("span",{className:"chip inline-flex min-w-[52px] justify-center text-micro tabular-nums",children:T?e.jsx("span",{"aria-hidden":!0,className:"h-2.5 w-5 rounded bg-white/15 animate-pulse"}):ut}),e.jsx("span",{className:ae("inline-flex min-w-[92px] justify-end text-micro text-muted transition-opacity",it&&!T?"opacity-100":"opacity-0"),"aria-live":"polite",children:"refreshing…"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"inline-flex items-center rounded-xl border border-white/[0.1] bg-white/[0.03] p-1",role:"tablist","aria-label":"Next Up scope",children:Kt.map(t=>{const o=k===t.value;return e.jsxs(_.button,{type:"button",role:"tab","aria-selected":o,onClick:()=>Y(t.value),...y.segmentedTap,className:ae("relative h-7 rounded-lg px-2.5 text-caption font-semibold transition-colors",o?"text-lime":"text-secondary hover:text-white"),title:`Show ${t.label.toLowerCase()} queue`,children:[o?e.jsx(_.span,{layoutId:"next-up-scope-indicator",transition:K?{duration:.01}:y.railMorphSpring,className:"pointer-events-none absolute inset-0 rounded-lg border border-lime/35 bg-lime/16","aria-hidden":!0}):null,e.jsx("span",{className:"relative z-[1]",children:t.label})]},t.value)})}),L?e.jsx("button",{type:"button",onClick:()=>le(!d),className:"control-pill h-8 flex-shrink-0 whitespace-nowrap px-3 text-caption font-semibold",title:d?"Switch to expanded cards":"Switch to compact list","aria-label":d?"Expand Next Up queue":"Compact Next Up queue",children:d?"Expand":"Compact"}):null]})]}):null,Jt&&e.jsx("div",{className:"px-3 pt-2",children:e.jsx(je,{initial:!1,mode:"wait",children:Pe==="upgrade"&&C?e.jsx(_.div,{initial:{opacity:0,y:-4,scale:.99},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.99},transition:Ve,className:"rounded-xl border border-amber-200/25 bg-amber-200/10 px-3 py-2 text-caption text-amber-100",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"rounded-full border border-amber-200/25 bg-amber-200/10 px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em] text-amber-100/90",children:"Upgrade required"}),e.jsxs("span",{className:"truncate text-micro text-secondary",children:[yt(C.currentPlan)," →"," ",yt(C.requiredPlan)]})]}),e.jsx("div",{className:"mt-1 line-clamp-2 text-caption leading-snug text-amber-50/90",title:C.message,children:C.message}),U?e.jsx("div",{className:"mt-1 text-micro text-rose-50/85",children:U}):null]}),e.jsxs("div",{className:"flex flex-shrink-0 flex-col items-end gap-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>void us({actions:C.actions,requiredPlan:C.requiredPlan}).catch(t=>j(he(t instanceof Error?t.message:"","Checkout failed"))),className:"h-7 rounded-full border border-amber-200/25 bg-amber-200/15 px-3 text-micro font-semibold text-amber-50 transition-colors hover:bg-amber-200/20",children:"Upgrade"}),e.jsx("button",{type:"button",onClick:()=>void ms({actions:C.actions}).catch(t=>j(he(t instanceof Error?t.message:"","Portal failed"))),className:"h-7 rounded-full border border-strong bg-white/[0.04] px-3 text-micro font-semibold text-primary transition-colors hover:bg-white/[0.08]",children:"Billing"}),E&&e.jsx("button",{type:"button",onClick:E,className:"h-7 rounded-full border border-strong bg-white/[0.04] px-2.5 text-micro font-semibold text-primary transition-colors hover:bg-white/[0.08]",children:"Settings"})]}),(wt=C.actions)!=null&&wt.pricing?e.jsx("a",{href:C.actions.pricing,target:"_blank",rel:"noopener noreferrer",className:"text-micro text-secondary underline decoration-white/20 hover:text-primary",children:"View pricing"}):null]})]})},"upgrade"):Pe==="error"&&ht?e.jsx(_.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:Ve,className:"rounded-xl border border-red-400/25 bg-red-500/[0.08] px-3 py-2 text-caption text-red-100",children:ht},"error"):Pe==="notice"&&U?e.jsx(_.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:Ve,className:"rounded-xl border border-white/[0.1] bg-white/[0.03] px-3 py-2 text-caption text-primary",children:U},"notice"):null})}),e.jsxs("div",{ref:nt,className:`flex-1 space-y-2.5 overflow-y-auto overscroll-y-contain scroll-smooth px-3 pb-3 ${h?"pt-1":"pt-2.5"}`,children:[!T&&ut>0?e.jsxs("div",{className:"flex flex-col gap-2.5 px-0.5 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-micro uppercase tracking-[0.08em] text-muted",children:k==="initiative"?"Initiatives":k==="milestone"?"Milestone slices":lt===m.BLOCKED?"Needs attention":lt===m.RUNNING?"Running now":"Next Up"}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[re>0?e.jsxs("span",{className:"chip text-micro",children:[re," selected"]}):null,e.jsx("span",{className:ae("inline-flex min-w-[92px] text-micro text-muted transition-opacity",it&&!T?"opacity-100":"opacity-0"),"aria-live":"polite",children:"refreshing…"}),W&&se&&!d&&re===0?e.jsx("span",{className:"text-micro text-muted",children:"Shift+select to pick ranges."}):null]})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 sm:justify-end",children:[L?e.jsx("button",{type:"button",onClick:()=>le(!d),className:"control-pill h-8 px-2.5 text-caption font-semibold",title:d?"Switch to expanded cards":"Switch to compact list","aria-label":d?"Expand Next Up queue":"Compact Next Up queue",children:d?"Expand":"Compact"}):null,ft?e.jsx("div",{className:"flex flex-wrap justify-end gap-1.5",children:gt}):null,!ft&&qe&&se?e.jsxs("div",{ref:st,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>we(t=>!t),className:"control-pill h-8 px-2.5 text-caption font-semibold","aria-haspopup":"menu","aria-expanded":ge,title:"Queue settings",children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"opacity-85","aria-hidden":!0,children:[e.jsx("path",{d:"M4 6h16"}),e.jsx("path",{d:"M7 12h10"}),e.jsx("path",{d:"M10 18h4"})]}),e.jsx("span",{children:"Queue"})]}),ge?e.jsx("div",{className:"surface-tier-2 absolute right-0 top-[calc(100%+8px)] z-[280] w-[320px] max-w-[86vw] rounded-xl p-3 shadow-[0_18px_42px_rgba(0,0,0,0.46)] backdrop-blur-xl",children:e.jsxs("div",{className:"space-y-2.5",children:[W&&!d?e.jsxs("div",{children:[e.jsx("p",{className:"section-kicker",children:"Bulk actions"}),e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:gt})]}):null,E?e.jsx("button",{type:"button",onClick:()=>{we(!1),E()},className:"control-pill h-7 px-2.5 text-micro font-semibold",children:"Open settings"}):null]})}):null]}):null]})]}):null,T?e.jsx(ws,{compact:d}):null,!T&&!Yt&&!Ee&&e.jsx(ns,{icon:"queue",headline:Ot,description:bt>0?"Check the In Progress tab to see active work.":ke??"Create an initiative or add workstreams to populate the queue.",primaryAction:te.length>0&&ke?{label:"Retry now",onClick:()=>{Me(!1),_t()}}:void 0}),!T&&k==="initiative"?e.jsx(je,{initial:!1,children:Fe.map((t,o)=>{const n=t.items.find(N=>X(N))??t.items[0]??null,a=Ce(t.initiativeTitle,t.initiativeId,"Initiative"),p=kt(t.queueState),b=Nt(t.queueState),P=t.items.reduce((N,v)=>N+(v.sliceTaskCount??0),0);return e.jsxs(_.article,{layout:!0,initial:{opacity:0,y:8,scale:.99},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.99},transition:{duration:K?.01:y.surfaceSwitch.duration,delay:K?0:Math.min(o,y.listStaggerMaxItems)*y.listStaggerStep,ease:y.surfaceSwitch.ease},className:"rounded-2xl border border-white/[0.08] bg-white/[0.02] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:"Initiative"}),e.jsx("p",{className:"mt-0.5 truncate text-body font-semibold text-white",title:a,children:a})]}),e.jsx("span",{className:ae("inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.08em]",b),children:p})]}),e.jsxs("p",{className:"mt-1 text-micro text-secondary",children:[t.workstreamCount," workstreams · ",P," tasks"]}),e.jsx("div",{className:"mt-2 space-y-1",children:t.items.slice(0,3).map((N,v)=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg border border-white/[0.06] bg-black/[0.18] px-2.5 py-1.5 text-caption",children:[e.jsx("span",{className:"truncate text-white/84",children:S(N.workstreamTitle)}),e.jsxs("span",{className:"text-micro text-secondary",children:[N.sliceTaskCount??0," tasks"]})]},`${N.workstreamId}:${v}`))}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>$==null?void 0:$(t.initiativeId,t.initiativeTitle),className:"control-pill h-7 px-2.5 text-micro font-semibold",children:"Open"}),e.jsx("button",{type:"button",disabled:!n||B===`initiative:${t.initiativeId}`,onClick:()=>{n&&ne(`initiative:${t.initiativeId}`,()=>Be(n),N=>ze(n,N))},className:"control-pill h-7 px-2.5 text-micro font-semibold disabled:opacity-45",title:n?_e(n,n.queueState===m.RUNNING):"No dispatchable workstream is available",children:"Dispatch"})]})]},`initiative-group:${t.initiativeId}`)})}):null,!T&&k==="milestone"?e.jsx(je,{initial:!1,children:He.map((t,o)=>{const n=t.item,a=`milestone:${t.workstreamId}:${t.milestoneId??"none"}`;return e.jsxs(_.article,{layout:!0,initial:{opacity:0,y:8,scale:.99},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.99},transition:{duration:K?.01:y.surfaceSwitch.duration,delay:K?0:Math.min(o,y.listStaggerMaxItems)*y.listStaggerStep,ease:y.surfaceSwitch.ease},className:"rounded-2xl border border-white/[0.08] bg-white/[0.02] px-3 py-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-micro uppercase tracking-[0.08em] text-muted",children:[S(t.initiativeTitle)," · ",S(t.workstreamTitle)]}),e.jsx("p",{className:"mt-0.5 truncate text-body font-semibold text-white",title:t.milestoneTitle,children:S(t.milestoneTitle)})]}),e.jsx("span",{className:ae("inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.08em]",Nt(t.queueState)),children:kt(t.queueState)})]}),e.jsxs("p",{className:"mt-1 text-micro text-secondary",children:[t.taskCount," tasks in slice"]}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>$==null?void 0:$(t.initiativeId,t.initiativeTitle),className:"control-pill h-7 px-2.5 text-micro font-semibold",children:"Open"}),e.jsx("button",{type:"button",disabled:B===a||!X(n),onClick:()=>void ne(a,()=>Be(n),p=>ze(n,p)),className:"control-pill h-7 px-2.5 text-micro font-semibold disabled:opacity-45",title:_e(n,t.queueState===m.RUNNING),children:t.queueState===m.RUNNING?"Running":X(n)?"Start":"Unavailable"})]})]},`${t.initiativeId}:${t.workstreamId}:${t.milestoneId??"none"}`)})}):null,!T&&se&&d?e.jsx(je,{initial:!1,children:I.map((t,o)=>{const n=A(t),a=B===n,p=t.queueState===m.RUNNING,b=t.nextTaskDueAt?jt(t.nextTaskDueAt):null,P=Ce(t.initiativeTitle,t.initiativeId,"Initiative"),N=Ce(t.workstreamTitle,t.workstreamId,"Workstream"),v=Rt(t),J=t.nextTaskTitle?S(t.nextTaskTitle):null,Ue=t.blockReason?S(t.blockReason):null,Ae=Mt(t),Ne=Lt(t);return e.jsxs(_.article,{layout:!0,initial:{opacity:0,y:6,scale:.99},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.99},transition:{duration:K?.01:y.surfaceSwitch.duration,delay:K?0:Math.min(o,y.listStaggerMaxItems)*y.listStaggerStep,ease:y.surfaceSwitch.ease},className:"group relative overflow-visible rounded-2xl border border-white/[0.08] bg-white/[0.02] px-2.5 py-2 cursor-pointer transition-colors hover:border-white/[0.14]",onClick:()=>G==null?void 0:G(t),role:"button",tabIndex:0,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),G==null||G(t))},children:[e.jsx("div",{className:`pointer-events-none absolute inset-x-2.5 top-0 h-px bg-gradient-to-r ${qt(t.queueState)}`,"aria-hidden":!0}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx(St,{name:Ae,hint:Et(t,Ae),size:"xs"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx(Se,{type:"initiative",size:11,className:"flex-shrink-0 opacity-85"}),e.jsx("button",{type:"button",onClick:()=>$==null?void 0:$(t.initiativeId,t.initiativeTitle),className:"block min-w-0 flex-1 truncate text-left text-micro uppercase tracking-[0.08em] text-muted transition-colors hover:text-white/72",title:P,children:P}),v?e.jsx("span",{className:ae("inline-flex flex-shrink-0 items-center rounded-full border px-2 py-0.5 text-[9px] font-semibold uppercase tracking-[0.08em]",v.toneClass),title:v.longLabel,children:v.shortLabel}):null]}),e.jsxs("p",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-caption font-semibold leading-snug text-white",title:N,children:[e.jsx(Se,{type:"workstream",size:12,className:"flex-shrink-0 opacity-95"}),e.jsx("span",{className:"line-clamp-2",children:N})]}),J?e.jsxs("p",{className:"mt-0.5 line-clamp-2 text-micro leading-snug text-secondary",title:`${Ye(t.queueState)}: ${J}${b?` · ${b}`:""}`,children:[Ye(t.queueState),": ",J,b?` · ${b}`:""]}):e.jsx("p",{className:"mt-0.5 line-clamp-2 text-micro leading-snug text-secondary",title:Oe(t),children:Oe(t)}),Ne?e.jsxs("p",{className:"mt-0.5 text-micro text-muted",children:["Runner ",Ne]}):null,t.milestoneBreakdown&&t.milestoneBreakdown.length>0&&e.jsxs("div",{className:"mt-1.5 space-y-1",children:[e.jsx(Ct,{milestones:t.milestoneBreakdown}),e.jsxs("p",{className:"text-micro text-secondary",children:[t.milestoneBreakdown.length," milestone",t.milestoneBreakdown.length!==1?"s":""," · ",t.milestoneBreakdown.reduce((f,M)=>f+M.doneTasks,0),"/",t.milestoneBreakdown.reduce((f,M)=>f+M.totalTasks,0)," tasks done"]})]}),t.queueState===m.COMPLETED&&t.milestoneBreakdown&&t.milestoneBreakdown.length>0&&e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-micro",style:{color:rs.done.text},children:[e.jsxs("span",{children:["✓ ",t.milestoneBreakdown.length," milestones"]}),e.jsxs("span",{children:["✓ ",t.milestoneBreakdown.reduce((f,M)=>f+M.totalTasks,0)," tasks"]})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[(()=>{const f=t.objectiveScore??t.compositeScore??null;if(f==null)return null;const M=f>=80?"S":f>=60?"A":"B",ie=M==="S"?"border-lime/30 bg-lime/[0.12] text-lime":M==="A"?"border-[#14B8A6]/30 bg-[#14B8A6]/[0.12] text-[#87FFE9]":"border-white/[0.12] bg-white/[0.05] text-white/60";return e.jsxs("span",{className:`chip text-[9px] font-semibold ${ie}`,children:[M,"-tier"]})})(),(()=>{const f=t.expectedValueUsd,M=t.sliceTaskCount??0,ie=[];return M>0&&ie.push(`${M} tasks`),typeof f=="number"&&f>0&&ie.push(`$${f.toFixed(2)}`),b&&ie.push(b),ie.length===0?null:e.jsx("span",{className:"text-micro text-muted",children:ie.join(" · ")})})()]})]})]}),(t.sliceTaskCount??0)>0&&e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-[2px] rounded-b-2xl overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.max(t.queueState===m.COMPLETED?100:t.queueState===m.RUNNING?50:15,4)}%`,background:t.queueState===m.COMPLETED?Xe.teal:`linear-gradient(90deg, ${Xe.lime}, ${Xe.teal})`,opacity:.6}})}),Ue&&e.jsxs("div",{className:"mt-1.5 rounded-lg border border-red-400/24 bg-red-500/[0.08] px-2.5 py-1 text-micro text-red-100/85",children:["Blocked: ",Ue]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",onClick:f=>f.stopPropagation(),children:[e.jsx("button",{type:"button",disabled:a||!X(t),onClick:()=>void ne(n,()=>Be(t),f=>ze(t,f)),className:"control-pill flex h-7 items-center justify-center px-2.5 text-micro font-semibold disabled:opacity-40",title:_e(t,p),children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Tt,{className:"h-3 w-3 opacity-85"}),e.jsx("span",{children:p?"Running":X(t)?"Start":"Unavailable"})]})}),e.jsxs("div",{className:"relative ml-auto",children:[e.jsx("button",{type:"button",disabled:a,onClick:()=>ee(f=>f===n?null:n),className:"control-pill flex h-7 items-center justify-center px-2.5 text-micro font-semibold disabled:opacity-40",title:"Queue actions",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Pt,{className:"h-3 w-3 opacity-85"}),e.jsx("span",{children:"More"})]})}),u===n&&e.jsxs("div",{className:"absolute right-0 top-[calc(100%+6px)] z-[320] min-w-[178px] rounded-xl border border-white/[0.1] bg-[#080d14]/95 p-1.5 shadow-[0_16px_36px_rgba(0,0,0,0.42)] backdrop-blur",children:[e.jsx("button",{type:"button",onClick:()=>{ee(null),ne(`${n}:top`,()=>Z.move({initiativeId:t.initiativeId,workstreamId:t.workstreamId,placement:"top"}),`Moved ${N} to top of queue.`)},className:"flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Move to top"}),e.jsx("button",{type:"button",onClick:()=>{ee(null),ne(`${n}:bottom`,()=>Z.move({initiativeId:t.initiativeId,workstreamId:t.workstreamId,placement:"bottom"}),`Moved ${N} to bottom of queue.`)},className:"flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Move to bottom"}),e.jsx("button",{type:"button",onClick:()=>{ee(null),ne(`${n}:auto`,()=>ot({initiativeId:t.initiativeId,workstreamId:t.workstreamId,agentId:t.runnerAgentId,scope:"initiative"}),f=>Bt(t,f))},className:"flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Auto on"}),e.jsx("button",{type:"button",disabled:Z.isRemoving,onClick:()=>{ee(null),pt(t)},className:"mt-1 flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-red-100 transition-colors hover:bg-red-500/[0.12] disabled:opacity-45",children:"Remove from queue"})]})]})]})]},n)})}):!T&&se?e.jsx(os,{axis:"y",values:pe,onReorder:t=>{Ze.current=t,mt(t)},className:"space-y-2.5",children:pe.map(t=>xt.get(t)).filter(Boolean).map((t,o)=>e.jsx(vs,{item:t,index:o,actionKey:B,setNotice:j,setUpgradeGate:de,onUpgradeGate:z,onOpenInitiative:$,onOpenSliceDetail:G,selected:H.has(A(t)),selectionEnabled:W,onToggleSelection:Vt,menuKey:u,setMenuKey:ee,onPlayWorkstream:Be,startWorkstreamAutoContinue:ot,triagePlacement:ce,onPauseWorkstream:(n,a)=>Z.stopTriage({initiativeId:n.initiativeId,workstreamId:n.workstreamId,placement:a,resetToTodo:!1}),onMoveWorkstream:(n,a)=>Z.move({initiativeId:n.initiativeId,workstreamId:n.workstreamId,placement:a}),onCommitReorder:()=>void Zt().catch(()=>null),onDismiss:pt,runAction:ne},A(t)))}):null,(Ke||Le)&&e.jsx("div",{ref:rt,className:"flex h-10 items-center justify-center",children:e.jsx("span",{className:"text-micro text-muted",children:Le?"Loading more queue items…":"Scroll for more"})})]}),e.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-[250]",children:e.jsx(ps,{open:Xt,tone:"warning",title:"Limited signal",message:ke,autoDismissMs:6e3,onDismiss:()=>Me(!0)})})]})}function vs({item:s,index:r,actionKey:l,setNotice:i,setUpgradeGate:x,onUpgradeGate:h,onOpenInitiative:g,onOpenSliceDetail:w,selected:q,selectionEnabled:L,onToggleSelection:fe,menuKey:$,setMenuKey:E,onPlayWorkstream:z,startWorkstreamAutoContinue:G,triagePlacement:W,onPauseWorkstream:Ie,onMoveWorkstream:qe,onCommitReorder:$e,onDismiss:Ge,runAction:V}){const Te=ls(),F=It(),[oe,be]=c.useState(!1),d=`${s.initiativeId}:${s.workstreamId}`,le=l===d,U=s.queueState===m.RUNNING,j=s.nextTaskDueAt?jt(s.nextTaskDueAt):null,k=Ce(s.initiativeTitle,s.initiativeId,"Initiative"),Y=Ce(s.workstreamTitle,s.workstreamId,"Workstream"),ce=Rt(s),C=s.nextTaskTitle?S(s.nextTaskTitle):null,de=s.blockReason?S(s.blockReason):null,B=Mt(s),O=Lt(s);return e.jsx(cs,{value:d,id:d,dragListener:!1,dragControls:Te,onDragStart:()=>be(!0),onDragEnd:()=>{be(!1),$e()},whileDrag:{scale:1.02,boxShadow:"0 20px 48px rgba(0,0,0,0.5), 0 0 0 1px rgba(191,255,0,0.15)",zIndex:50,cursor:"grabbing"},className:"relative",children:e.jsxs(_.article,{layout:!0,initial:{opacity:0,y:12,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.98},transition:{duration:F?.01:y.surfaceSwitch.duration,ease:y.surfaceSwitch.ease,delay:F?0:Math.min(r,y.listStaggerMaxItems)*y.listStaggerStep,opacity:{duration:F?.01:y.surfaceSwitch.duration,ease:y.surfaceSwitch.ease}},className:"group relative overflow-visible rounded-2xl border border-white/[0.08] bg-white/[0.02] px-3 py-3 cursor-pointer transition-colors hover:border-white/[0.14]",onClick:()=>w==null?void 0:w(s),role:"button",tabIndex:0,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),w==null||w(s))},children:[e.jsx("div",{className:`pointer-events-none absolute inset-x-3 top-0 h-px bg-gradient-to-r ${qt(s.queueState)}`,"aria-hidden":!0}),e.jsx("div",{className:"flex items-start justify-between gap-2.5",children:e.jsxs("div",{className:"min-w-0 flex flex-1 items-start gap-2.5",children:[e.jsxs("div",{className:"relative h-8 w-8 flex-shrink-0",children:[e.jsx("div",{className:`absolute inset-0 transition-[opacity,transform] duration-200 ease-out ${L?q?"opacity-0 scale-90":"opacity-100 scale-100 group-hover:opacity-0 group-hover:scale-90 group-focus-within:opacity-0 group-focus-within:scale-90":"opacity-100 scale-100"}`,children:e.jsx(St,{name:B,hint:Et(s,B),size:"sm"})}),L?e.jsx("button",{type:"button",role:"checkbox","aria-checked":q,"aria-label":"Select queue row",title:q?"Selected (Shift+click for range)":"Select (Shift+click for range)",onClick:u=>{u.stopPropagation(),fe(d,!q,u.shiftKey)},onMouseDown:u=>u.stopPropagation(),onKeyDown:u=>u.stopPropagation(),className:`absolute inset-0 flex items-center justify-center rounded-full border transition-[opacity,transform,background-color,border-color,color] duration-200 ease-out ${q?"opacity-100 scale-100 border-lime/40 bg-lime/18 text-lime":"opacity-0 scale-90 border-white/[0.24] bg-black/55 text-white/78 group-hover:opacity-100 group-hover:scale-100 group-focus-within:opacity-100 group-focus-within:scale-100 hover:bg-black/62"}`,children:e.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center rounded-full border border-current/45 bg-black/30",children:q?e.jsx("svg",{viewBox:"0 0 16 16",className:"h-2.5 w-2.5",fill:"none","aria-hidden":!0,children:e.jsx("path",{d:"M3.2 8.3 6.2 11l6.6-6.1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx(Se,{type:"initiative",size:11,className:"flex-shrink-0 opacity-85"}),e.jsx("button",{type:"button",onClick:()=>g==null?void 0:g(s.initiativeId,s.initiativeTitle),className:"block min-w-0 flex-1 truncate text-left text-micro uppercase tracking-[0.08em] text-muted transition-colors hover:text-white/72",title:k,children:k}),ce?e.jsx("span",{className:ae("inline-flex flex-shrink-0 items-center rounded-full border px-2 py-0.5 text-[9px] font-semibold uppercase tracking-[0.08em]",ce.toneClass),title:ce.longLabel,children:ce.shortLabel}):null]}),e.jsxs("div",{className:"mt-0.5 flex min-w-0 items-start gap-1.5",children:[e.jsx(Se,{type:"workstream",size:12,className:"mt-[3px] flex-shrink-0 opacity-95"}),e.jsx("p",{className:"min-w-0 line-clamp-2 text-body font-semibold leading-snug text-white",title:Y,children:Y})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-micro text-secondary",children:[e.jsx("span",{className:"rounded-full border border-strong bg-white/[0.03] px-2 py-0.5 text-micro uppercase tracking-[0.08em] text-secondary",children:"Runner"}),e.jsxs("span",{className:"truncate text-white/68",children:[B,O?` · ${O}`:""]})]})]})]})}),e.jsx("div",{className:"mt-2 rounded-lg border border-white/[0.07] bg-black/[0.18] px-2.5 py-2 text-caption text-white/68",children:C?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-micro uppercase tracking-[0.08em] text-white/44",children:[e.jsx(Se,{type:"task",size:10,className:"flex-shrink-0 opacity-80"}),e.jsx("span",{children:Ye(s.queueState)}),j?e.jsxs("span",{className:"truncate text-micro normal-case tracking-normal text-muted",children:["· ",j]}):null]}),e.jsx("p",{className:"line-clamp-2 break-words text-caption leading-snug text-white/84",title:C,children:C})]}):e.jsx("span",{className:"text-secondary",children:Oe(s)})}),s.milestoneBreakdown&&s.milestoneBreakdown.length>0&&e.jsxs("div",{className:"mt-2 rounded-lg border border-white/[0.07] bg-black/[0.18] px-2.5 py-2",children:[e.jsx(Ct,{milestones:s.milestoneBreakdown}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-x-3 gap-y-0.5",children:[s.milestoneBreakdown.slice(0,4).map(u=>e.jsxs("span",{className:"text-micro text-secondary",children:[u.doneTasks===u.totalTasks&&u.totalTasks>0?"✓":"○"," ",u.title,e.jsxs("span",{className:"ml-1 text-muted",children:[u.doneTasks,"/",u.totalTasks]})]},u.id)),s.milestoneBreakdown.length>4&&e.jsxs("span",{className:"text-micro text-muted",children:["+",s.milestoneBreakdown.length-4]})]})]}),de&&e.jsxs("div",{className:"mt-1.5 rounded-lg border border-red-400/24 bg-red-500/[0.08] px-2.5 py-1 text-micro text-red-100/85",children:["Blocked: ",de]}),e.jsxs("div",{className:"mt-2 flex items-center gap-1.5",onClick:u=>u.stopPropagation(),children:[e.jsx("button",{type:"button",disabled:le||!X(s),onClick:()=>void V(d,()=>z(s),u=>ze(s,u)),className:"control-pill flex h-7 items-center justify-center px-2.5 text-micro font-semibold disabled:opacity-40",title:_e(s,U),children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Tt,{className:"h-3 w-3 opacity-85"}),e.jsx("span",{children:U?"Running":X(s)?"Start":"Unavailable"})]})}),e.jsxs("button",{type:"button",onPointerDown:u=>Te.start(u),"aria-label":"Drag to reorder",title:oe?"Reordering":"Drag to reorder",className:`control-pill flex h-7 items-center justify-center gap-1 px-2 text-micro font-semibold transition-colors ${oe?"border-lime/35 bg-lime/14 text-lime cursor-grabbing":"cursor-grab hover:bg-white/[0.08] hover:text-bright"}`,children:[oe?e.jsx(fs,{className:"h-3.5 w-3.5 opacity-90"}):e.jsx(hs,{className:"h-3.5 w-3.5 opacity-90"}),e.jsx("span",{children:oe?"Reordering":"Drag"})]}),e.jsxs("div",{className:"relative ml-auto",children:[e.jsx("button",{type:"button",disabled:le,onClick:()=>E(u=>u===d?null:d),className:"control-pill flex h-7 items-center justify-center px-2.5 text-micro font-semibold disabled:opacity-40",title:"Queue actions",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Pt,{className:"h-3 w-3 opacity-85"}),e.jsx("span",{children:"More"})]})}),$===d&&e.jsxs("div",{className:"absolute right-0 top-[calc(100%+6px)] z-[320] min-w-[198px] rounded-xl border border-white/[0.1] bg-[#080d14]/95 p-1.5 shadow-[0_16px_36px_rgba(0,0,0,0.42)] backdrop-blur",children:[e.jsx("button",{type:"button",onClick:()=>{E(null),V(`${d}:top`,()=>qe(s,"top"),`Moved ${Y} to top of queue.`)},className:"flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Move to top"}),e.jsx("button",{type:"button",onClick:()=>{E(null),V(`${d}:bottom`,()=>qe(s,"bottom"),`Moved ${Y} to bottom of queue.`)},className:"flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Move to bottom"}),e.jsx("button",{type:"button",onClick:()=>{E(null),V(`${d}:auto`,()=>G({initiativeId:s.initiativeId,workstreamId:s.workstreamId,agentId:s.runnerAgentId,scope:"initiative"}),u=>Bt(s,u))},className:"flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Auto on"}),U?e.jsx("button",{type:"button",onClick:()=>{E(null),V(`${d}:pause`,()=>Ie(s,W),`Paused ${Y}.`)},className:"mt-1 flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Pause run"}):null,e.jsx("button",{type:"button",disabled:le||U,onClick:()=>{E(null),Ge(s)},className:"mt-1 flex h-8 w-full items-center rounded-md px-2.5 text-left text-caption text-red-100 transition-colors hover:bg-red-500/[0.12] disabled:opacity-45",children:"Remove from queue"})]})]})]})]})})}const Is=Object.freeze(Object.defineProperty({__proto__:null,NextUpPanel:ys},Symbol.toStringTag,{value:"Module"}));export{ps as I,ys as N,Is as a,us as o};
@@ -1,2 +1,2 @@
1
- import{r as d,j as e}from"./Dj2k1r16.js";import{z as C,E as k,f as m,w as S}from"./CSd4rSuU.js";import"./DMKyYAtD.js";import"./eeHXe_OQ.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";function $(i){const o=i.trim().toLowerCase();return o==="fulfilled"||o==="completed"?m.lime:o==="claimed"?m.teal:o==="blocked"?m.red:m.amber}function H({open:i,onClose:o,handoffs:x}){const[p,g]=d.useState(""),[c,h]=d.useState(new Set),[y,n]=d.useState(null);d.useEffect(()=>{i&&n(null)},[i]);const b=d.useMemo(()=>[...x].sort((t,s)=>Date.parse(s.updatedAt??"")-Date.parse(t.updatedAt??"")),[x]),r=d.useMemo(()=>{const t=p.trim().toLowerCase();return t?b.filter(s=>[s.title,s.summary,s.status,s.priority].filter(Boolean).join(" ").toLowerCase().includes(t)):b},[b,p]);d.useEffect(()=>{i&&h(t=>{const s=new Set(r.map(a=>a.id)),l=new Set;for(const a of t)s.has(a)&&l.add(a);return l})},[r,i]);const u=c.size,f=r.length>0&&r.every(t=>c.has(t.id)),w=()=>{h(t=>r.length===0?t:f?new Set:new Set(r.map(s=>s.id)))},j=t=>{h(s=>{const l=new Set(s);return l.has(t)?l.delete(t):l.add(t),l})},N=async()=>{const t=r.filter(a=>u===0||c.has(a.id)),s=[];s.push(`# Handoffs (${t.length})`),s.push("");for(const a of t)s.push(`- **${a.title}** — ${a.status}${a.priority?` (priority: ${a.priority})`:""}`),a.summary&&s.push(` - ${a.summary}`),s.push(` - Updated: ${a.updatedAt}`);const l=s.join(`
1
+ import{r as d,j as e}from"./Dj2k1r16.js";import{z as C,E as k,f as m,w as S}from"./C0i7ABUU.js";import"./DMKyYAtD.js";import"./eeHXe_OQ.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";function $(i){const o=i.trim().toLowerCase();return o==="fulfilled"||o==="completed"?m.lime:o==="claimed"?m.teal:o==="blocked"?m.red:m.amber}function H({open:i,onClose:o,handoffs:x}){const[p,g]=d.useState(""),[c,h]=d.useState(new Set),[y,n]=d.useState(null);d.useEffect(()=>{i&&n(null)},[i]);const b=d.useMemo(()=>[...x].sort((t,s)=>Date.parse(s.updatedAt??"")-Date.parse(t.updatedAt??"")),[x]),r=d.useMemo(()=>{const t=p.trim().toLowerCase();return t?b.filter(s=>[s.title,s.summary,s.status,s.priority].filter(Boolean).join(" ").toLowerCase().includes(t)):b},[b,p]);d.useEffect(()=>{i&&h(t=>{const s=new Set(r.map(a=>a.id)),l=new Set;for(const a of t)s.has(a)&&l.add(a);return l})},[r,i]);const u=c.size,f=r.length>0&&r.every(t=>c.has(t.id)),w=()=>{h(t=>r.length===0?t:f?new Set:new Set(r.map(s=>s.id)))},j=t=>{h(s=>{const l=new Set(s);return l.has(t)?l.delete(t):l.add(t),l})},N=async()=>{const t=r.filter(a=>u===0||c.has(a.id)),s=[];s.push(`# Handoffs (${t.length})`),s.push("");for(const a of t)s.push(`- **${a.title}** — ${a.status}${a.priority?` (priority: ${a.priority})`:""}`),a.summary&&s.push(` - ${a.summary}`),s.push(` - Updated: ${a.updatedAt}`);const l=s.join(`
2
2
  `);try{await navigator.clipboard.writeText(l),n("Copied markdown."),setTimeout(()=>n(null),1200)}catch{n("Copy failed (clipboard unavailable).")}},v=async()=>{const t=r.filter(s=>u===0||c.has(s.id));try{await navigator.clipboard.writeText(JSON.stringify(t,null,2)),n("Copied JSON."),setTimeout(()=>n(null),1200)}catch{n("Copy failed (clipboard unavailable).")}};return e.jsx(C,{open:i,onClose:o,maxWidth:"max-w-3xl",children:e.jsxs("div",{className:"flex h-full w-full flex-col",children:[e.jsxs("div",{className:"border-b border-subtle px-5 pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"inline-flex items-center gap-2 text-heading font-semibold text-white",children:[e.jsx(k,{type:"handoff",size:14}),e.jsx("span",{className:"truncate",children:"Handoffs"}),e.jsx("span",{className:"rounded-full border border-strong bg-white/[0.04] px-2 py-0.5 text-caption font-semibold text-primary",children:x.length})]}),e.jsx("p",{className:"mt-1 text-body leading-relaxed text-secondary",children:"Review and export current handoffs. Select items for a tighter export."})]}),e.jsx("button",{type:"button",onClick:o,className:"rounded-md border border-strong bg-white/[0.03] px-2.5 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08]","aria-label":"Close handoffs modal",children:"Close"})]}),e.jsxs("div",{className:"mt-4 flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"sr-only",htmlFor:"bulk-handoffs-search",children:"Search handoffs"}),e.jsx("input",{id:"bulk-handoffs-search",value:p,onChange:t=>g(t.target.value),placeholder:"Search title, summary, status…","data-modal-autofocus":"true",className:"w-full rounded-lg border border-strong bg-black/25 px-3 py-2 text-body text-white placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-lime/35"})]}),e.jsx("button",{type:"button",onClick:w,disabled:r.length===0,className:"rounded-lg border border-strong bg-white/[0.03] px-3 py-2 text-caption text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:f?"Clear all":`Select all (${r.length})`})]}),y&&e.jsx("div",{className:"mt-3 rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2 text-body text-secondary",children:y})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:r.length===0?e.jsx("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-4 text-body text-secondary",children:"No handoffs match this view."}):e.jsx("div",{className:"space-y-2",children:r.map(t=>{const s=c.has(t.id),l=$(t.status);return e.jsx("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2.5",style:{borderColor:s?`${m.lime}40`:"rgba(255,255,255,0.08)"},children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:()=>j(t.id),className:"mt-0.5 h-4 w-4 rounded border-white/20 bg-black/40 text-lime focus:ring-lime/40","aria-label":`Select handoff ${t.title}`}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-body font-medium text-white",children:t.title}),t.summary&&e.jsx("p",{className:"mt-1 line-clamp-2 text-caption text-secondary",children:t.summary}),e.jsxs("p",{className:"mt-1 text-micro text-secondary",children:["Updated ",S(t.updatedAt)]})]}),e.jsx("span",{className:"shrink-0 rounded-full border px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em]",style:{borderColor:`${l}30`,backgroundColor:`${l}14`,color:l},children:t.status})]})})]})},t.id)})})}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-subtle px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"text-caption text-secondary",children:u>0?`${u} selected`:"No selection (exporting will include all filtered handoffs)"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:N,disabled:r.length===0,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:"Copy markdown"}),e.jsx("button",{type:"button",onClick:v,disabled:r.length===0,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:"Copy JSON"})]})]})]})})}export{H as BulkHandoffsModal};
@@ -1,2 +1,2 @@
1
- import{r as p,j as e}from"./Dj2k1r16.js";import{z as D,E as W,f as m,w as Q}from"./CSd4rSuU.js";import"./DMKyYAtD.js";import"./eeHXe_OQ.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";const q={blocked:0,failed:1,running:2,active:2,queued:3,in_progress:3,pending:4,paused:5,cancelled:6,completed:7,archived:8};function Y(n){if(!n)return 0;const x=Date.parse(n);return Number.isFinite(x)?x:0}function I(n){return Y(n.updatedAt??n.lastEventAt??n.startedAt)}function G(n,x){const i=q[(n.status??"").toLowerCase()]??99,y=q[(x.status??"").toLowerCase()]??99;return i!==y?i-y:I(x)-I(n)}function H(n,x){const i=n.trim().toLowerCase();return i==="failed"?m.red:i==="blocked"||x>0?m.red:i==="running"||i==="active"||i==="in_progress"?m.lime:i==="queued"||i==="pending"?m.amber:i==="completed"?m.teal:m.textMuted}function J(n){switch(n){case"active":return{title:"Active Sessions",subtitle:"Running and queued work across agents."};case"blocked":return{title:"Blocked Sessions",subtitle:"Work that needs attention before it can proceed."};case"failed":return{title:"Failed Sessions",subtitle:"Runs that exited with an error and may need a retry."};default:return{title:"Sessions",subtitle:"All sessions visible to this dashboard."}}}function K(n,x){var j;const i=(x.status??"").toLowerCase(),y=((j=x.blockers)==null?void 0:j.length)??0;return n==="active"?["running","active","queued","pending","in_progress"].includes(i):n==="blocked"?i==="blocked"||y>0:n==="failed"?i==="failed":!0}function le({open:n,onClose:x,mode:i,sessions:y,onOpenSession:j,onRunAction:A,onRefetch:L,onSetNotice:v}){const{title:P,subtitle:_}=J(i),[S,R]=p.useState(""),[w,B]=p.useState(new Set),[d,k]=p.useState(null),[M,h]=p.useState(null),[N,C]=p.useState(null);p.useEffect(()=>{n&&(h(null),C(null))},[n]);const f=p.useMemo(()=>y.filter(t=>K(i,t)),[i,y]),g=p.useMemo(()=>{const t={};for(const o of f){const a=(o.status??"unknown").toLowerCase();t[a]=(t[a]??0)+1}const r=f.filter(o=>{var a;return(o.status??"").toLowerCase()==="blocked"||(((a=o.blockers)==null?void 0:a.length)??0)>0}).length,s=f.filter(o=>(o.status??"").toLowerCase()==="failed").length,l=f.filter(o=>["running","active","queued","pending","in_progress"].includes((o.status??"").toLowerCase())).length;return{total:f.length,active:l,blocked:r,failed:s,byStatus:t}},[f]),u=p.useMemo(()=>{const t=S.trim().toLowerCase(),r=[...f].sort(G);return t?r.filter(s=>[s.title,s.agentName,s.agentId,s.runId,s.lastEventSummary].filter(Boolean).join(" ").toLowerCase().includes(t)):r},[S,f]);p.useEffect(()=>{n&&B(t=>{const r=new Set(u.map(l=>l.id)),s=new Set;for(const l of t)r.has(l)&&s.add(l);return s})},[u,n]);const b=w.size,T=u.length>0&&u.every(t=>w.has(t.id)),U=()=>{d||B(t=>u.length===0?t:T?new Set:new Set(u.map(r=>r.id)))},z=t=>{d||B(r=>{const s=new Set(r);return s.has(t)?s.delete(t):s.add(t),s})},F=async()=>{if(b===0||d)return;const t=[];for(const s of u){if(!w.has(s.id))continue;const l=s.blockers??[];if(l.length!==0){t.push(`- ${s.title} (${l.length} blocker${l.length===1?"":"s"})`);for(const o of l)t.push(` - ${o}`)}}const r=t.length>0?t.join(`
1
+ import{r as p,j as e}from"./Dj2k1r16.js";import{z as D,E as W,f as m,w as Q}from"./C0i7ABUU.js";import"./DMKyYAtD.js";import"./eeHXe_OQ.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";const q={blocked:0,failed:1,running:2,active:2,queued:3,in_progress:3,pending:4,paused:5,cancelled:6,completed:7,archived:8};function Y(n){if(!n)return 0;const x=Date.parse(n);return Number.isFinite(x)?x:0}function I(n){return Y(n.updatedAt??n.lastEventAt??n.startedAt)}function G(n,x){const i=q[(n.status??"").toLowerCase()]??99,y=q[(x.status??"").toLowerCase()]??99;return i!==y?i-y:I(x)-I(n)}function H(n,x){const i=n.trim().toLowerCase();return i==="failed"?m.red:i==="blocked"||x>0?m.red:i==="running"||i==="active"||i==="in_progress"?m.lime:i==="queued"||i==="pending"?m.amber:i==="completed"?m.teal:m.textMuted}function J(n){switch(n){case"active":return{title:"Active Sessions",subtitle:"Running and queued work across agents."};case"blocked":return{title:"Blocked Sessions",subtitle:"Work that needs attention before it can proceed."};case"failed":return{title:"Failed Sessions",subtitle:"Runs that exited with an error and may need a retry."};default:return{title:"Sessions",subtitle:"All sessions visible to this dashboard."}}}function K(n,x){var j;const i=(x.status??"").toLowerCase(),y=((j=x.blockers)==null?void 0:j.length)??0;return n==="active"?["running","active","queued","pending","in_progress"].includes(i):n==="blocked"?i==="blocked"||y>0:n==="failed"?i==="failed":!0}function le({open:n,onClose:x,mode:i,sessions:y,onOpenSession:j,onRunAction:A,onRefetch:L,onSetNotice:v}){const{title:P,subtitle:_}=J(i),[S,R]=p.useState(""),[w,B]=p.useState(new Set),[d,k]=p.useState(null),[M,h]=p.useState(null),[N,C]=p.useState(null);p.useEffect(()=>{n&&(h(null),C(null))},[n]);const f=p.useMemo(()=>y.filter(t=>K(i,t)),[i,y]),g=p.useMemo(()=>{const t={};for(const o of f){const a=(o.status??"unknown").toLowerCase();t[a]=(t[a]??0)+1}const r=f.filter(o=>{var a;return(o.status??"").toLowerCase()==="blocked"||(((a=o.blockers)==null?void 0:a.length)??0)>0}).length,s=f.filter(o=>(o.status??"").toLowerCase()==="failed").length,l=f.filter(o=>["running","active","queued","pending","in_progress"].includes((o.status??"").toLowerCase())).length;return{total:f.length,active:l,blocked:r,failed:s,byStatus:t}},[f]),u=p.useMemo(()=>{const t=S.trim().toLowerCase(),r=[...f].sort(G);return t?r.filter(s=>[s.title,s.agentName,s.agentId,s.runId,s.lastEventSummary].filter(Boolean).join(" ").toLowerCase().includes(t)):r},[S,f]);p.useEffect(()=>{n&&B(t=>{const r=new Set(u.map(l=>l.id)),s=new Set;for(const l of t)r.has(l)&&s.add(l);return s})},[u,n]);const b=w.size,T=u.length>0&&u.every(t=>w.has(t.id)),U=()=>{d||B(t=>u.length===0?t:T?new Set:new Set(u.map(r=>r.id)))},z=t=>{d||B(r=>{const s=new Set(r);return s.has(t)?s.delete(t):s.add(t),s})},F=async()=>{if(b===0||d)return;const t=[];for(const s of u){if(!w.has(s.id))continue;const l=s.blockers??[];if(l.length!==0){t.push(`- ${s.title} (${l.length} blocker${l.length===1?"":"s"})`);for(const o of l)t.push(` - ${o}`)}}const r=t.length>0?t.join(`
2
2
  `):"No blockers found for selected sessions.";try{await navigator.clipboard.writeText(r),h("Copied blockers to clipboard.")}catch{h("Copy failed (clipboard unavailable).")}},$=async t=>{if(b===0||d)return;if(t==="cancel"){C({text:""});return}const r=u.filter(a=>w.has(a.id));h(null),k({action:t,processed:0,total:r.length});let s=0;const l=[];for(const a of r)try{await A(a,t)}catch(c){s+=1;const E=c instanceof Error?c.message:"unknown error";l.push(`${a.title||a.runId}: ${E}`)}finally{k(c=>c&&{...c,processed:Math.min(c.total,c.processed+1)})}const o=r.length-s;if(k(null),s>0){const a=l.length>0?` — ${l[0]}${l.length>1?` (+${l.length-1} more)`:""}`:"";h(`${t} finished: ${o} ok, ${s} failed.${a}`)}else h(`${t} finished: ${o} session${o===1?"":"s"}.`);try{await L()}catch{}t==="resume"?v(`Bulk resume requested: ${o} ok${s?`, ${s} failed`:""}.`):t==="pause"?v(`Bulk pause requested: ${o} ok${s?`, ${s} failed`:""}.`):t==="complete"&&v(`Bulk mark completed requested: ${o} ok${s?`, ${s} failed`:""}.`)},O=async()=>{if(!N||d||N.text.trim().toUpperCase()!=="CANCEL")return;const t=u.filter(a=>w.has(a.id));h(null),k({action:"cancel",processed:0,total:t.length}),C(null);let r=0;const s=[];for(const a of t)try{await A(a,"cancel")}catch(c){r+=1;const E=c instanceof Error?c.message:"unknown error";s.push(`${a.title||a.runId}: ${E}`)}finally{k(c=>c&&{...c,processed:Math.min(c.total,c.processed+1)})}const l=t.length-r;k(null);const o=s.length>0?` — ${s[0]}${s.length>1?` (+${s.length-1} more)`:""}`:"";h(`cancel finished: ${l} ok${r?`, ${r} failed`:""}.${o}`),v(`Bulk cancel requested: ${l} ok${r?`, ${r} failed`:""}.`);try{await L()}catch{}};return e.jsx(D,{open:n,onClose:x,maxWidth:"max-w-4xl",children:e.jsxs("div",{className:"flex h-full w-full flex-col",children:[e.jsxs("div",{className:"border-b border-subtle px-5 pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"inline-flex items-center gap-2 text-heading font-semibold text-white",children:[e.jsx(W,{type:"session",size:14}),e.jsx("span",{className:"truncate",children:P}),e.jsx("span",{className:"rounded-full border border-strong bg-white/[0.04] px-2 py-0.5 text-caption font-semibold text-primary",children:g.total})]}),e.jsx("p",{className:"mt-1 text-body leading-relaxed text-secondary",children:_}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-white/[0.1] bg-white/[0.03] px-2 py-0.5 text-micro text-secondary",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:m.teal}}),"Total ",e.jsx("span",{className:"font-semibold text-white",children:g.total})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-white/[0.1] bg-white/[0.03] px-2 py-0.5 text-micro text-secondary",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:g.active>0?m.lime:m.textMuted}}),"Active ",e.jsx("span",{className:"font-semibold text-white",children:g.active})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-white/[0.1] bg-white/[0.03] px-2 py-0.5 text-micro text-secondary",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:g.blocked>0?m.red:m.textMuted}}),"Blocked ",e.jsx("span",{className:"font-semibold text-white",children:g.blocked})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-white/[0.1] bg-white/[0.03] px-2 py-0.5 text-micro text-secondary",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:g.failed>0?m.red:m.textMuted}}),"Failed ",e.jsx("span",{className:"font-semibold text-white",children:g.failed})]})]})]}),e.jsx("button",{type:"button",onClick:x,className:"rounded-md border border-strong bg-white/[0.03] px-2.5 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08]","aria-label":"Close bulk modal",children:"Close"})]}),e.jsxs("div",{className:"mt-4 flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"sr-only",htmlFor:"bulk-sessions-search",children:"Search sessions"}),e.jsx("input",{id:"bulk-sessions-search",value:S,onChange:t=>R(t.target.value),placeholder:"Search title, agent, run id…","data-modal-autofocus":"true",className:"w-full rounded-lg border border-strong bg-black/25 px-3 py-2 text-body text-white placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-lime/35"})]}),e.jsx("button",{type:"button",onClick:U,disabled:u.length===0||!!d,className:"rounded-lg border border-strong bg-white/[0.03] px-3 py-2 text-caption text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:T?"Clear all":`Select all (${u.length})`})]}),M&&e.jsx("div",{className:"mt-3 rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2 text-body text-secondary",children:M}),N&&e.jsxs("div",{className:"mt-3 rounded-xl border border-red-400/25 bg-red-500/[0.06] px-3 py-2.5",children:[e.jsxs("p",{className:"text-body font-semibold text-red-200",children:["Cancel ",b," session",b===1?"":"s","?"]}),e.jsxs("p",{className:"mt-1 text-caption text-red-200/70",children:["This is destructive. Type ",e.jsx("span",{className:"font-semibold",children:"CANCEL"})," to confirm."]}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsx("input",{value:N.text,onChange:t=>C({text:t.target.value}),placeholder:"CANCEL",className:"flex-1 rounded-lg border border-red-300/25 bg-black/30 px-3 py-2 text-body text-white placeholder:text-muted focus:outline-none focus:ring-1 focus:ring-red-300/40"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>C(null),className:"rounded-lg border border-strong bg-white/[0.03] px-3 py-2 text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Back"}),e.jsx("button",{type:"button",onClick:O,disabled:N.text.trim().toUpperCase()!=="CANCEL",className:"rounded-lg border border-red-300/25 bg-red-500/15 px-3 py-2 text-caption font-semibold text-red-200 transition-colors hover:bg-red-500/20 disabled:opacity-45",children:"Confirm cancel"})]})]})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:u.length===0?e.jsx("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-4 text-body text-secondary",children:"No sessions match this view."}):e.jsx("div",{className:"space-y-2",children:u.map(t=>{const r=w.has(t.id),s=t.blockers??[],l=H(t.status??"",s.length),o=t.updatedAt??t.lastEventAt??t.startedAt,a=[(t.agentName??t.agentId??"").trim()||"Unknown agent",(t.status??"unknown").toLowerCase(),o?Q(o):null].filter(Boolean);return e.jsx("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2.5 transition-colors hover:bg-white/[0.04]",style:{borderColor:r?`${m.lime}40`:"rgba(255,255,255,0.08)"},children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("input",{type:"checkbox",checked:r,onChange:()=>z(t.id),disabled:!!d,className:"mt-0.5 h-4 w-4 rounded border-white/20 bg-black/40 text-lime focus:ring-lime/40","aria-label":`Select session ${t.title}`}),e.jsx("button",{type:"button",onClick:()=>j(t),disabled:!!d,className:"min-w-0 flex-1 text-left",title:"Open session inspector",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-body font-medium text-white",children:t.title}),e.jsx("p",{className:"mt-0.5 text-caption text-secondary",children:a.join(" · ")}),t.lastEventSummary&&e.jsx("p",{className:"mt-1 line-clamp-2 text-caption text-secondary",children:t.lastEventSummary}),s.length>0&&e.jsxs("p",{className:"mt-1 text-micro text-red-200/80",children:[s.length," blocker",s.length===1?"":"s"," · ",s[0]]})]}),e.jsx("span",{className:"shrink-0 rounded-full border px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em]",style:{borderColor:`${l}30`,backgroundColor:`${l}14`,color:l},children:(t.status??"unknown").toUpperCase()})]})})]})},t.id)})})}),e.jsxs("div",{className:"flex flex-col gap-2 border-t border-subtle px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-caption text-secondary",children:[d?e.jsxs("span",{children:[d.action," ",d.processed,"/",d.total]}):e.jsx("span",{children:b>0?`${b} selected`:"No selection"}),i==="blocked"&&e.jsx("button",{type:"button",onClick:F,disabled:b===0||!!d,className:"rounded-md border border-strong bg-white/[0.03] px-2.5 py-1.5 text-caption text-secondary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:"Copy blockers"})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{const t=u.find(r=>w.has(r.id))??null;t&&j(t)},disabled:b!==1||!!d,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:"Open inspector"}),e.jsx("button",{type:"button",onClick:()=>void $("resume"),disabled:b===0||!!d,className:"rounded-md border border-lime/25 bg-lime/10 px-3 py-1.5 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:"Resume selected"}),e.jsx("button",{type:"button",onClick:()=>void $("complete"),disabled:b===0||!!d,className:"rounded-md border border-teal/25 bg-teal/10 px-3 py-1.5 text-caption font-semibold text-teal transition-colors hover:bg-teal/20 disabled:opacity-45",children:"Mark completed"}),e.jsx("button",{type:"button",onClick:()=>void $("pause"),disabled:b===0||!!d,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:"Pause selected"}),e.jsx("button",{type:"button",onClick:()=>void $("cancel"),disabled:b===0||!!d,className:"rounded-md border border-red-300/25 bg-red-500/10 px-3 py-1.5 text-caption font-semibold text-red-200 transition-colors hover:bg-red-500/15 disabled:opacity-45",children:"Cancel selected"})]})]})]})})}export{le as BulkSessionsModal};
@@ -1 +1 @@
1
- import{r as j,j as e}from"./Dj2k1r16.js";import{F as B,G as N,O as ke,f as x,C as L,Q as Ve,R as Ge,S as Ne,w as O,l as Ie,A as Xe,D as Ke,T as Qe,M as He,n as Je,V as ce,X as Ye}from"./CSd4rSuU.js";import{u as Ze}from"./CGJiHCIx.js";import{A as De,m as I}from"./eeHXe_OQ.js";import"./DMKyYAtD.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";const et=/^[0-9a-f-]{20,}$/i,tt=new Set(["agent execution failed","execution failed","run failed","failed"]);function v(a){return typeof a=="string"&&a.trim().length>0}function rt(a){return(a??"").trim().replace(/\s+/g," ").toLowerCase()}function st(a){return tt.has(rt(a))}function V(a,t=3){return a.length<=t?a.join(", "):`${a.slice(0,t).join(", ")} +${a.length-t} more`}function G(a,t){const f=[],c=h=>{if(typeof h!="string")return;const w=h.trim();w&&(f.some(E=>E.toLowerCase()===w.toLowerCase())||f.push(w))};if(Array.isArray(a))for(const h of a)c(h);return c(t??null),f}function at(a){if(a.runId&&a.runId.trim().length>0)return a.runId.trim();const t=a.metadata;if(!t)return null;const f=["slice_run_id","sliceRunId","runId","run_id","correlation_id","correlationId","sessionId","session_id","agentRunId"];for(const c of f){const h=t[c];if(typeof h=="string"&&h.trim().length>0)return h.trim()}return null}function it(a){const t=ce(a.status??"");if(t==="blocked"||t==="failed"||t==="completed"||t==="cancelled")return t;const f=ce(a.phase??"");if(f==="blocked")return"blocked";if(f==="handoff")return"handoff";if(f==="completed")return"completed";if(f==="review")return"review";const c=ce(a.state??"");return c==="error"?"failed":c==="stopped"?"paused":c==="stale"?"queued":Ye(t)?t:a.blockers.length>0?"blocked":t||"unknown"}function nt(a,t,f){var h;const c=[((h=a.blockerDiagnostics)==null?void 0:h.reason)??null,a.blockerReason??null,...a.blockers,t==="blocked"||t==="failed"||t==="handoff"?f:null].map(w=>typeof w=="string"?w.trim():"").filter(w=>w.length>0);return c.length>0?c.find(E=>!st(E))??c[0]:t==="handoff"?"Waiting for handoff acceptance by the next agent.":t==="blocked"?"Blocked without an explicit reason from runtime.":t==="failed"?"Run failed without explicit error details.":null}function lt(a){return a==="completed"?"border-lime/25 bg-lime/[0.08] text-lime":a==="needs_attention"?"border-amber-400/30 bg-amber-400/10 text-amber-200":a==="failed"?"border-red-400/30 bg-red-500/10 text-red-200":a==="in_progress"?"border-teal-400/30 bg-teal-400/10 text-teal-200":"border-strong bg-white/[0.04] text-secondary"}const dt={hidden:{opacity:0,y:-4},visible:a=>({opacity:1,y:0,transition:{duration:.28,delay:a*.04,ease:[.16,1,.3,1]}}),exit:{opacity:0,transition:{duration:.18}}},R={hidden:{opacity:0,y:8},visible:a=>({opacity:1,y:0,transition:{duration:.22,delay:a*.04,ease:[.22,1,.36,1]}}),exit:{opacity:0,transition:{duration:.18}}};function ue(){return e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-white/[0.06] to-transparent"})}function ot(a){return a==="in_progress"?{background:`linear-gradient(90deg, ${x.lime}, ${x.teal})`}:a==="needs_attention"?{background:`linear-gradient(90deg, ${x.red}, ${x.amber})`}:a==="completed"?{background:`linear-gradient(90deg, ${x.teal}, ${x.cyan})`}:a==="failed"?{background:`linear-gradient(90deg, ${x.red}, ${x.red}80)`}:{background:`linear-gradient(90deg, ${x.iris}, ${x.iris}80)`}}const vt=j.memo(function({session:t,activity:f,initiatives:c=[],sliceRuns:h=[],onOpenActivityItem:w,onContinueHighestPriority:E,onDispatchSession:X,onPauseSession:K,onResumeSession:Q,onCancelSession:H,onCreateCheckpoint:J,onRollbackSession:Y,onStartInitiative:ct,onStartWorkstream:ut,initialInterventionDraft:C=null,onSubmitIntervention:te,onClose:me}){var ye,ve,je;const[u,xe]=j.useState(null),[W,T]=j.useState(null),[U,he]=j.useState(!1),[re,q]=j.useState(""),{enqueue:pe,ToastRenderer:Ce}=Ze();j.useEffect(()=>{if(!t){q("");return}if(C!=null&&C.text){q(C.text);return}q("")},[C==null?void 0:C.text,t==null?void 0:t.id]);const z=j.useMemo(()=>{var l,g,y,d,m;if(!t)return new Set;const r=new Set;return(l=t.runId)!=null&&l.trim()&&r.add(t.runId.trim()),(g=t.id)!=null&&g.trim()&&r.add(t.id.trim()),(m=(d=(y=t.blockerDiagnostics)==null?void 0:y.context)==null?void 0:d.sliceRunId)!=null&&m.trim()&&r.add(t.blockerDiagnostics.context.sliceRunId.trim()),r},[t]),$=j.useMemo(()=>t?z.size===0?[]:f.filter(r=>{const l=at(r);return!!(l&&z.has(l))}).sort((r,l)=>Date.parse(l.timestamp)-Date.parse(r.timestamp)).slice(0,12):[],[f,t,z]),s=j.useMemo(()=>{var y,d;if(!t||!Array.isArray(h)||h.length===0)return null;const r=((y=t.initiativeId)==null?void 0:y.trim())??"",l=((d=t.workstreamId)==null?void 0:d.trim())??"",g=h.filter(m=>{var oe,we;const A=((oe=m.sliceRunId)==null?void 0:oe.trim())??"",S=((we=m.runId)==null?void 0:we.trim())??"";if(A&&z.has(A)||S&&z.has(S))return!0;if(!l||!G(m.workstreamIds,m.workstreamId).includes(l))return!1;if(!r)return!0;const ee=G(m.initiativeIds,m.initiativeId);return!(ee.length>0&&!ee.includes(r))});return g.length===0?null:[...g].sort((m,A)=>{const S=Date.parse(m.updatedAt??m.lastEventAt??m.startedAt??""),de=Date.parse(A.updatedAt??A.lastEventAt??A.startedAt??""),ee=Number.isFinite(S)?S:0;return(Number.isFinite(de)?de:0)-ee})[0]},[t,z,h]),se=j.useMemo(()=>{var y;if(!t)return[];const r=[],l=t.initiativeId??t.groupId;if(l){const d=c.find(m=>m.id===l);d?r.push({label:"Initiative",value:d.name}):t.groupLabel&&t.groupLabel.trim().length>0?r.push({label:"Initiative",value:t.groupLabel}):B(l)&&r.push({label:"Initiative",value:N(l)})}if(t.workstreamId){let d=null;for(const m of c){const A=(y=m.workstreams)==null?void 0:y.find(S=>S.id===t.workstreamId);if(A){d=A.name;break}}!d&&B(t.workstreamId)?d=N(t.workstreamId):!d&&!et.test(t.workstreamId)&&(d=t.workstreamId),d&&r.push({label:"Workstream",value:d})}const g=t.phase??null;if(g){const d=String(g);r.push({label:"Milestone",value:B(d)?N(d):d})}return t.title&&r.push({label:"Task",value:t.title}),r},[c,t]),M=j.useMemo(()=>{var y,d;if(!t)return null;const r=((y=$[0])==null?void 0:y.summary)??((d=$[0])==null?void 0:d.description)??null,g=t.lastEventSummary??r??null;return g&&g.trim().length>0?g.trim():null},[$,t]),Ae=j.useMemo(()=>{var r;return t?ke(t.agentName,t.title,t.lastEventSummary,M,(r=$[0])==null?void 0:r.metadata):ke()},[$,t,M]),_=async(r,l,g)=>{if(!(!g||u)){xe(r),T(null);try{await g(),T(`${l} requested.`)}catch(y){T(y instanceof Error?y.message:`${l} failed.`)}finally{xe(null)}}};if(!t)return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0",style:{background:`linear-gradient(90deg, ${x.iris}, ${x.iris}80)`}}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsx("p",{className:"section-kicker",children:"Session Detail"}),e.jsx("button",{onClick:()=>he(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":U?"Expand session detail":"Collapse session detail",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:L("transition-transform",U?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})})]}),e.jsx("div",{className:L("transition-all",U?"max-h-0 overflow-hidden":"min-h-0 flex-1"),children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col items-center justify-center gap-4 px-5 py-8",children:[e.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-2xl border border-white/[0.08] bg-white/[0.03]",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-muted",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]})}),e.jsx("p",{className:"text-body text-secondary text-center",children:"No session selected"}),e.jsx("p",{className:"text-caption text-muted text-center max-w-[240px]",children:"Select a session to inspect summary, breadcrumbs, blockers, and recent messages."}),e.jsx("button",{onClick:()=>_("continue-priority","Continue highest priority",E),disabled:!E||!!u,className:"mt-2 h-8 rounded-lg border border-lime/25 bg-lime/10 px-4 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:u==="continue-priority"?"Dispatching...":"Continue highest priority"}),W&&e.jsx("p",{className:"text-caption text-secondary",children:W})]})})]});const P=t.progress===null?null:Math.round(t.progress),k=it(t),p=$[0]??null,ae=(s==null?void 0:s.blockingDecisionCount)??0,Re=Math.max(0,((s==null?void 0:s.decisionCount)??0)-ae),o=Ve({sessionStatus:t.status,sessionPhase:t.phase??null,sessionState:t.state??null,sliceStatus:(s==null?void 0:s.status)??null,activityType:(p==null?void 0:p.type)??null,activityStatus:(typeof(p==null?void 0:p.state)=="string"&&p.state.trim().length>0?p.state:null)??(typeof(p==null?void 0:p.phase)=="string"&&p.phase.trim().length>0?p.phase:null)??(s==null?void 0:s.runtimeState)??null,stopReason:t.blockerReason??((ye=t.blockerDiagnostics)==null?void 0:ye.reason)??((s==null?void 0:s.status)==="failed"?"error":null),decisionRequired:((p==null?void 0:p.decisionRequired)??!1)||ae>0,blockingDecisionCount:ae,nonBlockingDecisionCount:Re,blockerCount:t.blockers.length,blockerReason:t.blockerReason??((ve=t.blockerDiagnostics)==null?void 0:ve.reason)??null}),ie=nt(t,k,M),Te=k==="handoff"?"Handoff":k==="blocked"?"Blocker reason":k==="failed"?"Failure reason":"Status note",$e=o.status==="in_progress"&&["running","active","queued","pending","working","in_progress","planning","review"].includes(k),Me=o.status==="needs_attention"&&["paused","blocked","queued","pending"].includes(k),Be=!["completed","archived","cancelled"].includes(k),Le=!["archived","cancelled"].includes(k),We=o.label,_e=lt(o.status),ne=["running","active","working","in_progress","planning","review"].includes(k),Se=o.status!=="in_progress"&&!ne,Ee=o.tone==="critical"?x.red:o.tone==="warning"?x.amber:o.tone==="positive"?x.lime:x.teal,Ue=P!==null&&P>=100&&o.status!=="completed"?"Terminal state":"Progress",ze=o.tone==="critical"?"border-red-400/25 bg-red-500/10":o.tone==="warning"?"border-amber-400/25 bg-amber-500/10":o.tone==="positive"?"border-lime/22 bg-lime/[0.08]":"border-subtle bg-white/[0.02]",i=t.blockerDiagnostics??null,n=(i==null?void 0:i.context)??null,le=[v(i==null?void 0:i.source)?`Source: ${i.source.trim()}`:null,v(i==null?void 0:i.errorCode)?`Code: ${i.errorCode.trim()}`:null,v(i==null?void 0:i.errorCategory)?`Category: ${i.errorCategory.trim()}`:null,(i==null?void 0:i.retryable)===!0?"Retryable: yes":(i==null?void 0:i.retryable)===!1?"Retryable: no":null].filter(r=>!!r),b=[];n&&(Array.isArray(n.initiativeIds)&&n.initiativeIds.length>0?b.push({label:"Initiatives",value:V(n.initiativeIds.map(r=>B(r)?N(r):r),4)}):v(n.initiativeId)&&b.push({label:"Initiative",value:Ge("Initiative",n.initiativeId.trim())}),v(n.workstreamTitle)?b.push({label:"Workstream",value:n.workstreamTitle.trim()}):Array.isArray(n.workstreamIds)&&n.workstreamIds.length>0?b.push({label:"Workstreams",value:V(n.workstreamIds,4)}):v(n.workstreamId)&&b.push({label:"Workstream",value:n.workstreamId.trim()}),v(n.sliceRunId)&&b.push({label:"Slice run",value:N(n.sliceRunId.trim())}),v(n.parallelMode)&&b.push({label:"Mode",value:n.parallelMode.trim().toUpperCase()}),Array.isArray(n.taskIds)&&n.taskIds.length>0&&b.push({label:"Tasks",value:V(n.taskIds.map(r=>B(r)?N(r):r))}),Array.isArray(n.milestoneIds)&&n.milestoneIds.length>0&&b.push({label:"Milestones",value:V(n.milestoneIds.map(r=>B(r)?N(r):r))}),Array.isArray(n.iwmtIds)&&n.iwmtIds.length>0?b.push({label:"Scope IDs",value:V(n.iwmtIds.map(r=>B(r)?N(r):r),4)}):v(n.iwmtId)&&b.push({label:"Scope ID",value:B(n.iwmtId.trim())?N(n.iwmtId.trim()):n.iwmtId.trim()}),v(n.logPath)&&b.push({label:"Log path",value:Ne(n.logPath.trim())}),v(n.outputPath)&&b.push({label:"Output path",value:Ne(n.outputPath.trim())}));const be=(k==="blocked"||k==="failed")&&!!(i&&(v(i.reason)||le.length>0||b.length>0||Array.isArray(i.suggestedActions)&&i.suggestedActions.length>0)),Z=v(ie)?ie:null,qe=Z!==null&&!(M&&(Z===M||M.includes(Z)))&&!be,Pe=j.useCallback(()=>{!H||!t||(T("Session will be cancelled..."),pe({message:`Cancelled "${t.title}"`,onCommit:async()=>{try{await H(t),T("Session cancelled.")}catch(r){T(r instanceof Error?r.message:"Cancel failed.")}},onUndo:()=>{T(null)}}))},[H,t,pe]),Fe=[{label:"Started",value:t.startedAt?O(t.startedAt):"—"},{label:"Updated",value:t.updatedAt?O(t.updatedAt):"—"},...t.eta?[{label:"ETA",value:t.eta}]:[],...t.checkpointCount?[{label:"Checkpoints",value:String(t.checkpointCount)}]:[]],fe=s?s.status.replace(/_/g," "):null,F=G(s==null?void 0:s.initiativeIds,(s==null?void 0:s.initiativeId)??null),D=G(s==null?void 0:s.workstreamIds,(s==null?void 0:s.workstreamId)??null);G(s==null?void 0:s.iwmtIds,(s==null?void 0:s.iwmtId)??null);const Oe=F[0]?((je=c.find(r=>r.id===F[0]))==null?void 0:je.name)??F[0]:null,ge=W?W.toLowerCase().includes("fail")||W.toLowerCase().includes("error")?"error":u?"pending":"success":null;return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0",style:ot(o.status)}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("p",{className:"section-kicker",children:"Session Detail"}),e.jsxs("span",{className:L("inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em]",_e),children:[ne&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full pulse-soft",style:{backgroundColor:Ie(k)}}),We]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>he(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":U?"Expand session detail":"Collapse session detail",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:L("transition-transform",U?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}),me&&e.jsx("button",{type:"button",onClick:me,"aria-label":"Close session inspector",className:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-strong bg-white/[0.03] text-primary transition-colors hover:bg-white/[0.08] hover:text-white",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})})]})]}),e.jsxs("div",{className:L("transition-all flex flex-col min-h-0",U?"max-h-0 overflow-hidden":"flex-1"),children:[e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-5 space-y-5",children:[e.jsx(De,{mode:"wait",children:e.jsxs(I.div,{variants:dt,initial:"hidden",animate:"visible",exit:"exit",custom:0,children:[e.jsxs("div",{className:"flex items-start gap-3.5",children:[e.jsx(Xe,{name:t.agentName??"OrgX",size:"md",hint:t.agentName}),e.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[e.jsx("h2",{className:"text-display font-medium leading-tight text-white truncate",children:Ke(t.title)}),e.jsxs("p",{className:"mt-1 text-micro uppercase tracking-[0.12em] text-muted",children:[t.agentName??"OrgX"," · ",Ae.label]})]})]}),se.length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:se.map((r,l)=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Qe,{tone:"muted",children:r.value}),l<se.length-1&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"flex-shrink-0 text-faint",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})]},`${r.label}-${r.value}`))})]},t.id)}),e.jsx(ue,{}),M&&e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:1,children:[e.jsx("p",{className:"section-kicker mb-2",children:"Summary"}),e.jsx(He,{text:M,mode:"block"})]}),e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:2,children:e.jsxs("div",{className:L("rounded-xl border px-4 py-3",ze),children:[e.jsx("p",{className:"section-kicker mb-1.5",children:o.label}),e.jsx("p",{className:"text-body text-secondary",children:o.sentence}),o.nextAction&&e.jsxs("p",{className:"mt-1.5 flex items-center gap-1 text-caption text-secondary",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:x.lime,strokeWidth:"2.5",className:"flex-shrink-0",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),"Next: ",o.nextAction]})]})}),qe&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:3,children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-1.5",children:Te}),e.jsx("p",{className:"text-body text-secondary",children:Z})]})}),be&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:3,children:e.jsxs("div",{className:"rounded-xl border border-red-500/25 bg-red-500/10 px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-1.5 text-red-200/75",children:"Why blocked"}),e.jsx("p",{className:"text-body text-red-100/90",children:(i==null?void 0:i.reason)??ie??"Runtime marked this run as blocked without details."}),le.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:le.map(r=>e.jsx("span",{className:"rounded-full border border-red-300/25 bg-red-500/10 px-2 py-0.5 text-micro text-red-100/85",children:r},r))}),b.length>0&&e.jsxs("div",{className:"mt-2 rounded-md border border-red-300/20 bg-black/15 p-2.5",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.14em] text-red-200/65",children:"Associated context"}),e.jsx("dl",{className:"grid grid-cols-1 gap-1.5 text-caption text-red-100/85",children:b.map(r=>e.jsxs("div",{className:"grid grid-cols-[86px_1fr] gap-2",children:[e.jsx("dt",{className:"text-red-200/70",children:r.label}),e.jsx("dd",{className:"break-all text-red-50/95",children:r.value})]},r.label))})]}),Array.isArray(i==null?void 0:i.suggestedActions)&&i.suggestedActions.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.14em] text-red-200/65",children:"Suggested actions"}),e.jsx("ul",{className:"space-y-1 text-caption text-red-100/85",children:i.suggestedActions.map(r=>e.jsxs("li",{children:["• ",r]},r))})]}),v(i==null?void 0:i.eventTimestamp)&&e.jsxs("p",{className:"mt-2 text-micro text-red-200/60",children:["Last blocker event: ",new Date(i.eventTimestamp).toLocaleString()," ·"," ",O(i.eventTimestamp)]})]})}),e.jsx(ue,{}),e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:4,children:[P!==null&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between text-caption text-secondary",children:[e.jsx("span",{children:Ue}),e.jsxs("span",{className:"text-primary",children:[P,"%"]})]}),e.jsx("div",{className:"h-[3px] rounded-full bg-white/[0.08]",children:e.jsx(I.div,{className:L("h-[3px] rounded-full",ne&&"live-pulse"),style:{background:Ee},initial:{width:0},animate:{width:`${P}%`},transition:{duration:.5,ease:Je.easingStandard}})})]}),e.jsx("dl",{className:"grid grid-cols-2 gap-3 text-caption text-secondary",children:Fe.map(r=>e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:r.label}),e.jsx("dd",{className:"text-body font-semibold text-white",children:r.value})]},r.label))})]}),s&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:5,children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"section-kicker",children:"Slice scope"}),fe?e.jsx("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em] text-secondary",children:fe}):null]}),s.statusExplainer?e.jsx("p",{className:"mt-2 text-caption text-secondary",children:s.statusExplainer}):null,e.jsxs("dl",{className:"mt-2 grid grid-cols-2 gap-2 text-caption text-secondary",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Initiative"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:Oe??"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Workstream"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:s.workstreamTitle??(D[0]?N(D[0]):"—")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Run"}),e.jsx("dd",{className:"break-all text-body font-semibold text-white",children:N(s.runId??s.sliceRunId)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Updated"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:s.updatedAt?O(s.updatedAt):"—"})]})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5 text-micro",children:[e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Tasks ",s.taskIds.length]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Milestones ",s.milestoneIds.length]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Artifacts ",s.artifactCount]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Needs input ",s.blockingDecisionCount]}),F.length>1?e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["+",F.length-1," initiatives"]}):null,D.length>1?e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["+",D.length-1," workstreams"]}):null]}),s.taskIds.length>0?e.jsxs("p",{className:"mt-2 text-micro text-secondary",children:["Tasks: ",s.taskIds.length]}):null]})}),t.blockers.length>0&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:6,children:e.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-2 text-red-200/70",children:"Blockers"}),e.jsx("ul",{className:"space-y-1 text-body text-red-100/90",children:t.blockers.map(r=>e.jsxs("li",{children:["• ",r]},r))})]})}),e.jsx(ue,{}),e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:7,children:[e.jsx("p",{className:"section-kicker mb-4",children:"Recent Messages"}),$.length===0&&e.jsx("p",{className:"text-body text-secondary",children:"No recent messages for this run."}),e.jsx("div",{className:"relative border-l border-white/[0.06] pl-6 ml-1 space-y-3",children:$.map((r,l)=>e.jsxs(I.div,{className:"relative group",variants:R,initial:"hidden",animate:"visible",custom:l,children:[e.jsx("div",{className:"absolute -left-[27px] top-1.5 h-2 w-2 rounded-full border border-black ring-4 ring-black",style:{backgroundColor:Ie(r.type??r.state??"unknown")}}),e.jsxs("article",{className:"rounded-lg border border-subtle bg-white/[0.02] px-3 py-2.5 transition-colors hover:bg-white/[0.04]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 text-caption text-bright",children:r.title}),w&&e.jsx("button",{type:"button",onClick:()=>w(r),className:"flex-shrink-0 rounded-full border border-strong bg-white/[0.03] px-2.5 py-0.5 text-micro font-semibold text-secondary opacity-0 transition-all group-hover:opacity-100 hover:bg-white/[0.08] hover:text-primary",children:"Open"})]}),(r.summary||r.description)&&e.jsx("p",{className:"mt-0.5 line-clamp-2 text-caption text-secondary",children:r.summary??r.description}),e.jsxs("p",{className:"mt-1 text-micro text-muted",children:[new Date(r.timestamp).toLocaleString()," · ",O(r.timestamp)]})]})]},r.id))})]})]}),e.jsxs("div",{className:"flex-shrink-0 border-t border-subtle px-5 py-3 space-y-3",children:[W&&e.jsx("p",{className:L("rounded-md border px-2.5 py-1.5 text-caption",ge==="error"?"border-red-400/30 bg-red-500/10 text-red-200":ge==="pending"?"border-white/[0.08] bg-white/[0.02] text-secondary pulse-soft":"border-lime/25 bg-lime/[0.08] text-lime"),children:W}),te&&e.jsx("div",{children:e.jsx("textarea",{value:re,onChange:r=>q(r.target.value),placeholder:"Share guidance for this run...",rows:2,className:"w-full resize-none rounded-lg border border-white/[0.10] bg-white/[0.03] px-3 py-2 text-body text-bright outline-none placeholder:text-faint focus:border-white/20"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[$e&&e.jsx("button",{onClick:()=>_("pause-session","Session paused",()=>K==null?void 0:K(t)),disabled:!K||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="pause-session"?"Pausing...":"Pause"}),Me&&e.jsx("button",{onClick:()=>_("resume-session","Session resumed",()=>Q==null?void 0:Q(t)),disabled:!Q||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="resume-session"?"Resuming...":"Resume"}),e.jsx("button",{onClick:()=>_("checkpoint-session","Progress saved",()=>J==null?void 0:J(t)),disabled:!J||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="checkpoint-session"?"Saving...":"Save"}),Le&&e.jsx("button",{onClick:()=>_("rollback-session","Undo requested",()=>Y==null?void 0:Y(t)),disabled:!Y||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="rollback-session"?"Undoing...":"Undo"}),Be&&H&&e.jsx("button",{onClick:Pe,disabled:!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-red-400/70 hover:bg-red-500/[0.08] hover:text-red-300 disabled:opacity-45 transition-colors",children:"Cancel"})]}),e.jsx("div",{className:"flex-1"}),te&&e.jsx("button",{type:"button",onClick:()=>{const r=re.trim();if(!r){T("Intervention note cannot be empty.");return}_("intervene-note","Intervention sent",async()=>{await te({session:t,workstreamId:(C==null?void 0:C.workstreamId)??t.workstreamId??null,text:r}),q("")})},disabled:!!u||re.trim().length===0,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption font-semibold text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:u==="intervene-note"?"Sending...":"Intervene"}),e.jsxs("button",{onClick:()=>_("dispatch-session","Session started",()=>X==null?void 0:X(t)),disabled:!X||!!u||!Se,className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-lime/25 bg-lime/10 px-4 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",className:"flex-shrink-0",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),u==="dispatch-session"?"Starting...":o.status==="completed"?"Restart":"Start"]})]})]})]}),e.jsx(Ce,{})]})});export{vt as SessionInspector};
1
+ import{r as j,j as e}from"./Dj2k1r16.js";import{F as B,G as N,O as ke,f as x,C as L,Q as Ve,R as Ge,S as Ne,w as O,l as Ie,A as Xe,D as Ke,T as Qe,M as He,n as Je,V as ce,X as Ye}from"./C0i7ABUU.js";import{u as Ze}from"./DClUc9rw.js";import{A as De,m as I}from"./eeHXe_OQ.js";import"./DMKyYAtD.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";const et=/^[0-9a-f-]{20,}$/i,tt=new Set(["agent execution failed","execution failed","run failed","failed"]);function v(a){return typeof a=="string"&&a.trim().length>0}function rt(a){return(a??"").trim().replace(/\s+/g," ").toLowerCase()}function st(a){return tt.has(rt(a))}function V(a,t=3){return a.length<=t?a.join(", "):`${a.slice(0,t).join(", ")} +${a.length-t} more`}function G(a,t){const f=[],c=h=>{if(typeof h!="string")return;const w=h.trim();w&&(f.some(E=>E.toLowerCase()===w.toLowerCase())||f.push(w))};if(Array.isArray(a))for(const h of a)c(h);return c(t??null),f}function at(a){if(a.runId&&a.runId.trim().length>0)return a.runId.trim();const t=a.metadata;if(!t)return null;const f=["slice_run_id","sliceRunId","runId","run_id","correlation_id","correlationId","sessionId","session_id","agentRunId"];for(const c of f){const h=t[c];if(typeof h=="string"&&h.trim().length>0)return h.trim()}return null}function it(a){const t=ce(a.status??"");if(t==="blocked"||t==="failed"||t==="completed"||t==="cancelled")return t;const f=ce(a.phase??"");if(f==="blocked")return"blocked";if(f==="handoff")return"handoff";if(f==="completed")return"completed";if(f==="review")return"review";const c=ce(a.state??"");return c==="error"?"failed":c==="stopped"?"paused":c==="stale"?"queued":Ye(t)?t:a.blockers.length>0?"blocked":t||"unknown"}function nt(a,t,f){var h;const c=[((h=a.blockerDiagnostics)==null?void 0:h.reason)??null,a.blockerReason??null,...a.blockers,t==="blocked"||t==="failed"||t==="handoff"?f:null].map(w=>typeof w=="string"?w.trim():"").filter(w=>w.length>0);return c.length>0?c.find(E=>!st(E))??c[0]:t==="handoff"?"Waiting for handoff acceptance by the next agent.":t==="blocked"?"Blocked without an explicit reason from runtime.":t==="failed"?"Run failed without explicit error details.":null}function lt(a){return a==="completed"?"border-lime/25 bg-lime/[0.08] text-lime":a==="needs_attention"?"border-amber-400/30 bg-amber-400/10 text-amber-200":a==="failed"?"border-red-400/30 bg-red-500/10 text-red-200":a==="in_progress"?"border-teal-400/30 bg-teal-400/10 text-teal-200":"border-strong bg-white/[0.04] text-secondary"}const dt={hidden:{opacity:0,y:-4},visible:a=>({opacity:1,y:0,transition:{duration:.28,delay:a*.04,ease:[.16,1,.3,1]}}),exit:{opacity:0,transition:{duration:.18}}},R={hidden:{opacity:0,y:8},visible:a=>({opacity:1,y:0,transition:{duration:.22,delay:a*.04,ease:[.22,1,.36,1]}}),exit:{opacity:0,transition:{duration:.18}}};function ue(){return e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-white/[0.06] to-transparent"})}function ot(a){return a==="in_progress"?{background:`linear-gradient(90deg, ${x.lime}, ${x.teal})`}:a==="needs_attention"?{background:`linear-gradient(90deg, ${x.red}, ${x.amber})`}:a==="completed"?{background:`linear-gradient(90deg, ${x.teal}, ${x.cyan})`}:a==="failed"?{background:`linear-gradient(90deg, ${x.red}, ${x.red}80)`}:{background:`linear-gradient(90deg, ${x.iris}, ${x.iris}80)`}}const vt=j.memo(function({session:t,activity:f,initiatives:c=[],sliceRuns:h=[],onOpenActivityItem:w,onContinueHighestPriority:E,onDispatchSession:X,onPauseSession:K,onResumeSession:Q,onCancelSession:H,onCreateCheckpoint:J,onRollbackSession:Y,onStartInitiative:ct,onStartWorkstream:ut,initialInterventionDraft:C=null,onSubmitIntervention:te,onClose:me}){var ye,ve,je;const[u,xe]=j.useState(null),[W,T]=j.useState(null),[U,he]=j.useState(!1),[re,q]=j.useState(""),{enqueue:pe,ToastRenderer:Ce}=Ze();j.useEffect(()=>{if(!t){q("");return}if(C!=null&&C.text){q(C.text);return}q("")},[C==null?void 0:C.text,t==null?void 0:t.id]);const z=j.useMemo(()=>{var l,g,y,d,m;if(!t)return new Set;const r=new Set;return(l=t.runId)!=null&&l.trim()&&r.add(t.runId.trim()),(g=t.id)!=null&&g.trim()&&r.add(t.id.trim()),(m=(d=(y=t.blockerDiagnostics)==null?void 0:y.context)==null?void 0:d.sliceRunId)!=null&&m.trim()&&r.add(t.blockerDiagnostics.context.sliceRunId.trim()),r},[t]),$=j.useMemo(()=>t?z.size===0?[]:f.filter(r=>{const l=at(r);return!!(l&&z.has(l))}).sort((r,l)=>Date.parse(l.timestamp)-Date.parse(r.timestamp)).slice(0,12):[],[f,t,z]),s=j.useMemo(()=>{var y,d;if(!t||!Array.isArray(h)||h.length===0)return null;const r=((y=t.initiativeId)==null?void 0:y.trim())??"",l=((d=t.workstreamId)==null?void 0:d.trim())??"",g=h.filter(m=>{var oe,we;const A=((oe=m.sliceRunId)==null?void 0:oe.trim())??"",S=((we=m.runId)==null?void 0:we.trim())??"";if(A&&z.has(A)||S&&z.has(S))return!0;if(!l||!G(m.workstreamIds,m.workstreamId).includes(l))return!1;if(!r)return!0;const ee=G(m.initiativeIds,m.initiativeId);return!(ee.length>0&&!ee.includes(r))});return g.length===0?null:[...g].sort((m,A)=>{const S=Date.parse(m.updatedAt??m.lastEventAt??m.startedAt??""),de=Date.parse(A.updatedAt??A.lastEventAt??A.startedAt??""),ee=Number.isFinite(S)?S:0;return(Number.isFinite(de)?de:0)-ee})[0]},[t,z,h]),se=j.useMemo(()=>{var y;if(!t)return[];const r=[],l=t.initiativeId??t.groupId;if(l){const d=c.find(m=>m.id===l);d?r.push({label:"Initiative",value:d.name}):t.groupLabel&&t.groupLabel.trim().length>0?r.push({label:"Initiative",value:t.groupLabel}):B(l)&&r.push({label:"Initiative",value:N(l)})}if(t.workstreamId){let d=null;for(const m of c){const A=(y=m.workstreams)==null?void 0:y.find(S=>S.id===t.workstreamId);if(A){d=A.name;break}}!d&&B(t.workstreamId)?d=N(t.workstreamId):!d&&!et.test(t.workstreamId)&&(d=t.workstreamId),d&&r.push({label:"Workstream",value:d})}const g=t.phase??null;if(g){const d=String(g);r.push({label:"Milestone",value:B(d)?N(d):d})}return t.title&&r.push({label:"Task",value:t.title}),r},[c,t]),M=j.useMemo(()=>{var y,d;if(!t)return null;const r=((y=$[0])==null?void 0:y.summary)??((d=$[0])==null?void 0:d.description)??null,g=t.lastEventSummary??r??null;return g&&g.trim().length>0?g.trim():null},[$,t]),Ae=j.useMemo(()=>{var r;return t?ke(t.agentName,t.title,t.lastEventSummary,M,(r=$[0])==null?void 0:r.metadata):ke()},[$,t,M]),_=async(r,l,g)=>{if(!(!g||u)){xe(r),T(null);try{await g(),T(`${l} requested.`)}catch(y){T(y instanceof Error?y.message:`${l} failed.`)}finally{xe(null)}}};if(!t)return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0",style:{background:`linear-gradient(90deg, ${x.iris}, ${x.iris}80)`}}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsx("p",{className:"section-kicker",children:"Session Detail"}),e.jsx("button",{onClick:()=>he(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":U?"Expand session detail":"Collapse session detail",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:L("transition-transform",U?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})})]}),e.jsx("div",{className:L("transition-all",U?"max-h-0 overflow-hidden":"min-h-0 flex-1"),children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col items-center justify-center gap-4 px-5 py-8",children:[e.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-2xl border border-white/[0.08] bg-white/[0.03]",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-muted",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]})}),e.jsx("p",{className:"text-body text-secondary text-center",children:"No session selected"}),e.jsx("p",{className:"text-caption text-muted text-center max-w-[240px]",children:"Select a session to inspect summary, breadcrumbs, blockers, and recent messages."}),e.jsx("button",{onClick:()=>_("continue-priority","Continue highest priority",E),disabled:!E||!!u,className:"mt-2 h-8 rounded-lg border border-lime/25 bg-lime/10 px-4 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:u==="continue-priority"?"Dispatching...":"Continue highest priority"}),W&&e.jsx("p",{className:"text-caption text-secondary",children:W})]})})]});const P=t.progress===null?null:Math.round(t.progress),k=it(t),p=$[0]??null,ae=(s==null?void 0:s.blockingDecisionCount)??0,Re=Math.max(0,((s==null?void 0:s.decisionCount)??0)-ae),o=Ve({sessionStatus:t.status,sessionPhase:t.phase??null,sessionState:t.state??null,sliceStatus:(s==null?void 0:s.status)??null,activityType:(p==null?void 0:p.type)??null,activityStatus:(typeof(p==null?void 0:p.state)=="string"&&p.state.trim().length>0?p.state:null)??(typeof(p==null?void 0:p.phase)=="string"&&p.phase.trim().length>0?p.phase:null)??(s==null?void 0:s.runtimeState)??null,stopReason:t.blockerReason??((ye=t.blockerDiagnostics)==null?void 0:ye.reason)??((s==null?void 0:s.status)==="failed"?"error":null),decisionRequired:((p==null?void 0:p.decisionRequired)??!1)||ae>0,blockingDecisionCount:ae,nonBlockingDecisionCount:Re,blockerCount:t.blockers.length,blockerReason:t.blockerReason??((ve=t.blockerDiagnostics)==null?void 0:ve.reason)??null}),ie=nt(t,k,M),Te=k==="handoff"?"Handoff":k==="blocked"?"Blocker reason":k==="failed"?"Failure reason":"Status note",$e=o.status==="in_progress"&&["running","active","queued","pending","working","in_progress","planning","review"].includes(k),Me=o.status==="needs_attention"&&["paused","blocked","queued","pending"].includes(k),Be=!["completed","archived","cancelled"].includes(k),Le=!["archived","cancelled"].includes(k),We=o.label,_e=lt(o.status),ne=["running","active","working","in_progress","planning","review"].includes(k),Se=o.status!=="in_progress"&&!ne,Ee=o.tone==="critical"?x.red:o.tone==="warning"?x.amber:o.tone==="positive"?x.lime:x.teal,Ue=P!==null&&P>=100&&o.status!=="completed"?"Terminal state":"Progress",ze=o.tone==="critical"?"border-red-400/25 bg-red-500/10":o.tone==="warning"?"border-amber-400/25 bg-amber-500/10":o.tone==="positive"?"border-lime/22 bg-lime/[0.08]":"border-subtle bg-white/[0.02]",i=t.blockerDiagnostics??null,n=(i==null?void 0:i.context)??null,le=[v(i==null?void 0:i.source)?`Source: ${i.source.trim()}`:null,v(i==null?void 0:i.errorCode)?`Code: ${i.errorCode.trim()}`:null,v(i==null?void 0:i.errorCategory)?`Category: ${i.errorCategory.trim()}`:null,(i==null?void 0:i.retryable)===!0?"Retryable: yes":(i==null?void 0:i.retryable)===!1?"Retryable: no":null].filter(r=>!!r),b=[];n&&(Array.isArray(n.initiativeIds)&&n.initiativeIds.length>0?b.push({label:"Initiatives",value:V(n.initiativeIds.map(r=>B(r)?N(r):r),4)}):v(n.initiativeId)&&b.push({label:"Initiative",value:Ge("Initiative",n.initiativeId.trim())}),v(n.workstreamTitle)?b.push({label:"Workstream",value:n.workstreamTitle.trim()}):Array.isArray(n.workstreamIds)&&n.workstreamIds.length>0?b.push({label:"Workstreams",value:V(n.workstreamIds,4)}):v(n.workstreamId)&&b.push({label:"Workstream",value:n.workstreamId.trim()}),v(n.sliceRunId)&&b.push({label:"Slice run",value:N(n.sliceRunId.trim())}),v(n.parallelMode)&&b.push({label:"Mode",value:n.parallelMode.trim().toUpperCase()}),Array.isArray(n.taskIds)&&n.taskIds.length>0&&b.push({label:"Tasks",value:V(n.taskIds.map(r=>B(r)?N(r):r))}),Array.isArray(n.milestoneIds)&&n.milestoneIds.length>0&&b.push({label:"Milestones",value:V(n.milestoneIds.map(r=>B(r)?N(r):r))}),Array.isArray(n.iwmtIds)&&n.iwmtIds.length>0?b.push({label:"Scope IDs",value:V(n.iwmtIds.map(r=>B(r)?N(r):r),4)}):v(n.iwmtId)&&b.push({label:"Scope ID",value:B(n.iwmtId.trim())?N(n.iwmtId.trim()):n.iwmtId.trim()}),v(n.logPath)&&b.push({label:"Log path",value:Ne(n.logPath.trim())}),v(n.outputPath)&&b.push({label:"Output path",value:Ne(n.outputPath.trim())}));const be=(k==="blocked"||k==="failed")&&!!(i&&(v(i.reason)||le.length>0||b.length>0||Array.isArray(i.suggestedActions)&&i.suggestedActions.length>0)),Z=v(ie)?ie:null,qe=Z!==null&&!(M&&(Z===M||M.includes(Z)))&&!be,Pe=j.useCallback(()=>{!H||!t||(T("Session will be cancelled..."),pe({message:`Cancelled "${t.title}"`,onCommit:async()=>{try{await H(t),T("Session cancelled.")}catch(r){T(r instanceof Error?r.message:"Cancel failed.")}},onUndo:()=>{T(null)}}))},[H,t,pe]),Fe=[{label:"Started",value:t.startedAt?O(t.startedAt):"—"},{label:"Updated",value:t.updatedAt?O(t.updatedAt):"—"},...t.eta?[{label:"ETA",value:t.eta}]:[],...t.checkpointCount?[{label:"Checkpoints",value:String(t.checkpointCount)}]:[]],fe=s?s.status.replace(/_/g," "):null,F=G(s==null?void 0:s.initiativeIds,(s==null?void 0:s.initiativeId)??null),D=G(s==null?void 0:s.workstreamIds,(s==null?void 0:s.workstreamId)??null);G(s==null?void 0:s.iwmtIds,(s==null?void 0:s.iwmtId)??null);const Oe=F[0]?((je=c.find(r=>r.id===F[0]))==null?void 0:je.name)??F[0]:null,ge=W?W.toLowerCase().includes("fail")||W.toLowerCase().includes("error")?"error":u?"pending":"success":null;return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0",style:ot(o.status)}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("p",{className:"section-kicker",children:"Session Detail"}),e.jsxs("span",{className:L("inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em]",_e),children:[ne&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full pulse-soft",style:{backgroundColor:Ie(k)}}),We]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>he(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":U?"Expand session detail":"Collapse session detail",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:L("transition-transform",U?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}),me&&e.jsx("button",{type:"button",onClick:me,"aria-label":"Close session inspector",className:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-strong bg-white/[0.03] text-primary transition-colors hover:bg-white/[0.08] hover:text-white",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})})]})]}),e.jsxs("div",{className:L("transition-all flex flex-col min-h-0",U?"max-h-0 overflow-hidden":"flex-1"),children:[e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-5 space-y-5",children:[e.jsx(De,{mode:"wait",children:e.jsxs(I.div,{variants:dt,initial:"hidden",animate:"visible",exit:"exit",custom:0,children:[e.jsxs("div",{className:"flex items-start gap-3.5",children:[e.jsx(Xe,{name:t.agentName??"OrgX",size:"md",hint:t.agentName}),e.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[e.jsx("h2",{className:"text-display font-medium leading-tight text-white truncate",children:Ke(t.title)}),e.jsxs("p",{className:"mt-1 text-micro uppercase tracking-[0.12em] text-muted",children:[t.agentName??"OrgX"," · ",Ae.label]})]})]}),se.length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:se.map((r,l)=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Qe,{tone:"muted",children:r.value}),l<se.length-1&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"flex-shrink-0 text-faint",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})]},`${r.label}-${r.value}`))})]},t.id)}),e.jsx(ue,{}),M&&e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:1,children:[e.jsx("p",{className:"section-kicker mb-2",children:"Summary"}),e.jsx(He,{text:M,mode:"block"})]}),e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:2,children:e.jsxs("div",{className:L("rounded-xl border px-4 py-3",ze),children:[e.jsx("p",{className:"section-kicker mb-1.5",children:o.label}),e.jsx("p",{className:"text-body text-secondary",children:o.sentence}),o.nextAction&&e.jsxs("p",{className:"mt-1.5 flex items-center gap-1 text-caption text-secondary",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:x.lime,strokeWidth:"2.5",className:"flex-shrink-0",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),"Next: ",o.nextAction]})]})}),qe&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:3,children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-1.5",children:Te}),e.jsx("p",{className:"text-body text-secondary",children:Z})]})}),be&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:3,children:e.jsxs("div",{className:"rounded-xl border border-red-500/25 bg-red-500/10 px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-1.5 text-red-200/75",children:"Why blocked"}),e.jsx("p",{className:"text-body text-red-100/90",children:(i==null?void 0:i.reason)??ie??"Runtime marked this run as blocked without details."}),le.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:le.map(r=>e.jsx("span",{className:"rounded-full border border-red-300/25 bg-red-500/10 px-2 py-0.5 text-micro text-red-100/85",children:r},r))}),b.length>0&&e.jsxs("div",{className:"mt-2 rounded-md border border-red-300/20 bg-black/15 p-2.5",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.14em] text-red-200/65",children:"Associated context"}),e.jsx("dl",{className:"grid grid-cols-1 gap-1.5 text-caption text-red-100/85",children:b.map(r=>e.jsxs("div",{className:"grid grid-cols-[86px_1fr] gap-2",children:[e.jsx("dt",{className:"text-red-200/70",children:r.label}),e.jsx("dd",{className:"break-all text-red-50/95",children:r.value})]},r.label))})]}),Array.isArray(i==null?void 0:i.suggestedActions)&&i.suggestedActions.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.14em] text-red-200/65",children:"Suggested actions"}),e.jsx("ul",{className:"space-y-1 text-caption text-red-100/85",children:i.suggestedActions.map(r=>e.jsxs("li",{children:["• ",r]},r))})]}),v(i==null?void 0:i.eventTimestamp)&&e.jsxs("p",{className:"mt-2 text-micro text-red-200/60",children:["Last blocker event: ",new Date(i.eventTimestamp).toLocaleString()," ·"," ",O(i.eventTimestamp)]})]})}),e.jsx(ue,{}),e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:4,children:[P!==null&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between text-caption text-secondary",children:[e.jsx("span",{children:Ue}),e.jsxs("span",{className:"text-primary",children:[P,"%"]})]}),e.jsx("div",{className:"h-[3px] rounded-full bg-white/[0.08]",children:e.jsx(I.div,{className:L("h-[3px] rounded-full",ne&&"live-pulse"),style:{background:Ee},initial:{width:0},animate:{width:`${P}%`},transition:{duration:.5,ease:Je.easingStandard}})})]}),e.jsx("dl",{className:"grid grid-cols-2 gap-3 text-caption text-secondary",children:Fe.map(r=>e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:r.label}),e.jsx("dd",{className:"text-body font-semibold text-white",children:r.value})]},r.label))})]}),s&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:5,children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"section-kicker",children:"Slice scope"}),fe?e.jsx("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em] text-secondary",children:fe}):null]}),s.statusExplainer?e.jsx("p",{className:"mt-2 text-caption text-secondary",children:s.statusExplainer}):null,e.jsxs("dl",{className:"mt-2 grid grid-cols-2 gap-2 text-caption text-secondary",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Initiative"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:Oe??"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Workstream"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:s.workstreamTitle??(D[0]?N(D[0]):"—")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Run"}),e.jsx("dd",{className:"break-all text-body font-semibold text-white",children:N(s.runId??s.sliceRunId)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Updated"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:s.updatedAt?O(s.updatedAt):"—"})]})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5 text-micro",children:[e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Tasks ",s.taskIds.length]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Milestones ",s.milestoneIds.length]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Artifacts ",s.artifactCount]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Needs input ",s.blockingDecisionCount]}),F.length>1?e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["+",F.length-1," initiatives"]}):null,D.length>1?e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["+",D.length-1," workstreams"]}):null]}),s.taskIds.length>0?e.jsxs("p",{className:"mt-2 text-micro text-secondary",children:["Tasks: ",s.taskIds.length]}):null]})}),t.blockers.length>0&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:6,children:e.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-2 text-red-200/70",children:"Blockers"}),e.jsx("ul",{className:"space-y-1 text-body text-red-100/90",children:t.blockers.map(r=>e.jsxs("li",{children:["• ",r]},r))})]})}),e.jsx(ue,{}),e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:7,children:[e.jsx("p",{className:"section-kicker mb-4",children:"Recent Messages"}),$.length===0&&e.jsx("p",{className:"text-body text-secondary",children:"No recent messages for this run."}),e.jsx("div",{className:"relative border-l border-white/[0.06] pl-6 ml-1 space-y-3",children:$.map((r,l)=>e.jsxs(I.div,{className:"relative group",variants:R,initial:"hidden",animate:"visible",custom:l,children:[e.jsx("div",{className:"absolute -left-[27px] top-1.5 h-2 w-2 rounded-full border border-black ring-4 ring-black",style:{backgroundColor:Ie(r.type??r.state??"unknown")}}),e.jsxs("article",{className:"rounded-lg border border-subtle bg-white/[0.02] px-3 py-2.5 transition-colors hover:bg-white/[0.04]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 text-caption text-bright",children:r.title}),w&&e.jsx("button",{type:"button",onClick:()=>w(r),className:"flex-shrink-0 rounded-full border border-strong bg-white/[0.03] px-2.5 py-0.5 text-micro font-semibold text-secondary opacity-0 transition-all group-hover:opacity-100 hover:bg-white/[0.08] hover:text-primary",children:"Open"})]}),(r.summary||r.description)&&e.jsx("p",{className:"mt-0.5 line-clamp-2 text-caption text-secondary",children:r.summary??r.description}),e.jsxs("p",{className:"mt-1 text-micro text-muted",children:[new Date(r.timestamp).toLocaleString()," · ",O(r.timestamp)]})]})]},r.id))})]})]}),e.jsxs("div",{className:"flex-shrink-0 border-t border-subtle px-5 py-3 space-y-3",children:[W&&e.jsx("p",{className:L("rounded-md border px-2.5 py-1.5 text-caption",ge==="error"?"border-red-400/30 bg-red-500/10 text-red-200":ge==="pending"?"border-white/[0.08] bg-white/[0.02] text-secondary pulse-soft":"border-lime/25 bg-lime/[0.08] text-lime"),children:W}),te&&e.jsx("div",{children:e.jsx("textarea",{value:re,onChange:r=>q(r.target.value),placeholder:"Share guidance for this run...",rows:2,className:"w-full resize-none rounded-lg border border-white/[0.10] bg-white/[0.03] px-3 py-2 text-body text-bright outline-none placeholder:text-faint focus:border-white/20"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[$e&&e.jsx("button",{onClick:()=>_("pause-session","Session paused",()=>K==null?void 0:K(t)),disabled:!K||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="pause-session"?"Pausing...":"Pause"}),Me&&e.jsx("button",{onClick:()=>_("resume-session","Session resumed",()=>Q==null?void 0:Q(t)),disabled:!Q||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="resume-session"?"Resuming...":"Resume"}),e.jsx("button",{onClick:()=>_("checkpoint-session","Progress saved",()=>J==null?void 0:J(t)),disabled:!J||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="checkpoint-session"?"Saving...":"Save"}),Le&&e.jsx("button",{onClick:()=>_("rollback-session","Undo requested",()=>Y==null?void 0:Y(t)),disabled:!Y||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="rollback-session"?"Undoing...":"Undo"}),Be&&H&&e.jsx("button",{onClick:Pe,disabled:!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-red-400/70 hover:bg-red-500/[0.08] hover:text-red-300 disabled:opacity-45 transition-colors",children:"Cancel"})]}),e.jsx("div",{className:"flex-1"}),te&&e.jsx("button",{type:"button",onClick:()=>{const r=re.trim();if(!r){T("Intervention note cannot be empty.");return}_("intervene-note","Intervention sent",async()=>{await te({session:t,workstreamId:(C==null?void 0:C.workstreamId)??t.workstreamId??null,text:r}),q("")})},disabled:!!u||re.trim().length===0,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption font-semibold text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:u==="intervene-note"?"Sending...":"Intervene"}),e.jsxs("button",{onClick:()=>_("dispatch-session","Session started",()=>X==null?void 0:X(t)),disabled:!X||!!u||!Se,className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-lime/25 bg-lime/10 px-4 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",className:"flex-shrink-0",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),u==="dispatch-session"?"Starting...":o.status==="completed"?"Restart":"Start"]})]})]})]}),e.jsx(Ce,{})]})});export{vt as SessionInspector};