prismalens 0.5.4 → 0.5.5

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 (109) hide show
  1. package/dist/{chunk-ZZ3DOHTJ.js → chunk-3PSZIGUA.js} +14 -2
  2. package/dist/src/cli/up.js +1 -1
  3. package/dist/src/cli/update-notice.js +1 -1
  4. package/dist/src/cli/upgrade.js +70 -10
  5. package/node_modules/@prismalens/api/dist/src/core/settings/about.service.js +28 -8
  6. package/node_modules/@prismalens/api/dist/src/core/settings/update.service.js +9 -3
  7. package/node_modules/@prismalens/api/public/assets/{AddProjectDialog-BEBKziDJ.js → AddProjectDialog-p3LLsE1B.js} +1 -1
  8. package/node_modules/@prismalens/api/public/assets/{AgentDetail-DNNZ2RSQ.js → AgentDetail-CbhnttdO.js} +1 -1
  9. package/node_modules/@prismalens/api/public/assets/{AlertsBlank-M7HkWlgo.js → AlertsBlank-CVPQuVxb.js} +1 -1
  10. package/node_modules/@prismalens/api/public/assets/Composer-DIYA4JDp.js +1 -0
  11. package/node_modules/@prismalens/api/public/assets/{HelperThread-BmGnmkL5.js → HelperThread-DNWceguA.js} +1 -1
  12. package/node_modules/@prismalens/api/public/assets/{Hint-BCpVhAvV.js → Hint-Od6cnmvm.js} +1 -1
  13. package/node_modules/@prismalens/api/public/assets/{HomeComposer-BI6Vhge8.js → HomeComposer-sotk5r71.js} +1 -1
  14. package/node_modules/@prismalens/api/public/assets/{HypothesesCard-HKxfxVbG.js → HypothesesCard-BcaBcZ8b.js} +1 -1
  15. package/node_modules/@prismalens/api/public/assets/{IncidentHeader-BIYafwD0.js → IncidentHeader-GG30mdkp.js} +1 -1
  16. package/node_modules/@prismalens/api/public/assets/{KeptWorkspaces-ozJb7lRG.js → KeptWorkspaces-B_TvW0ro.js} +1 -1
  17. package/node_modules/@prismalens/api/public/assets/{MergeDialog-DRjChRQQ.js → MergeDialog-82IoAwUo.js} +1 -1
  18. package/node_modules/@prismalens/api/public/assets/{NewThread-HisGwIRc.js → NewThread-CAT5otyD.js} +1 -1
  19. package/node_modules/@prismalens/api/public/assets/{PanelShell-BHpdPx3P.js → PanelShell-ghqMmsZW.js} +1 -1
  20. package/node_modules/@prismalens/api/public/assets/{ProjectList-lAMigyat.js → ProjectList-DAPGOIoj.js} +1 -1
  21. package/node_modules/@prismalens/api/public/assets/{ResolveDialog-DbMNHrwo.js → ResolveDialog-CPNlWRrP.js} +1 -1
  22. package/node_modules/@prismalens/api/public/assets/{RingTick-DkMvLoUV.js → RingTick-Zd_duqBv.js} +1 -1
  23. package/node_modules/@prismalens/api/public/assets/{RunStrip-CLaYEj2D.js → RunStrip-CAosRfHY.js} +1 -1
  24. package/node_modules/@prismalens/api/public/assets/{RunsMenu-CD4Yy4jT.js → RunsMenu-B9_X_90y.js} +1 -1
  25. package/node_modules/@prismalens/api/public/assets/{ScheduleDialog-DPYtmK0g.js → ScheduleDialog-DKRvxEa7.js} +1 -1
  26. package/node_modules/@prismalens/api/public/assets/{ServiceFormDialog-9-qDnObk.js → ServiceFormDialog-Bfyz7V7X.js} +1 -1
  27. package/node_modules/@prismalens/api/public/assets/{SubagentPane-exGNOprU.js → SubagentPane-DxVUfFbn.js} +1 -1
  28. package/node_modules/@prismalens/api/public/assets/{Transcript-2ke3pjya.js → Transcript-Csly_ODF.js} +4 -4
  29. package/node_modules/@prismalens/api/public/assets/{TriggerCard-BIAznpA9.js → TriggerCard-B4_zrVDz.js} +1 -1
  30. package/node_modules/@prismalens/api/public/assets/{WebhookCopy-C8w9xwD6.js → WebhookCopy-Cy9bof9B.js} +1 -1
  31. package/node_modules/@prismalens/api/public/assets/{WorkspaceFields-DCSJCThm.js → WorkspaceFields-CXSg1krp.js} +1 -1
  32. package/node_modules/@prismalens/api/public/assets/{___design-8brlEBqd.js → ___design-F8T4DJmm.js} +1 -1
  33. package/node_modules/@prismalens/api/public/assets/{_authenticated-BETuqAeS.js → _authenticated-CJYOmwQf.js} +1 -1
  34. package/node_modules/@prismalens/api/public/assets/{_id-y5y3CxjT.js → _id-0EUmYM6O.js} +1 -1
  35. package/node_modules/@prismalens/api/public/assets/{_id-B8v8uWe_.js → _id-B4P0alBy.js} +1 -1
  36. package/node_modules/@prismalens/api/public/assets/{_id-DiQnst4D.js → _id-C_OturvV.js} +1 -1
  37. package/node_modules/@prismalens/api/public/assets/{_id-BeO8QWfB.js → _id-D3aRrGal.js} +1 -1
  38. package/node_modules/@prismalens/api/public/assets/{_id-Cnh_sXTf.js → _id-Jd8V68_n.js} +1 -1
  39. package/node_modules/@prismalens/api/public/assets/{_id-VgE-Xeq5.js → _id-o6KZri3X.js} +1 -1
  40. package/node_modules/@prismalens/api/public/assets/{_id_.runs._runId-U4P5LH-M.js → _id_.runs._runId-B2eT22Ak.js} +1 -1
  41. package/node_modules/@prismalens/api/public/assets/{alerts-BI1l8Cxn.js → alerts-DkmUI_TY.js} +1 -1
  42. package/node_modules/@prismalens/api/public/assets/{automation-FhFtuS5_.js → automation-Cw0qe0-8.js} +1 -1
  43. package/node_modules/@prismalens/api/public/assets/{boxes-Dh2QZfJa.js → boxes-B__2zYVO.js} +1 -1
  44. package/node_modules/@prismalens/api/public/assets/check-C96xWdLm.js +1 -0
  45. package/node_modules/@prismalens/api/public/assets/chevron-left-S6eOHk4C.js +1 -0
  46. package/node_modules/@prismalens/api/public/assets/chevron-right-DXWfiPu3.js +1 -0
  47. package/node_modules/@prismalens/api/public/assets/circle-Dy7W2aR3.js +1 -0
  48. package/node_modules/@prismalens/api/public/assets/{command-chip-5Lf0FARB.js → command-chip-BFhgzAY5.js} +1 -1
  49. package/node_modules/@prismalens/api/public/assets/{conversation-CXkaesO_.js → conversation-Cf7_OnZb.js} +1 -1
  50. package/node_modules/@prismalens/api/public/assets/{copy-BUnkkIK-.js → copy-_5FNPl7W.js} +1 -1
  51. package/node_modules/@prismalens/api/public/assets/desktop-yb-lqHMd.js +9 -0
  52. package/node_modules/@prismalens/api/public/assets/{device-name-CZPntaj6.js → device-name-CxC_JUpj.js} +1 -1
  53. package/node_modules/@prismalens/api/public/assets/{dist-CYLssYEL.js → dist-CtE2KbbF.js} +1 -1
  54. package/node_modules/@prismalens/api/public/assets/{dist-CQz4Osl1.js → dist-zIr1CK3Q.js} +1 -1
  55. package/node_modules/@prismalens/api/public/assets/{dropdown-menu-Db9u3UIb.js → dropdown-menu-yoILSLgJ.js} +1 -1
  56. package/node_modules/@prismalens/api/public/assets/{ellipsis-d1vABf4v.js → ellipsis-BsNLvnl9.js} +1 -1
  57. package/node_modules/@prismalens/api/public/assets/{evidence-files-C9UcJR1J.js → evidence-files-C_a9Ct8m.js} +1 -1
  58. package/node_modules/@prismalens/api/public/assets/{fixes-CgjsPkfr.js → fixes-BWFKY2Zx.js} +1 -1
  59. package/node_modules/@prismalens/api/public/assets/{folder-git-2-DRsiaeAx.js → folder-git-2-Co_pliwR.js} +1 -1
  60. package/node_modules/@prismalens/api/public/assets/{globe-D2S-zGel.js → globe-C0OZE9Nx.js} +1 -1
  61. package/node_modules/@prismalens/api/public/assets/{highlighted-body-JLMTFACH-B_v9yJZa.js → highlighted-body-JLMTFACH-DGWjXpHw.js} +1 -1
  62. package/node_modules/@prismalens/api/public/assets/{incidents-B0KnIveX.js → incidents-TJ2Rty4H.js} +1 -1
  63. package/node_modules/@prismalens/api/public/assets/{index-DZMj9YK4.js → index-BoI68UdU.js} +6 -6
  64. package/node_modules/@prismalens/api/public/assets/{key-CjFGD02m.js → key-BjaZOgBI.js} +1 -1
  65. package/node_modules/@prismalens/api/public/assets/{live-refresh-C5Jfxdxb.js → live-refresh-DlFUKDgl.js} +1 -1
  66. package/node_modules/@prismalens/api/public/assets/mermaid-WFAXDIZX-BQk6GVWB.js +1 -0
  67. package/node_modules/@prismalens/api/public/assets/{new-Ci475pgf.js → new-Bo1xcbFc.js} +1 -1
  68. package/node_modules/@prismalens/api/public/assets/{pair-CobM73_c.js → pair-BePmSLQZ.js} +1 -1
  69. package/node_modules/@prismalens/api/public/assets/{pencil-BwNhunJy.js → pencil-CKAiE_29.js} +1 -1
  70. package/node_modules/@prismalens/api/public/assets/plus-f3bDJe68.js +1 -0
  71. package/node_modules/@prismalens/api/public/assets/projects-Cwgyv1jw.js +1 -0
  72. package/node_modules/@prismalens/api/public/assets/{restart-40l7XMmi.js → restart-FIcq7DzH.js} +1 -1
  73. package/node_modules/@prismalens/api/public/assets/{route-DX3TI7JD.js → route-1kdlRYKk.js} +1 -1
  74. package/node_modules/@prismalens/api/public/assets/{route-Dvao2bBW.js → route-CLgiK_od.js} +1 -1
  75. package/node_modules/@prismalens/api/public/assets/{route-Bg17GbpR.js → route-q1BFinlW.js} +1 -1
  76. package/node_modules/@prismalens/api/public/assets/{route-ah1SnYbH.js → route-rOkhgLEt.js} +1 -1
  77. package/node_modules/@prismalens/api/public/assets/{run-details-DTzMO1X0.js → run-details-B1I5SE7k.js} +1 -1
  78. package/node_modules/@prismalens/api/public/assets/{run-labels-ubQZmnqd.js → run-labels-BLTL5eG9.js} +1 -1
  79. package/node_modules/@prismalens/api/public/assets/{select-98_n4DVz.js → select-hkRu0Dxf.js} +1 -1
  80. package/node_modules/@prismalens/api/public/assets/{service-detail.utils-ulWHS1Ao.js → service-detail.utils-BQfYgq-F.js} +1 -1
  81. package/node_modules/@prismalens/api/public/assets/{services-CZQMzqYj.js → services-CnYlTAN3.js} +1 -1
  82. package/node_modules/@prismalens/api/public/assets/{settings-QPxeIS82.js → settings-COMwARMq.js} +1 -1
  83. package/node_modules/@prismalens/api/public/assets/{source-words-B5oOdiQU.js → source-words-CCeTLwOy.js} +1 -1
  84. package/node_modules/@prismalens/api/public/assets/{state-tone-DEsvSFn6.js → state-tone-DOGSNxJV.js} +1 -1
  85. package/node_modules/@prismalens/api/public/assets/{switch-DpPkkZxw.js → switch-u0tmvVOg.js} +1 -1
  86. package/node_modules/@prismalens/api/public/assets/{theme-provider-C9jvt7JX.js → theme-provider-Cg3suR2p.js} +1 -1
  87. package/node_modules/@prismalens/api/public/assets/{threads-BqAHgCGd.js → threads-Pk0lpo7I.js} +1 -1
  88. package/node_modules/@prismalens/api/public/assets/{tick-copy-B7dbIrfQ.js → tick-copy-DPjahm-5.js} +1 -1
  89. package/node_modules/@prismalens/api/public/assets/{use-operator-BH6GxjAY.js → use-operator-BdSmIxpm.js} +1 -1
  90. package/node_modules/@prismalens/api/public/assets/{use-repositories-orpc-c6hPOKjE.js → use-repositories-orpc-Ban_zGD7.js} +1 -1
  91. package/node_modules/@prismalens/api/public/assets/{use-threads-orpc-rBrvQXJf.js → use-threads-orpc-mbpsuq3G.js} +1 -1
  92. package/node_modules/@prismalens/api/public/assets/{useInvestigationRun-xdB0R08B.js → useInvestigationRun-BJKQxOF2.js} +1 -1
  93. package/node_modules/@prismalens/api/public/assets/{useQueries-CGpidxif.js → useQueries-B6U7UAZl.js} +1 -1
  94. package/node_modules/@prismalens/api/public/index.html +2 -2
  95. package/node_modules/@prismalens/config/dist/index.js +2 -1
  96. package/node_modules/@prismalens/config/dist/utils/install-channel.js +3 -3
  97. package/node_modules/@prismalens/config/dist/utils/update-channel.js +65 -0
  98. package/node_modules/@prismalens/config/dist/utils/update-check.js +67 -34
  99. package/node_modules/@prismalens/contracts/dist/schemas/settings.js +16 -0
  100. package/package.json +3 -2
  101. package/node_modules/@prismalens/api/public/assets/Composer-MAXlRLhF.js +0 -1
  102. package/node_modules/@prismalens/api/public/assets/check-DfKru7HJ.js +0 -1
  103. package/node_modules/@prismalens/api/public/assets/chevron-left-DWLaEwl8.js +0 -1
  104. package/node_modules/@prismalens/api/public/assets/chevron-right-tPbGnTHi.js +0 -1
  105. package/node_modules/@prismalens/api/public/assets/circle-BqIhGHXt.js +0 -1
  106. package/node_modules/@prismalens/api/public/assets/desktop-Bqso9PNq.js +0 -9
  107. package/node_modules/@prismalens/api/public/assets/mermaid-WFAXDIZX-CqliGVff.js +0 -1
  108. package/node_modules/@prismalens/api/public/assets/plus-DWSahnrj.js +0 -1
  109. package/node_modules/@prismalens/api/public/assets/projects-CIckRlw8.js +0 -1
@@ -1,2 +1,2 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-Wy9s6hX0.js";import{t as r}from"./link-BHh9_evg.js";import{F as i,I as a,L as o,M as s,Q as c,R as l,U as u,X as d,Xt as f,Z as p,_t as m,a as h,c as g,gt as _,q as v,r as y,s as b,z as x}from"./desktop-Bqso9PNq.js";import{n as S}from"./useNavigate-I5E4IRt2.js";import{A as ee,F as C,M as te,N as w,O as ne,P as T,a as E,f as D,gt as re,ht as O,j as ie,k as ae,lt as k,n as oe,r as se,rt as A,v as j}from"./source-words-B5oOdiQU.js";import{W as M}from"./AgentDetail-DNNZ2RSQ.js";import{n as N}from"./restart-40l7XMmi.js";import{$ as P,F as ce,J as F,K as I,X as L,r as le,t as R,u as z}from"./Hint-BCpVhAvV.js";import{t as ue}from"./chevron-left-DWLaEwl8.js";import{t as de}from"./copy-BUnkkIK-.js";import{t as fe}from"./ellipsis-d1vABf4v.js";import{t as B}from"./utils-A3okWeke.js";import{n as pe,t as V}from"./MergeDialog-DRjChRQQ.js";import{n as me,r as H}from"./trigger-DVo1oKMX.js";import{n as U,t as W}from"./button-DmIfWVZ8.js";import{C as he,S as ge,b as _e,w as ve,x as ye,y as be}from"./use-repositories-orpc-c6hPOKjE.js";import{a as xe,c as Se,d as Ce,l as we,n as Te,o as Ee,r as G,t as De,u as Oe}from"./dropdown-menu-Db9u3UIb.js";import{n as K}from"./CopyButton-DKP5JHET.js";import{o as ke}from"./State-CCKzehkH.js";import{t as Ae}from"./use-page-title-DEIRQICr.js";import{n as je}from"./evidence-files-C9UcJR1J.js";import{I as Me,R as Ne,ht as Pe,lt as Fe,z as q}from"./index-DZMj9YK4.js";import{i as Ie,n as Le}from"./useInvestigationRun-xdB0R08B.js";import{a as Re,c as ze,f as J,i as Be,n as Ve,p as He,r as Ue}from"./run-labels-ubQZmnqd.js";import{n as We,r as Ge}from"./record-context-CoIOStXx.js";import{n as Ke}from"./service-lanes-BfHIrySn.js";import{t as qe}from"./use-escape-back-CK0fWxlL.js";import{a as Je,c as Ye,d as Xe,f as Y,h as Ze,i as Qe,l as $e,m as et,n as tt,o as nt,p as rt,r as it,s as at,t as ot,u as st}from"./fixes-CgjsPkfr.js";var ct={name:`circle-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.35 2.69A10 10 0 0 1 21.3 15.65`,key:`1pfsoa`}],[`path`,{d:`M19.08 19.08A10 10 0 1 1 4.92 4.92`,key:`1ablyi`}]]};ct.node;var lt=h(ct),ut={name:`circle-pause`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]],aliases:[`pause-circle`]};ut.node;var dt=h(ut),ft={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};ft.node;var pt=h(ft),mt={name:`git-commit-horizontal`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]],aliases:[`git-commit`]};mt.node;var ht=h(mt),X=e(t(),1),Z=n(),gt={Confirmed:`done`,Likely:`accent`,Unconfirmed:`stale`,"No cause found":`neutral`};function _t(e){let t=e.hypotheses.find(e=>e.status!==`refuted`);if(!e.rootCause){let t=e.hypotheses.filter(e=>e.status===`supported`||e.status===`confirmed`).length;return{word:`No cause found`,tone:gt[`No cause found`],basis:t===0?`nothing it found is supported`:`${t===1?`one finding is`:`${t} findings are`} supported, but not as a cause`}}let n=t?.status===`confirmed`?`Confirmed`:t?.status===`supported`?`Likely`:`Unconfirmed`,r=t?.evidence??[],i=r.filter(e=>e.direction===`supports`).length,a=r.filter(e=>e.direction===`contradicts`).length,o=i===1?`one piece`:`${i} pieces`;return{word:n,tone:gt[n],basis:i===0?`no evidence for it was recorded`:`${o} of evidence for it, ${a===0?`none`:a} against`}}function vt(e,t){return e.draft?t.alertCount>0&&!t.reported?`investigate`:`ask`:`investigate`}var yt=1500;function bt(e,t,n){let r=n.trim();if(r)return r;let i=e.nextSteps.map(e=>e.title).join(`; `),a=`Re-check Run #${t}. It found: ${e.summary.replace(/\.$/,``)}. Cause named: ${e.rootCause?.replace(/\.$/,``)||`none`}. Next steps it proposed: ${i||`none`}.`;return a.length>yt?`${a.slice(0,1499)}…`:a}function xt({title:e,sub:t,actions:n,children:r,testId:i,className:a,id:o}){let s=(0,X.useId)();return(0,Z.jsxs)(`section`,{id:o,"aria-labelledby":s,className:B(`flex min-h-0 min-w-0 flex-col gap-2.5 rounded-pool bg-surface-1 px-4 pt-3.5 pb-3`,a),"data-testid":i,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-baseline gap-3 whitespace-nowrap max-md:flex-wrap max-md:gap-y-1.5`,children:[(0,Z.jsx)(`h2`,{id:s,className:`shrink-0 text-heading`,children:e}),t,(0,Z.jsx)(`span`,{className:`flex-1`}),n]}),(0,Z.jsx)(Tt,{children:r})]})}function St(e){let t=e.scrollHeight-e.clientHeight>2,n=e.scrollTop+e.clientHeight,r=e.scrollHeight-n<=2;if(!t||r)return{overflows:t,rows:0,next:``,atEnd:r};let i=e.getBoundingClientRect().top-e.scrollTop,a=0,o=``;for(let t of Array.from(e.querySelectorAll(`[data-row]`)))if(t.getBoundingClientRect().bottom-i>n+2){a++;let e=t.dataset.row;o||=e&&e!==`true`?e:``}return{overflows:t,rows:a,next:o,atEnd:r}}function Ct(e){if(e.length<=28)return e;let t=e.slice(0,28);return`${t.slice(0,Math.max(t.lastIndexOf(` `),16))}…`}var wt=(e,t)=>e.overflows===t.overflows&&e.rows===t.rows&&e.next===t.next&&e.atEnd===t.atEnd;function Tt({children:e,className:t}){let n=(0,X.useRef)(null),[r,i]=(0,X.useState)({overflows:!1,rows:0,next:``,atEnd:!0}),a=(0,X.useCallback)(()=>{let e=n.current;if(!e)return;let t=St(e);i(e=>wt(e,t)?e:t)},[]);return(0,X.useEffect)(()=>{let e=n.current;if(!e)return;a();let t=new ResizeObserver(a);t.observe(e);let r=new MutationObserver(a);r.observe(e,{childList:!0,subtree:!0,characterData:!0});for(let n of Array.from(e.children))t.observe(n);return()=>{t.disconnect(),r.disconnect()}},[a]),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsx)(`div`,{ref:n,onScroll:a,className:B(`min-h-0 flex-1 overflow-y-auto overscroll-contain [scrollbar-width:thin]`,r.overflows&&!r.atEnd&&`[mask-image:linear-gradient(to_bottom,black_calc(100%-28px),transparent)]`,t),"data-testid":`card-body`,children:e}),r.overflows&&(0,Z.jsx)(`div`,{className:`flex h-6 shrink-0 items-end justify-end`,children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{let e=n.current;e&&(r.atEnd?e.scrollTo({top:0,behavior:`smooth`}):e.scrollBy({top:e.clientHeight*.8,behavior:`smooth`}))},className:`flex min-h-6 items-center gap-1 rounded-control px-1.5 text-meta text-accent transition-colors duration-(--dur-instant) hover:bg-surface-3`,"data-testid":`card-more`,children:[r.atEnd?`Back to top`:r.next?`${Ct(r.next)}${r.rows>1?` and ${r.rows-1} more`:``} below`:r.rows>0?`${r.rows} more below`:`More below`,(0,Z.jsx)(P,{className:B(`size-3`,r.atEnd&&`rotate-180`),"aria-hidden":!0})]})})]})}var Et=e=>typeof e==`string`&&Object.hasOwn(v,e)?v[e]:null;function Dt(e){let t=Et(e.metadata?.newStatus);return e.type===`status_changed`&&e.title===`Status changed`&&t?t:e.title}var Ot=e=>e?e.slice(0,7):null;function kt(e){let t=e.tag??Ot(e.sha);switch(e.kind){case`deployment`:return t?`Deploy ${t}`:`Deploy`;case`rollback`:return t?`Rollback to ${t}`:`Rollback`;case`release`:return`Release ${e.tag??Ot(e.sha)??``}`.trim();case`merge`:return e.pr?`Merged #${e.pr}`:`Merge`;case`config`:return`Config change`;case`migration`:return`Migration`;default:return t?`Commit ${t}`:`Commit`}}function At(e,t,n){let r=Math.round((Date.parse(t)-Date.parse(e))/6e4),i=n?`the alert`:`the incident opened`;return r<0?`after the incident opened`:r<120?`${r} ${r===1?`minute`:`minutes`} before ${i}`:`${Math.round(r/60)} hours before ${i}`}function jt(e){if(e.files&&e.files.count>0){let t=e.files.paths[0],n=e.files.count;return t?`${n} ${n===1?`file`:`files`}, including ${t}`:`${n} ${n===1?`file`:`files`}`}return e.title}function Mt(e){return e.type===`investigation_started`&&/\bresumed$/i.test(e.title)}function Nt(e,t){let n=e.metadata?.investigationId,r=typeof n==`string`?t.find(e=>e.id===n)??null:null,i={key:`t:${e.id}`,at:e.occurredAt};if(r&&Mt(e))return r.kind===`chat`?null:{...i,text:`${J(t,r)} continued`,tone:Be(r)===`working`?`live`:`accent`,runId:r.id};if(r&&e.type===`investigation_started`)return r.kind===`chat`?{...i,text:r.title?`You asked: ${r.title}`:`You asked a question`,tone:`plain`,runId:r.id}:{...i,text:`${J(t,r)} started`,tone:Be(r)===`working`?`live`:`accent`,runId:r.id};if(r&&e.type===`investigation_completed`){if(r.kind===`chat`)return null;let n=Be(r),a=l(n)?r.hasReport?`done`:/stopped/i.test(e.title)?`stopped`:`failed`:n,o=a===n?ze(r):a===`done`?Re(r.rootCause):a;return{...i,text:a===`failed`||a===`stopped`?`${J(t,r)} ${o}`:`${J(t,r)} concluded: ${o}`,tone:a===`failed`?`danger`:`accent`,runId:r.id}}if(e.type===`comment`)return{...i,text:`Note: ${e.title}`,tone:`plain`};let a=e.metadata?.priorIncidentId;if(e.type===`incident_created`)return typeof a==`string`&&e.description?{...i,text:e.description,tone:`plain`,incidentId:a}:{...i,text:`Incident opened`,tone:`plain`};if(e.type===`custom`&&e.description&&!Dt(e).includes(e.description))return{...i,text:`${Dt(e)}: ${e.description}`,tone:`plain`};let o=e.metadata?.mergedIntoId??e.metadata?.mergedFromId,s=e.metadata?.reason===`merged`&&typeof o==`string`?{incidentId:o}:{};return e.type===`alert_added`||e.type===`alert_removed`?{...i,text:e.description?`${e.title}: ${e.description}`:e.title,tone:e.type===`alert_added`?`danger`:`plain`,...s}:e.type===`recommendation_completed`?{...i,text:e.title,tone:`ok`}:{...i,text:Dt(e),tone:`plain`,...s}}function Pt(e,t,n){let r=new Set,i=[];for(let t of e){let e=t.metadata?.investigationId,a=t.type===`investigation_started`||t.type===`investigation_completed`;if(typeof e==`string`&&!a&&t.type!==`recommendation_completed`)continue;let o=Nt(t,n);if(!o)continue;let s=Mt(t)?t.id:`${t.type}:${String(e)}`;a&&r.has(s)||(a&&r.add(s),i.push(o))}for(let e of t)i.push({key:`c:${e.id}`,at:e.at,text:`${kt(e)}: ${e.title}`,tone:`accent`,url:e.url});return i.sort((e,t)=>Date.parse(t.at)-Date.parse(e.at))}function Ft(e){if(!e)return null;if(e.state===`no-repos`)return{text:`No repository is linked to this incident's services, so deploys and merges cannot show here.`,action:{label:`Link a repository`,to:`service`}};let t=e.sources.find(e=>e.problem)?.problem;return t?t.action===`add-credential`?{text:`Add a git host token, or sign in to git on this machine, to see deploys and merges`,action:{label:`Add a token`,to:`settings`}}:t.action===`replace-token`?{text:t.message,action:{label:`Replace the token`,to:`settings`}}:t.action===`pick-credential`?{text:t.message,action:{label:`Pick a credential`,to:`settings`}}:{text:t.message,action:null}:null}var It={danger:`bg-danger`,accent:`bg-accent`,live:`bg-live breathe`,ok:`bg-ok`,plain:`bg-text-3`},Lt=6;function Rt({o:e,wide:t}){let n=q(3e4),{incident:i,runs:a,timeline:o,timelineLoading:s}=e.record,c=e.changes,l=(0,X.useMemo)(()=>Pt(o,c?.timeline??[],a),[o,c?.timeline,a]),u=l.filter(e=>e.key.startsWith(`t:`)).length+(c?.total??0),d=e.allChanges?l:l.slice(0,Lt),f=Ft(c),p=c?.deploy??null,m=c?.state===`pending`||c?.refreshing;return(0,Z.jsx)(xt,{title:`What changed and when`,className:t?`md:col-span-2`:void 0,testId:`changes-card`,actions:u>Lt?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>e.setAllChanges(!e.allChanges),className:`text-meta text-accent hover:underline`,"aria-expanded":e.allChanges,"data-testid":`changes-all`,children:e.allChanges?`Latest ${Lt}`:`All ${u} events`}):null,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[p&&(0,Z.jsx)(Bt,{name:kt(p),detail:jt(p),at:p.at,started:i.createdAt,url:p.url,now:n,hasAlert:(i.alerts??[]).length>0}),f&&(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5 rounded-surface bg-surface-2 px-3 py-2`,"data-testid":`changes-problem`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-text-2`,children:f.text}),f.action&&(0,Z.jsx)(W,{variant:`secondary`,className:`h-[26px] shrink-0 bg-surface-3 hover:bg-surface-4`,asChild:!0,children:f.action.to===`service`&&i.service?(0,Z.jsx)(r,{to:`/services/$id`,params:{id:i.service.id},children:f.action.label}):(0,Z.jsx)(r,{to:`/settings`,search:{tab:`sources`},children:f.action.label})})]}),m&&!p&&(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-meta text-text-3`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`breathe size-1.5 rounded-full bg-live`}),`Reading the git history`]}),!s&&l.length===0?(0,Z.jsx)(`p`,{className:`text-text-3`,children:`No events yet.`}):(0,Z.jsx)(`ol`,{className:`flex flex-col`,"data-testid":`changes-timeline`,children:d.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2.5 px-1 py-1.5 shadow-[inset_0_-1px_0_var(--hairline)]`,"data-row":e.text,"data-testid":`changes-row`,children:[(0,Z.jsx)(R,{label:F(e.at),side:`left`,children:(0,Z.jsx)(`span`,{className:`w-[104px] shrink-0 text-meta text-text-3 tabular-nums`,children:Ve(e.at,n)})}),(0,Z.jsx)(`span`,{"aria-hidden":!0,className:B(`size-1.5 shrink-0 rounded-full`,It[e.tone])}),(0,Z.jsx)(zt,{row:e,incidentId:i.id})]},e.key))})]})})}function zt({row:e,incidentId:t}){let n=`min-w-0 line-clamp-2`,i=(0,Z.jsx)(R,{label:e.text,children:(0,Z.jsx)(`span`,{className:n,dir:`auto`,children:e.text})});return e.runId?(0,Z.jsx)(r,{to:`/incidents/$id/conversation`,params:{id:t},search:{investigation:e.runId},className:B(n,`py-0.5 hover:text-accent`),dir:`auto`,children:e.text}):e.incidentId?(0,Z.jsx)(r,{to:`/incidents/$id`,params:{id:e.incidentId},className:B(n,`hover:text-accent`),dir:`auto`,"data-testid":`changes-merge-link`,children:e.text}):e.url?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:B(n,`hover:text-accent`),dir:`auto`,children:e.text}):i}function Bt({name:e,detail:t,at:n,started:r,url:i,now:a,hasAlert:o}){let s=Math.round((Date.parse(r)-Date.parse(n))/6e4),c=s>=0&&s<120?`, ${At(n,r,o)}`:``,l=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ht,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`shrink-0 font-medium`,children:e}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-text-2`,children:t}),(0,Z.jsx)(R,{label:`${F(n)}${c}`,children:(0,Z.jsx)(`span`,{className:`shrink-0 text-meta text-text-3`,children:Ve(n,a)})})]}),u=`flex min-w-0 items-center gap-2.5 rounded-surface bg-surface-2 px-3 py-2 whitespace-nowrap`;return i?(0,Z.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:B(u,`transition-colors duration-(--dur-instant) hover:bg-surface-3`),"data-testid":`changes-deploy`,children:l}):(0,Z.jsx)(`div`,{className:u,"data-testid":`changes-deploy`,children:l})}function Vt(e){return e?.metric&&e.series.length>0&&(e.state===`ok`||e.metric.source===`service`)?e:null}function Ht(e){let t=e.connection?`from ${e.connection.label}, `:``;return e.metric.source===`service`?`The service's metric, not this alert's, ${t}last 24 hours`:e.metric.source===`alert_current_rule`?`The alert's rule as loaded now; it may have changed since this alert fired, ${t}last 24 hours`:`The alert's own query, ${t}last 24 hours`}function Ut({view:e}){let{impact:t,pending:n,slow:r,failed:i,retry:a}=e,o=Vt(t),s=r||t?.state===`timeout`,c=i??(t?.state===`error`?t.error??`it refused the query`:null),l=o?Ht(o):n&&!r?`Asking the metrics source`:s||c?`The metrics source did not answer`:t?.history.alertCount===0?`No alert on this incident`:`From the alert alone`;return(0,Z.jsx)(xt,{title:`Impact`,sub:(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-meta text-text-3`,children:l}),testId:`impact-card`,children:o?(0,Z.jsx)(Wt,{impact:o}):n&&!r?(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-2`,"data-testid":`impact-pending`,children:[(0,Z.jsx)(`span`,{className:`text-meta text-text-3`,children:`Asking for the last 24 hours`}),(0,Z.jsx)(ke,{className:`min-h-[60px] flex-1 rounded-control`})]}):s||c?(0,Z.jsxs)(`div`,{className:`flex h-full flex-col items-start justify-center gap-2.5`,"data-testid":`impact-slow`,children:[(0,Z.jsx)(`p`,{className:`text-text-2`,children:s?`The metrics source has not answered for 10 seconds. Nothing else on this page waits for it.`:`The metrics source answered with an error: ${c}`}),(0,Z.jsx)(W,{variant:`secondary`,className:`h-7 bg-surface-3 hover:bg-surface-4`,onClick:a,"data-testid":`impact-retry`,children:`Try again`})]}):t?(0,Z.jsx)(Jt,{impact:t,firing:e.firing}):null})}function Wt({impact:e}){let t=(0,X.useMemo)(()=>Xe(e),[e]),n=e.series.length>1,r=e.metric.threshold,i=e.metric.unit,a=r&&e.now!==null?Kt(e.now,r):!1,o=e.metric.source===`service`?`Service metric`:n?`${e.series.length} series match`:`This alert's series`;return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 gap-5`,"data-testid":`impact-chart`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-meta text-text-3`,children:[(0,Z.jsx)(R,{label:e.metric.query,children:(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-0.5 w-2.5 bg-danger`}),o]})}),r&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`svg`,{"aria-hidden":!0,width:`10`,height:`2`,className:`shrink-0`,children:(0,Z.jsx)(`line`,{x1:`0`,y1:`1`,x2:`10`,y2:`1`,stroke:`var(--warn)`,strokeDasharray:`3 2`})}),`Alert fires `,Gt(r.op),` `,Y(r.value,i)]}),t.deploys.map(e=>(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-2.5 w-0.5 bg-accent`}),e.label]},`${e.x}-${e.label}`))]}),(0,Z.jsxs)(`div`,{className:`flex min-h-[60px] flex-1 gap-1.5`,children:[(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`relative w-10 shrink-0 text-right text-[11px] leading-3 text-text-3`,children:t.ticks.map(e=>(0,Z.jsx)(`span`,{className:`absolute right-0`,style:{top:`calc(${e.y/200*100}% - 6px)`},children:Y(e.value,i)},e.value))}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsxs)(`svg`,{viewBox:`0 0 720 200`,preserveAspectRatio:`none`,width:`100%`,height:`100%`,role:`img`,"aria-label":qt(e,o),className:`block`,children:[t.ticks.map(e=>(0,Z.jsx)(`line`,{x1:`0`,x2:720,y1:e.y,y2:e.y,stroke:`var(--hairline)`,vectorEffect:`non-scaling-stroke`},e.value)),t.thresholdY!==null&&(0,Z.jsx)(`line`,{x1:`0`,x2:720,y1:t.thresholdY,y2:t.thresholdY,stroke:`var(--warn)`,strokeDasharray:`4 4`,vectorEffect:`non-scaling-stroke`}),t.deploys.map(e=>(0,Z.jsx)(`line`,{x1:e.x,x2:e.x,y1:`0`,y2:200,stroke:`var(--accent)`,strokeWidth:`1.5`,vectorEffect:`non-scaling-stroke`},`${e.x}-${e.label}`)),t.area&&(0,Z.jsx)(`polygon`,{points:t.area,fill:`oklch(from var(--danger) l c h / 0.12)`}),t.lines.map((e,t)=>(0,Z.jsx)(`polyline`,{points:e,fill:`none`,stroke:`var(--danger)`,strokeWidth:n?1.25:2,strokeOpacity:n?.7:1,strokeLinejoin:`round`,vectorEffect:`non-scaling-stroke`},t))]})})]}),(0,Z.jsxs)(`div`,{className:`relative ml-[38px] h-4 text-meta text-text-3`,children:[t.xLabels.map(e=>(0,Z.jsx)(`span`,{className:`absolute`,style:{left:`${e.x}%`},children:e.label},e.x)),(0,Z.jsx)(`span`,{className:`absolute right-0`,children:`Now`})]})]}),e.now!==null&&(0,Z.jsx)(`dl`,{className:`flex w-[120px] shrink-0 flex-col justify-center gap-3`,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-meta text-text-3`,children:`Now`}),(0,Z.jsx)(`dd`,{className:B(`text-display`,a?`text-danger`:`text-text-1`),"data-testid":`impact-now`,children:Y(e.now,i)}),e.usual!==null&&(0,Z.jsxs)(`dd`,{className:`text-meta text-text-2`,children:[`Usually `,Y(e.usual,i)]})]})})]})}var Gt=e=>e.startsWith(`<`)?`below`:e===`==`?`at`:e===`!=`?`away from`:`above`;function Kt(e,t){switch(t.op){case`>`:return e>t.value;case`>=`:return e>=t.value;case`<`:return e<t.value;case`<=`:return e<=t.value;case`==`:return e===t.value;default:return e!==t.value}}function qt(e,t){let n=e.metric.unit,r=[`${t} over the last 24 hours`];return e.now!==null&&r.push(`now ${Y(e.now,n)}`),e.usual!==null&&r.push(`usually ${Y(e.usual,n)}`),e.metric.threshold&&r.push(`the alert fires at ${Y(e.metric.threshold.value,n)}`),r.join(`, `)}function Jt({impact:e,firing:t}){let n=q(3e4)??Date.now(),r=e.history,i=r.firingSince&&!r.resolvedAt?n-Date.parse(r.firingSince):null;return r.alertCount===0?(0,Z.jsx)(`div`,{className:`flex h-full flex-col`,"data-testid":`impact-no-alert`,children:(0,Z.jsx)(Yt,{impact:e})}):(0,Z.jsxs)(`div`,{className:`flex h-full flex-col gap-3.5`,"data-testid":`impact-no-source`,children:[(0,Z.jsxs)(`dl`,{className:`grid grid-cols-[repeat(auto-fit,minmax(9rem,1fr))] gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-meta text-text-3`,children:`Firing for`}),(0,Z.jsx)(`dd`,{className:B(`truncate text-display`,i===null?`text-text-2`:`text-danger`),children:i===null?`Not firing`:L(Math.max(0,i)/1e3)})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-meta text-text-3`,children:`Alerts`}),(0,Z.jsxs)(`dd`,{className:`truncate text-display`,children:[t,` of `,r.alertCount,` firing`]})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-meta text-text-3`,children:`Fired before`}),(0,Z.jsx)(`dd`,{className:`truncate text-display`,children:r.refiresThisWeek===0?`Not this week`:`${r.refiresThisWeek} ${r.refiresThisWeek===1?`time`:`times`} this week`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-meta text-text-3`,children:`When this alert fired, last 7 days`}),(0,Z.jsx)(`div`,{className:`relative h-6 overflow-hidden rounded-control bg-surface-2`,children:r.strip.map((e,t)=>{let i=Ze(e,n),a=t===r.strip.length-1,o=e.end?`Fired ${I(e.start)} for ${L((Date.parse(e.end)-Date.parse(e.start))/1e3)}`:`Firing since ${I(e.start)}`;return(0,Z.jsx)(R,{label:o,children:(0,Z.jsx)(`span`,{tabIndex:0,role:`img`,"aria-label":o,className:B(`absolute inset-y-0`,a?`bg-danger`:`bg-danger/45`),style:{left:`${i.left}%`,width:`${i.width}%`}})},e.start)})}),(0,Z.jsx)(`div`,{className:`flex justify-between text-meta text-text-3`,children:et(n).map((e,t)=>(0,Z.jsx)(`span`,{children:e},t))})]}),(0,Z.jsx)(Yt,{impact:e})]})}function Yt({impact:e}){let t=rt(e);return(0,Z.jsxs)(`div`,{className:`mt-auto flex min-w-0 items-center gap-3 rounded-surface bg-surface-2 px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-text-2`,children:t}),e.state===`not_configured`?(0,Z.jsx)(W,{variant:`secondary`,className:`h-[26px] shrink-0 bg-surface-3 hover:bg-surface-4`,asChild:!0,children:(0,Z.jsx)(r,{to:`/settings`,search:{tab:`sources`},"data-testid":`impact-connect`,children:`Connect Prometheus`})}):e.linkOut?(0,Z.jsx)(W,{variant:`secondary`,className:`h-[26px] shrink-0 bg-surface-3 hover:bg-surface-4`,asChild:!0,children:(0,Z.jsx)(`a`,{href:e.linkOut,target:`_blank`,rel:`noreferrer`,children:`Open the query`})}):null]})}function Xt(e,t){return n=>{let r=e.current;switch(n){case`copy`:r&&e.copy(r,t.commandRef.current);return;case`applied`:r&&e.apply(r);return;case`check`:r&&e.check(r);return;case`next-option`:e.nextOption();return;case`resolve`:e.record.openClose();return;case`resume`:t.resume();return;case`retry`:case`investigate`:t.investigate();return;case`ask`:t.ask();return;case`watch`:t.watch();return;case`services`:t.services?.();return}}}function Zt(e){let t=Math.floor(e/60);if(t<60)return Q(Math.max(1,t),`minute`);let n=Math.floor(t/60);return n<24?Q(n,`hour`):Q(Math.floor(n/24),`day`)}function Q(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function Qt(e){let t=[],n=e.alerts.filter(e=>i(e.status)).length,r=e.services.length>0?` on ${e.services.join(`, `)}`:``;if(e.alerts.length===0)t.push(`No alerts are correlated.`);else{let i=Math.min(...e.alerts.map(e=>Date.parse(e.triggeredAt))),a=Zt((e.now-i)/1e3),o=e.alerts.length;t.push(e.alerts.every(me)?o===1?`A webhook event arrived${r} ${a} ago.`:`${o} webhook events arrived${r}, the first ${a} ago.`:n>0?`${n} of ${Q(e.alerts.length,`alert`)} firing${r}, the first ${a} ago.`:`${Q(e.alerts.length,`alert`)}${r}, none firing now.`)}let a=e.runs[0],o=a?u(a.status,{hasEvents:!0}):null,s=null;if(!a)t.push(`No investigation yet.`);else if(o===`starting`||o===`working`||o===`stopping`)t.push(e.waiting?`An investigation waits for your approval.`:e.step?`An investigation is working now: ${e.step}.`:`An investigation is working now.`);else if(o===`done`)t.push(a.rootCause?`The last investigation concluded: ${a.rootCause}`:`The last investigation finished without naming a root cause.`);else if(o===`stopped`)t.push(`The last investigation was stopped.`);else if(a.endReason===`interrupted`){let e=N(a.error);t.push(e?`The last investigation was interrupted when PrismaLens restarted, and not resumed: ${e}`:`The last investigation was interrupted when PrismaLens restarted.`)}else{let n=0;for(;n<e.runs.length&&u(e.runs[n]?.status??``,{hasEvents:!0})===`failed`;)n++;s=M(a.error),t.push(`${n>1?`${n} investigations in a row failed`:`The last investigation failed`}: ${s.what.replace(/^The /,`the `)}`)}return e.noRepo&&t.push(`No repository is linked, so the agent read no code.`),{lines:t,next:e.ended?null:e.attention===`unacknowledged`?{kind:`acknowledge`,text:`Acknowledge it so others know it is taken.`}:e.noRepo?{kind:`link-repo`,text:`Link the service's repository, then investigate.`}:s?{kind:`investigate`,text:s.next??`Try again.`}:e.attention===`awaiting_close`?{kind:`close`,text:`Its alerts cleared. Resolve it, with the cause if you know it.`}:o===`done`?{kind:`resolve`,text:`Read the report, then resolve.`}:a?null:{kind:`investigate`,text:`Start an investigation.`}}}var $t={accent:`bg-accent/12`,plain:`bg-surface-2`,live:`bg-live/10`,warn:`bg-warn/10`,ok:`bg-ok/10`,danger:`bg-danger/12`},en={accent:`bg-accent`,plain:`bg-text-3`,live:`bg-live breathe`,warn:`bg-warn`,ok:`bg-ok`,danger:`bg-danger`};function tn({o:e,onAction:t,canStart:n=!0,compact:i=!1,watching:o=!1,omit:s=[],limited:c=!1}){let{incident:l,runs:u}=e.record,f=q(3e4)??Date.now(),[p,m]=(0,X.useState)(!1),h=z(),g=e.report,_=!!e.live&&(e.latestRun.awaiting||!!e.live.awaitingApprovalAt),v=g?.summary??Qt({now:f,alerts:l.alerts??[],services:Ke(l).map(e=>e.name),runs:u,noRepo:!1,attention:pe(l),ended:a(l.status),waiting:_}).lines.join(` `),y=Pe(l,f),b=Ke(l).map(e=>e.name),x=b.length>0||(l.alerts??[]).length>0?{services:b.join(`, `)||`No service`,firing:Ue(l.alerts??[],f)}:null,S=[];y===`worse`?S.push({k:`Alert trend`,v:`Getting worse`,tone:`text-danger`}):y===`steady`?S.push({k:`Alert trend`,v:`Steady`}):y===`clear`&&S.push({k:`Alert trend`,v:`Recovered`,tone:`text-ok`});let ee=tt(l.actualCauseCategory,g?.rootCauseCategory);ee&&S.push({k:`Cause`,v:d[ee]}),g?.culprit?.changeRef&&S.push({k:`Change`,v:g.culprit.changeRef}),g?.culprit?.mechanism&&S.push({k:`Mechanism`,v:g.culprit.mechanism});let C=e.latest,te=e.latestRun.state,w=h.data?.harnesses.find(e=>e.id===C?.harness),ne=Qe(C,te,C?J(u,C):``,w?.label,w?.loginHint),T=at({lastingFix:g?.nextSteps?.find(e=>e.kind===`lasting`)?.title,ended:l.status===`closed`,cause:l.actualCause,mergedInto:l.mergedInto,refiredAs:l.refiredAs,cleared:e.cleared,alertsCleared:l.status===`resolved`,runs:u.filter(e=>e.kind!==`chat`).length,noService:Ke(l).length===0,live:e.live?{name:J(u,e.live),waiting:_}:null,failed:ne.failed,interrupted:ne.interrupted,reported:!!g,option:e.current,stage:e.stage,checkable:e.checkable,hasNextOption:e.others.length>0,unit:e.impact.impact?.metric?.unit,threshold:e.impact.impact?.metric?.threshold,flagged:e.flagged}),E=o?[...s,`watch`]:s;T.primary&&E.includes(T.primary.id)&&(T.primary=void 0),T.secondary&&E.includes(T.secondary.id)&&(T.secondary=void 0);let D=o&&!T.primary&&!T.secondary;return(0,Z.jsxs)(`section`,{"aria-label":`Situation`,className:`flex min-w-0 shrink-0 flex-col overflow-hidden rounded-pool bg-surface-1`,"data-testid":`situation`,children:[i&&x&&(0,Z.jsxs)(`p`,{className:`flex min-w-0 flex-wrap items-center gap-x-1.5 px-4 pt-2.5 text-meta text-text-3`,"data-testid":`situation-where`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:x.services}),x.firing&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Z.jsx)(`span`,{className:x.firing.firing?`text-danger`:`text-ok`,children:x.firing.firing?`Alert still firing`:`Alert cleared`})]}),c&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Z.jsx)(`span`,{className:`text-warn`,"data-testid":`situation-limited`,children:`From code only; alerts and metrics not read`})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-x-6 gap-y-2 px-4 pt-3 pb-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>m(e=>!e),"aria-expanded":p,className:B(`min-h-6 min-w-0 flex-[1_1_360px] text-left text-[15px] leading-[22px] font-medium`,!p&&(i?`line-clamp-2`:`line-clamp-3`),!g&&`text-text-2`),dir:`auto`,"data-testid":`situation-brief`,children:nn(v)}),S.length>0&&(0,Z.jsx)(`dl`,{className:B(`flex min-w-0 shrink flex-wrap justify-end gap-x-6 gap-y-1`,i&&`max-sm:hidden`),"data-testid":`situation-facts`,children:S.slice(0,4).map(e=>(0,Z.jsxs)(`div`,{className:`flex max-w-[180px] min-w-0 flex-col`,children:[(0,Z.jsx)(`dt`,{className:`text-meta text-text-3`,children:e.k}),(0,Z.jsx)(R,{label:e.v,children:(0,Z.jsx)(`dd`,{className:B(`truncate font-medium`,e.tone),children:e.v})})]},e.k))})]}),!i&&(0,Z.jsx)(rn,{deps:e.dependencies}),!D&&(0,Z.jsxs)(`div`,{className:B(`flex min-h-11 items-center gap-2.5 py-2 pr-3 pl-4`,$t[T.tone]),"data-testid":`next-strip`,"data-tone":T.tone,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-meta font-medium text-text-3`,children:`Next`}),(0,Z.jsx)(`span`,{"aria-hidden":!0,className:B(`size-1.5 shrink-0 rounded-full`,en[T.tone])}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 text-text-1`,dir:`auto`,"aria-live":`polite`,"data-testid":`next-text`,children:[T.text,T.link&&(0,Z.jsxs)(Z.Fragment,{children:[` `,(0,Z.jsx)(r,{to:`/incidents/$id`,params:{id:T.link.incidentId},className:`font-medium underline-offset-2 hover:underline`,"data-testid":`next-refire`,children:T.link.label})]})]}),T.secondary&&(0,Z.jsx)(W,{variant:`secondary`,className:`h-7 shrink-0 bg-surface-3 hover:bg-surface-4`,onClick:()=>T.secondary&&t(T.secondary.id),disabled:e.busy||st(T.secondary.id)&&!n,"data-testid":`next-${T.secondary.id}`,children:T.secondary.label}),T.primary&&(0,Z.jsx)(W,{className:`h-7 shrink-0`,onClick:()=>T.primary&&t(T.primary.id),disabled:e.busy||st(T.primary.id)&&!n,"data-testid":`next-${T.primary.id}`,children:T.primary.label})]})]})}function nn(e){return e.replace(/```[\s\S]*?```/g,` `).replace(/^#+\s*/gm,``).replace(/\*\*|__|`/g,``).replace(/^\s*[-*]\s+/gm,``).replace(/\s*\n+\s*/g,` `).trim()}function rn({deps:e}){let{incidents:t}=Fe(),n=q(3e4)??Date.now();if(e.length===0)return null;let i=e.slice(0,3),a=e.length-i.length,o=e=>t.some(t=>t.service?.id===e&&[`worse`,`steady`].includes(Pe(t,n))),s=i.filter(e=>o(e.service.id)),c=s.length===0?`${i.length===1?`healthy`:i.length===2?`both healthy`:`all healthy`} at ${I(n)}.`:`${s.map(e=>e.service.displayName||e.service.name).join(` and `)} ${s.length===1?`has`:`have`} an alert firing.`;return(0,Z.jsxs)(`p`,{className:`flex min-w-0 items-center gap-2 px-4 pb-2.5 text-meta text-text-2`,"data-testid":`situation-depends`,children:[(0,Z.jsx)(pt,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Depends on`,` `,i.map((e,t)=>(0,Z.jsxs)(X.Fragment,{children:[t>0&&(t===i.length-1&&a===0?` and `:`, `),(0,Z.jsx)(r,{to:`/services/$id`,params:{id:e.service.id},className:`text-text-1 underline-offset-2 hover:underline`,children:e.service.displayName||e.service.name}),` `,`(`,p[e.service.type].toLowerCase(),`)`]},e.service.id)),a>0&&` and ${a} more`,`, `,c]})]})}var an={ready:{text:`Not applied`,tone:`text-text-3`},applied:{text:`You applied this`,tone:`text-text-2`},checking:{text:`Checking`,tone:`text-live`},checked:{text:``,tone:``},"checked-not_yet":{text:`Not working yet`,tone:`text-warn`},"checked-below_threshold":{text:`Below the threshold`,tone:`text-text-2`},"checked-could_not_check":{text:`Could not check`,tone:`text-warn`},"checked-it_worked":{text:`Worked`,tone:`text-ok`},worked:{text:`Worked`,tone:`text-ok`}};function on(e){return e.stage===`checked`?an[`checked-${e.check.verdict}`]:an[e.stage]}function sn({o:e,commandRef:t}){let{incident:n}=e.record,r=e.current,i=e.flagged,a=e.report&&r?`Undo what hurts users; fix the cause after.`:null;return(0,Z.jsx)(xt,{title:`Stop the impact`,id:`stop-the-impact`,sub:a&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-meta text-text-3`,children:a}),testId:`stop-impact-card`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r&&e.stage?(0,Z.jsx)(ln,{o:e,option:r,stage:e.stage,flagged:i,commandRef:t}):e.report?(0,Z.jsx)(`p`,{className:`py-2 text-text-2`,"data-testid":`fix-empty`,children:`The report suggests no mitigation.`}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 py-2`,"data-testid":`fix-none`,children:[(0,Z.jsx)(`p`,{className:`text-text-2`,children:`No options yet. No run has reached a finding.`}),e.changes?.deploy&&(0,Z.jsxs)(`p`,{className:`text-text-3`,children:[kt(e.changes.deploy),` shipped`,` `,At(e.changes.deploy.at,n.createdAt,(n.alerts??[]).length>0),`.`]})]}),(0,Z.jsx)(un,{o:e}),e.others.map(t=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>e.pickOption(t),className:`flex min-w-0 flex-col rounded-surface bg-surface-2 px-3 py-2 text-left transition-colors duration-(--dur-instant) hover:bg-surface-3`,"data-row":t.title,"data-testid":`fix-other`,children:[(0,Z.jsx)(`span`,{className:`truncate`,dir:`auto`,children:t.title}),(0,Z.jsx)(`span`,{className:`truncate text-meta text-text-3`,dir:`auto`,children:cn(e,t)})]},t.id??t.title))]})})}function cn(e,t){let n=e.stageOf(t);return n.stage===`ready`?t.facts[0]??t.detail:`Applied at ${I(n.appliedAt)}. ${on(n).text}.`}function ln({o:e,option:t,stage:n,flagged:r,commandRef:i}){let[a,o]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!a)return;let e=window.setTimeout(()=>o(!1),1500);return()=>window.clearTimeout(e)},[a]);let s=on(n),c=t.canUndo&&n.stage===`applied`,l=it(t),u=Ye(t);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-surface bg-surface-2 p-3`,"data-row":t.title,"data-testid":`fix-card`,"data-stage":n.stage,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2.5`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-title`,dir:`auto`,"data-testid":`fix-title`,children:t.title}),(0,Z.jsx)(`span`,{className:B(`shrink-0 text-meta font-medium`,s.tone),"data-testid":`fix-state`,children:s.text}),c&&(0,Z.jsx)(W,{variant:`secondary`,className:`h-[22px] shrink-0 rounded-[4px] bg-surface-3 px-2 text-meta hover:bg-surface-4`,onClick:()=>e.undo(t),disabled:e.busy,"data-testid":`fix-undo`,children:`Undo`})]}),l?(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5`,children:[(0,Z.jsx)(`code`,{ref:i,tabIndex:0,className:`min-w-0 flex-1 rounded-control bg-canvas px-2.5 py-2 font-mono text-mono break-all whitespace-pre-wrap text-text-1 select-all`,"data-testid":`fix-command`,children:l}),(0,Z.jsxs)(W,{variant:`secondary`,className:`h-8 shrink-0 gap-1.5 bg-surface-3 hover:bg-surface-4`,"aria-label":`Copy command`,onClick:async()=>{await e.copy(t,i.current)&&o(!0)},"data-testid":`fix-copy`,children:[(0,Z.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{"aria-live":`polite`,children:a?`Copied`:`Copy`})]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-text-2`,dir:`auto`,children:t.detail}),u&&u!==t.detail&&(0,Z.jsx)(`p`,{className:`text-text-2`,dir:`auto`,"data-testid":`fix-note`,children:u})]}),t.facts.length>0&&(0,Z.jsx)(`ul`,{className:`list-disc pl-4 text-text-2`,"data-testid":`fix-facts`,children:t.facts.map(e=>(0,Z.jsx)(`li`,{dir:`auto`,children:e},e))}),r&&l&&(0,Z.jsxs)(`p`,{className:`flex gap-1.5 text-meta text-warn`,"data-testid":`fix-flagged`,children:[(0,Z.jsx)(k,{className:`mt-0.5 size-3 shrink-0`,"aria-hidden":!0}),`The agent flagged text that tried to instruct it while it worked. Read this command before you run it.`]}),t.readOnly&&(0,Z.jsx)(`p`,{className:`text-meta text-text-3`,children:`From a report written before fixes could be marked applied.`})]})}function un({o:e}){let t=q(3e4),{incident:n}=e.record,i=e.ask;if(!i)return null;let a=e.askRun.state,o=a===`starting`||a===`working`,s=e.askRun.latestText,c=e.earlierAsks[0];return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5 rounded-surface bg-surface-2 px-3 py-2`,"data-row":`Your question`,"data-testid":`you-asked`,children:[(0,Z.jsxs)(`span`,{className:`text-meta text-text-3`,children:[`You asked `,Ne(i.startedAt??i.createdAt,t)]}),(0,Z.jsx)(r,{to:`/incidents/$id/conversation`,params:{id:n.id},search:{investigation:i.id},className:`font-medium hover:text-accent`,dir:`auto`,"data-testid":`you-asked-question`,children:i.title??`Your question`}),o?(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 text-text-2`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`breathe size-1.5 rounded-full bg-live`}),`Answering.`,(0,Z.jsx)(r,{to:`/incidents/$id/conversation`,params:{id:n.id},search:{investigation:i.id},className:`text-accent hover:underline`,children:`Open the conversation`})]}):a===`failed`?(0,Z.jsx)(`span`,{className:`text-danger`,children:`The answer did not finish.`}):s?(0,Z.jsx)(`span`,{dir:`auto`,className:`text-text-1`,children:s}):null,c&&(0,Z.jsx)(r,{to:`/incidents/$id/conversation`,params:{id:n.id},search:{investigation:c.id},className:`truncate text-meta text-accent underline underline-offset-2`,"data-testid":`you-asked-earlier`,children:e.earlierAsks.length===1?`1 earlier question${c.title?`: ${c.title}`:``}`:`${e.earlierAsks.length} earlier questions`})]})}async function dn(e,t){try{if(!navigator.clipboard)throw Error(`no clipboard`);return await navigator.clipboard.writeText(e),!0}catch{if(t){let e=document.createRange();e.selectNodeContents(t);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(e),t.focus()}return!1}}var fn=1e4,$=e=>e.id??`#${e.index}`;function pn(){let e=Ge(),{incident:t,runs:n}=e,r=f(),{toast:a}=K(),o=We(n),s=Le(o?.id??null),c=s.investigation?.report??null,u=m({...g.fixes.forInvestigation.queryOptions({input:{id:o?.id??``}}),enabled:!!o}),d=(0,X.useMemo)(()=>$e(u.data),[u.data]),p=n.find(e=>e.kind===`chat`)??null,h=Le(p?.id??null),v=n.filter(e=>e.kind===`chat`).slice(1),x=n.find(e=>e.kind!==`chat`)??null,S=Le(x&&x.id!==o?.id?x.id:null),ee=x&&x.id===o?.id?s:S,C=x?Be(x):null,te=x&&C&&l(C)?x:null,w=m({...g.impact.forIncident.queryOptions({input:{id:t.id}}),retry:!1,refetchOnWindowFocus:!1,staleTime:6e4}),[ne,T]=(0,X.useState)(!1),E=w.isFetching;(0,X.useEffect)(()=>{if(T(!1),!E)return;let e=window.setTimeout(()=>T(!0),fn);return()=>window.clearTimeout(e)},[E]);let D=w.data??null,re=D?.checkable??!1,[O,ie]=(0,X.useState)(!1),ae=m({...g.changes.forIncident.queryOptions({input:{id:t.id,limit:O?200:6}}),placeholderData:e=>e,refetchInterval:e=>e.state.data?.refreshing?3e3:!1}),k=t.service?.id,oe=m({...g.services.getTopology.queryOptions({input:{id:k??``}}),enabled:!!k}),[se,A]=(0,X.useState)(0),[j,M]=(0,X.useState)({}),[N,P]=(0,X.useState)({}),[F,I]=(0,X.useState)({}),L=d.stop[Math.min(se,d.stop.length-1)]??null,R=d.stop.filter(e=>e!==L),z=t.alerts??[],ue=e=>{let t=$(e);return Je({option:e,copied:!!j[t],copyFailed:j[t]===`failed`,checking:!!N[t],check:F[t]??null,alerts:z})},de=()=>Promise.all([r.invalidateQueries({queryKey:g.fixes.forInvestigation.key()}),r.invalidateQueries({queryKey:le.all()}),r.invalidateQueries({queryKey:ce.all()})]),fe=e=>t=>a({title:e,description:y(t),variant:`destructive`}),B=_({mutationFn:e=>e.id?b.fixes.apply({id:e.id}):Promise.resolve(null),onSettled:de,onError:fe(`Not recorded`)}),pe=_({mutationFn:e=>e.id?b.fixes.undo({id:e.id}):Promise.resolve(null),onSettled:de,onError:fe(`Not undone`)}),V=async e=>{if(!e.id)return;let t=$(e);P(e=>({...e,[t]:!0}));try{let n=await b.fixes.check({id:e.id});I(e=>({...e,[t]:nt(n)}))}catch{I(e=>({...e,[t]:{verdict:`could_not_check`,at:new Date().toISOString(),retryable:!0}}))}finally{P(e=>({...e,[t]:!1})),de()}},me=(0,X.useRef)(new Set),H=(0,X.useRef)(V);H.current=V;let U=L?ue(L):null,W=U?.stage===`applied`&&re?Date.parse(U.appliedAt)+ot:null;return(0,X.useEffect)(()=>{if(W===null||!L)return;let e=$(L);if(me.current.has(e))return;let t=window.setTimeout(()=>{me.current.add(e),H.current(L)},Math.max(0,W-Date.now()));return()=>window.clearTimeout(t)},[W,L]),{record:e,report:c,reported:o,reportInvestigation:s.investigation,flagged:u.data?.flagged??(c?.flaggedContent?.length??0)>0,options:d,current:L,others:R,stage:U,stageOf:ue,nextOption:()=>A(e=>(e+1)%Math.max(1,d.stop.length)),pickOption:e=>A(d.stop.indexOf(e)),copy:async(e,t)=>{let n=it(e);if(!n)return!1;let r=await dn(n,t);return M(t=>({...t,[$(e)]:r?`ok`:`failed`})),r},apply:e=>B.mutate(e),undo:e=>pe.mutate(e),check:V,busy:B.isPending||pe.isPending,ask:p,askRun:h,earlierAsks:v,latest:x,latestRun:ee,live:te,impact:{impact:D,pending:w.isPending,slow:ne&&w.isFetching&&!D,failed:w.error?y(w.error):null,firing:z.filter(e=>i(e.status)).length,retry:()=>void w.refetch()},checkable:re,changes:ae.data,allChanges:O,setAllChanges:ie,dependencies:oe.data?.upstream??[],cleared:z.length>0&&!z.some(e=>i(e.status))}}var mn=e=>e&&e.state!==`unavailable`?e:null;function hn(e){let t=mn(e);if(!t)return`No snapshot`;let n=_n(gn(t.sources));return t.state===`not-saved`?`${n}, not saved`:n}function gn(e){let t=t=>e.filter(e=>e.status===t).length,n=t(`found`),r=t(`empty`);return{found:n,empty:r,skipped:t(`skipped`),notRead:t(`not-read`),read:n+r}}function _n(e){return[`${e.read} read`,...e.skipped?[`${e.skipped} skipped`]:[],...e.notRead?[`${e.notRead} not read`]:[]].join(`, `)}var vn={found:{text:`Data found`,tone:`ok`},empty:{text:`Nothing in the window`,tone:`neutral`},skipped:{text:`Skipped`,tone:`warn`},"not-read":{text:`Not read`,tone:`neutral`}},yn={stored:`Set in PrismaLens`,env:`From environment`,none:`Not set`},bn={found:`bg-ok`,empty:`bg-text-3`,skipped:`bg-warn`,notRead:`bg-[repeating-linear-gradient(135deg,var(--text-3)_0_2px,transparent_2px_5px)]`};function xn({c:e}){return e.found+e.empty+e.skipped+e.notRead?(0,Z.jsx)(`div`,{className:`flex h-2 gap-0.5 overflow-hidden rounded-full`,"aria-hidden":!0,children:[`found`,`empty`,`skipped`,`notRead`].map(t=>e[t]>0&&(0,Z.jsx)(`span`,{className:B(`h-full rounded-full`,bn[t]),style:{flexGrow:e[t]}},t))}):null}var Sn=[{key:`found`,label:`Data found`,Icon:re,tone:`text-ok`},{key:`empty`,label:`Nothing in the window`,Icon:O,tone:`text-text-2`},{key:`skipped`,label:`Skipped`,Icon:dt,tone:`text-warn`},{key:`notRead`,label:`Not read`,Icon:lt,tone:`text-text-2`}];function Cn({preRun:e}){if(e.state===`unavailable`)return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,"data-testid":`coverage-unavailable`,children:[(0,Z.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`b`,{className:`font-semibold`,children:`No snapshot for this run`}),(0,Z.jsx)(E,{word:{text:`No snapshot`,tone:`neutral`}})]}),(0,Z.jsx)(`p`,{className:`text-text-2`,children:`This follow-up has no stored snapshot, so it ran without telemetry.`})]});let t=e.sources,n=gn(t);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-testid":`pre-run-coverage`,children:[e.telemetrySkipped&&(0,Z.jsxs)(`p`,{className:`text-text-2`,"data-testid":`coverage-telemetry-skipped`,children:[`The telemetry read was skipped: `,e.telemetrySkipped]}),e.state===`not-saved`&&(0,Z.jsxs)(`p`,{className:`flex items-start gap-2 rounded-surface bg-warn/10 px-2.5 py-2`,"data-testid":`coverage-not-saved`,children:[(0,Z.jsx)(k,{className:`mt-0.5 size-4 shrink-0 text-warn`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`b`,{className:`font-semibold`,children:`Snapshot not saved.`}),` This run read it; a follow-up will not have it.`]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`p`,{className:`flex items-baseline gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[28px] leading-8 font-semibold tabular-nums`,"data-testid":`coverage-read`,children:n.read}),(0,Z.jsxs)(`span`,{className:`text-title font-normal text-text-2`,children:[n.read===1?`source`:`sources`,` read before the run`]})]}),(0,Z.jsx)(`p`,{className:`sr-only`,"data-testid":`coverage-line`,children:_n(n)}),(n.skipped>0||n.notRead>0)&&(0,Z.jsx)(`p`,{className:`text-text-2`,"aria-hidden":!0,children:[...n.skipped?[`${n.skipped} skipped`]:[],...n.notRead?[`${n.notRead} not read`]:[]].join(` · `)})]}),(0,Z.jsx)(xn,{c:n}),(0,Z.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-meta`,children:Sn.filter(e=>n[e.key]>0).map(({key:e,label:t,Icon:r,tone:i})=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(r,{className:B(`size-3.5`,i),"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`text-text-2`,children:t}),(0,Z.jsx)(`b`,{className:`font-semibold tabular-nums`,children:n[e]})]},e))}),t.length>0&&(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-hairline`,"data-testid":`coverage-sources`,children:t.map((e,t)=>(0,Z.jsx)(wn,{source:e},t))}),(0,Z.jsx)(Tn,{preRun:e})]})}function wn({source:e}){let[t,n]=(0,X.useState)(!1),i=vn[e.status];return(0,Z.jsxs)(`li`,{className:`py-2`,"data-testid":`coverage-source`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,Z.jsx)(se,{kind:e.kind,small:!0}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Z.jsx)(`b`,{className:`font-semibold`,children:e.label}),e.services?.length?(0,Z.jsx)(`span`,{className:`text-text-2`,children:e.services.join(`, `)}):null,(0,Z.jsx)(E,{word:i,testId:`coverage-result`})]}),(0,Z.jsxs)(`p`,{className:`text-meta text-text-2`,dir:`auto`,children:[e.detail,e.truncated?` (truncated)`:``]})]}),e.status===`skipped`&&(0,Z.jsx)(W,{variant:`secondary`,size:`sm`,asChild:!0,children:(0,Z.jsx)(r,{to:`/settings`,search:{tab:`sources`,...e.connectionId?{source:e.connectionId}:{}},"data-testid":`coverage-fix`,children:`Fix`})}),(0,Z.jsx)(W,{variant:`text`,size:`icon-sm`,"aria-expanded":t,"aria-label":`Details of ${e.label}`,onClick:()=>n(!t),children:(0,Z.jsx)(P,{className:B(`size-4`,t&&`rotate-180`),"aria-hidden":!0})})]}),t&&(0,Z.jsxs)(`dl`,{className:`mt-2 ml-8 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-meta`,children:[(0,Z.jsx)(`dt`,{className:`text-text-3`,children:`Connection`}),(0,Z.jsxs)(`dd`,{children:[e.label,` · `,D(e.kind)]}),(0,Z.jsx)(`dt`,{className:`text-text-3`,children:`Deployment`}),(0,Z.jsx)(`dd`,{children:e.deployment??`Any deployment`}),(0,Z.jsx)(`dt`,{className:`text-text-3`,children:`Credential`}),(0,Z.jsxs)(`dd`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(oe,{text:yn[e.credentialFrom??`none`]??`Not set`}),e.overridesEnv&&(0,Z.jsxs)(`span`,{className:`text-text-2`,"data-testid":`coverage-over`,children:[`Over `,(0,Z.jsx)(`code`,{className:`font-mono`,children:e.overridesEnv})]})]})]})]})}function Tn({preRun:e}){let t=e.notConfigured.map(e=>`No ${D(e.kind)} is set up for ${e.services.join(`, `)||`this service`}.`);return t.length?(0,Z.jsx)(`ul`,{className:`text-meta text-text-3`,"data-testid":`coverage-notes`,children:t.map(e=>(0,Z.jsx)(`li`,{children:e},e))}):null}var En={Confirmed:`text-ok`,Likely:`text-accent`,Unconfirmed:`text-warn`,"No cause found":`text-text-3`};function Dn({o:e,onInvestigate:t}){let n=q(3e4),{incident:i,runs:a}=e.record,[o,s]=(0,X.useState)(!1),c=e.report,l=e.reported,u=e.latest,d=u&&e.latestRun.state===`failed`&&u.id!==l?.id?u:null,f=c?_t(c).word:null,p=l??d,m=(l?e.reportInvestigation?.preRun:e.latestRun.investigation?.preRun)??null,h=e=>({to:`/incidents/$id/conversation`,params:{id:i.id},search:{investigation:e}});return(0,Z.jsx)(xt,{title:`Why`,testId:`why-card`,sub:(0,Z.jsxs)(Z.Fragment,{children:[f&&(0,Z.jsx)(`span`,{className:B(`shrink-0 text-meta font-medium`,En[f]),"data-testid":`why-tag`,children:f===`No cause found`?`No cause named`:f}),!f&&d&&(0,Z.jsx)(`span`,{className:`shrink-0 text-meta font-medium text-danger`,"data-testid":`why-tag`,children:`No cause yet`}),l&&(0,Z.jsxs)(`span`,{className:`min-w-0 truncate text-meta text-text-3`,children:[`From `,J(a,l),`,`,` `,Ne(l.completedAt??l.createdAt,n)]})]}),actions:(0,Z.jsxs)(Z.Fragment,{children:[a.length>0&&!e.live&&(0,Z.jsx)(W,{variant:`secondary`,className:`h-6 shrink-0 bg-surface-2 px-2 text-meta hover:bg-surface-3`,onClick:t,"data-testid":`why-investigate`,children:`Investigate again`}),p&&(0,Z.jsxs)(r,{...h(p.id),className:`inline-flex min-h-6 shrink-0 items-center text-meta text-accent hover:underline`,"data-testid":`why-transcript`,children:[J(a,p),` transcript`]})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[e.live&&(0,Z.jsxs)(r,{...h(e.live.id),className:`flex min-w-0 items-center gap-2 rounded-control bg-live/10 px-2.5 py-1.5 whitespace-nowrap transition-colors duration-(--dur-instant) hover:bg-live/15`,"data-testid":`why-live`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`breathe size-1.5 shrink-0 rounded-full bg-live`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[J(a,e.live),` `,e.latestRun.awaiting||e.live.awaitingApprovalAt?`waits for your approval in the box below.`:`is investigating.`,c?` This finding stands until it reports.`:` Its finding lands here when it reports.`]}),(0,Z.jsx)(`span`,{className:`shrink-0 text-meta text-accent`,children:`Watch`})]}),d&&(0,Z.jsx)(On,{o:e,name:J(a,d),standing:!!c}),c?(0,Z.jsx)(kn,{o:e,lasting:o,setLasting:s}):!e.live&&!d?(0,Z.jsx)(`p`,{className:`text-text-3`,"data-testid":`why-none`,children:a.length===0?`No run yet. A run reads the alert, the code and the telemetry, then names a likely cause.`:`No run has reached a finding yet.`}):null,m&&(0,Z.jsx)(`section`,{"aria-label":`Read before the run`,className:`mt-1 rounded-surface bg-surface-2 px-3 py-3`,"data-testid":`why-coverage`,children:(0,Z.jsx)(Cn,{preRun:m})})]})})}function On({o:e,name:t,standing:n}){let r=e.latestRun.investigation,i=(0,X.useMemo)(()=>Ie(e.latestRun.events,{cwd:r?.workspace?.cwd,ended:!0}),[e.latestRun.events,r?.workspace?.cwd]),a=r?.error??e.latest?.error??null,o=He(`The agent`,a),s=z().data?.harnesses.find(t=>t.id===e.latest?.harness),c=M(a,s?.label,s?.loginHint),l=(r?.endReason??e.latest?.endReason)===`interrupted`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`rounded-surface bg-danger/12 px-3 py-2.5`,"data-row":`What failed`,"data-testid":`why-failed`,children:[(0,Z.jsxs)(`div`,{className:`font-semibold text-danger`,children:[l?`${t} was interrupted when PrismaLens restarted`:`${t} stopped before a finding`,n?`; the finding below stands`:``]}),(0,Z.jsx)(`div`,{className:`text-text-1`,children:l?N(a)??`Its last command may or may not have completed.`:c.next?`${c.what} ${c.next}`:o.said})]}),!n&&i.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-meta text-text-3`,children:`Its last steps`}),(0,Z.jsx)(`ol`,{className:`flex flex-col`,children:i.slice(-3).map(e=>(0,Z.jsxs)(`li`,{className:`flex gap-2.5 px-1 py-1.5 shadow-[inset_0_-1px_0_var(--hairline)]`,"data-row":e.title,children:[(0,Z.jsx)(`span`,{className:`w-16 shrink-0 text-meta text-text-3 tabular-nums`,children:I(e.at)}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-text-2`,children:e.title})]},e.n))})]})]})}function kn({o:e,lasting:t,setLasting:n}){let i=e.report,{incident:a}=e.record;if(!i||!e.reported)return null;let o=e.reportInvestigation?.workspace?.cwd,s=i.hypotheses.find(e=>e.status!==`refuted`)?.evidence??[],c=i.ruledOut.length,l=i.coverage.notQueried.length,u=e.options.lasting,d=e.reported.id;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`line-clamp-3 text-[15px] leading-[22px]`,dir:`auto`,"data-testid":`why-cause`,children:nn(i.rootCause??i.summary)}),s.length===0?(0,Z.jsx)(`p`,{className:`text-text-3`,children:`No evidence recorded for this conclusion.`}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1`,"data-testid":`why-evidence`,children:s.map((t,n)=>{let i=A(t.source,o);return(0,Z.jsx)(`li`,{"data-row":`Evidence`,children:(0,Z.jsx)(R,{label:t.observation,children:(0,Z.jsxs)(r,{to:`/incidents/$id/conversation`,params:{id:a.id},search:{investigation:d,...t.toolCallId?{call:t.toolCallId}:{},...je(t.source,e.reportInvestigation?.workspace)?{file:t.source}:{}},className:`flex min-w-0 items-baseline gap-2.5 rounded-control bg-surface-2 px-2.5 py-1.5 transition-colors duration-(--dur-instant) hover:bg-surface-3`,"data-testid":`why-evidence-row`,children:[(0,Z.jsx)(`span`,{className:`w-[52px] shrink-0 text-meta text-text-3`,children:t.direction===`supports`?`For`:`Against`}),(0,Z.jsx)(`span`,{className:`line-clamp-2 min-w-0 flex-1`,dir:`auto`,children:nn(t.observation)}),(0,Z.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate font-mono text-mono text-text-3`,children:i})]})})},n)})}),t&&u&&(0,Z.jsxs)(`div`,{id:`lasting-fix`,className:`rounded-control bg-surface-2 px-2.5 py-2`,"data-row":`Lasting fix`,"data-testid":`why-lasting`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,dir:`auto`,children:u.title}),(0,Z.jsx)(`p`,{className:`text-text-2`,dir:`auto`,children:nn(u.detail)}),it(u)?(0,Z.jsx)(`code`,{className:`mt-1 block font-mono text-mono break-all whitespace-pre-wrap text-text-1`,children:it(u)}):Ye(u)&&(0,Z.jsx)(`p`,{className:`text-text-2`,dir:`auto`,children:Ye(u)})]}),(0,Z.jsxs)(`div`,{className:`flex gap-4.5 text-meta whitespace-nowrap`,children:[(0,Z.jsx)(r,{to:`/incidents/$id/conversation`,params:{id:a.id},search:{investigation:d},className:`inline-flex min-h-6 items-center text-text-2 hover:underline`,"data-testid":`why-ruled-out`,children:c===0?`Nothing ruled out`:`${c} ruled out`}),l>0&&(0,Z.jsx)(r,{to:`/incidents/$id/conversation`,params:{id:a.id},search:{investigation:d},className:`inline-flex min-h-6 min-w-0 items-center text-warn hover:underline`,title:i.coverage.notQueried.join(`, `),"data-testid":`why-unchecked`,children:(0,Z.jsxs)(`span`,{className:`truncate`,children:[`Not checked: `,i.coverage.notQueried[0],l>1&&` and ${l-1} more`]})}),(0,Z.jsx)(`span`,{className:`flex-1`}),u&&(0,Z.jsx)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":`lasting-fix`,onClick:()=>{n(!t),window.setTimeout(()=>document.getElementById(`lasting-fix`)?.scrollIntoView({block:`nearest`,behavior:`smooth`}),50)},className:`text-accent hover:underline`,"data-testid":`why-lasting-toggle`,children:`Lasting fix`})]})]})}function An(e,t,n=`text/markdown;charset=utf-8`){let r=URL.createObjectURL(new Blob([t],{type:n})),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),URL.revokeObjectURL(r)}function jn({open:e,onOpenChange:t}){let n=Ge(),{toast:r}=K(),[i,a]=(0,X.useState)(``);return(0,Z.jsx)(be,{open:e,onOpenChange:t,children:(0,Z.jsxs)(_e,{"data-testid":`note-dialog`,children:[(0,Z.jsxs)(he,{children:[(0,Z.jsx)(ve,{children:`Add a note`}),(0,Z.jsx)(ye,{children:`It goes on the incident's timeline. The agent doesn't get it as a message.`})]}),(0,Z.jsx)(j,{value:i,onChange:e=>a(e.target.value),rows:4,"aria-label":`Note`,"data-testid":`note-text`}),(0,Z.jsxs)(ge,{children:[(0,Z.jsx)(W,{variant:`text`,onClick:()=>t(!1),children:`Cancel`}),(0,Z.jsx)(W,{onClick:()=>n.addNote(i.trim(),()=>{a(``),t(!1)},e=>r({title:`Note not saved`,description:y(e),variant:`destructive`})),disabled:!i.trim()||n.isSavingNote,"data-testid":`note-save`,children:`Add note`})]})]})})}function Mn(e,t){let n=e.service?`, ${e.service.displayName||e.service.name}`:``,r=[`INC-${e.number} ${e.title}${n}. Severity ${c[e.severity]}.`];if(e.mergedInto)r.push(`Merged into INC-${e.mergedInto.number}.`);else if(e.status===`closed`)r.push(`Resolved.`);else if(e.status===`resolved`)r.push(`Alerts cleared.`);else{let n=Ue(e.alerts??[],t);n&&r.push(`${n.text}.`)}let i=(e.investigations??[]).filter(e=>(e.kind??`investigation`)===`investigation`),a=e.actualCause??(e=>e.reduce((e,t)=>!e||t.createdAt>e.createdAt?t:e,null))(i.filter(e=>e.rootCause))?.rootCause;return a?r.push(`${e.actualCause?`Cause`:`Likely cause`}: ${a}`):i.some(e=>x(e.status))?r.push(`An investigation is running; no cause yet.`):r.push(`No cause found yet.`),r.join(`
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-Wy9s6hX0.js";import{t as r}from"./link-BHh9_evg.js";import{F as i,I as a,L as o,M as s,Q as c,R as l,U as u,X as d,Xt as f,Z as p,_t as m,a as h,c as g,gt as _,q as v,r as y,s as b,z as x}from"./desktop-yb-lqHMd.js";import{n as S}from"./useNavigate-I5E4IRt2.js";import{A as ee,F as C,M as te,N as w,O as ne,P as T,a as E,f as D,gt as re,ht as O,j as ie,k as ae,lt as k,n as oe,r as se,rt as A,v as j}from"./source-words-CCeTLwOy.js";import{W as M}from"./AgentDetail-CbhnttdO.js";import{n as N}from"./restart-FIcq7DzH.js";import{$ as P,F as ce,J as F,K as I,X as L,r as le,t as R,u as z}from"./Hint-Od6cnmvm.js";import{t as ue}from"./chevron-left-S6eOHk4C.js";import{t as de}from"./copy-_5FNPl7W.js";import{t as fe}from"./ellipsis-BsNLvnl9.js";import{t as B}from"./utils-A3okWeke.js";import{n as pe,t as V}from"./MergeDialog-82IoAwUo.js";import{n as me,r as H}from"./trigger-DVo1oKMX.js";import{n as U,t as W}from"./button-DmIfWVZ8.js";import{C as he,S as ge,b as _e,w as ve,x as ye,y as be}from"./use-repositories-orpc-Ban_zGD7.js";import{a as xe,c as Se,d as Ce,l as we,n as Te,o as Ee,r as G,t as De,u as Oe}from"./dropdown-menu-yoILSLgJ.js";import{n as K}from"./CopyButton-DKP5JHET.js";import{o as ke}from"./State-CCKzehkH.js";import{t as Ae}from"./use-page-title-DEIRQICr.js";import{n as je}from"./evidence-files-C_a9Ct8m.js";import{I as Me,R as Ne,ht as Pe,lt as Fe,z as q}from"./index-BoI68UdU.js";import{i as Ie,n as Le}from"./useInvestigationRun-BJKQxOF2.js";import{a as Re,c as ze,f as J,i as Be,n as Ve,p as He,r as Ue}from"./run-labels-BLTL5eG9.js";import{n as We,r as Ge}from"./record-context-CoIOStXx.js";import{n as Ke}from"./service-lanes-BfHIrySn.js";import{t as qe}from"./use-escape-back-CK0fWxlL.js";import{a as Je,c as Ye,d as Xe,f as Y,h as Ze,i as Qe,l as $e,m as et,n as tt,o as nt,p as rt,r as it,s as at,t as ot,u as st}from"./fixes-BWFKY2Zx.js";var ct={name:`circle-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.35 2.69A10 10 0 0 1 21.3 15.65`,key:`1pfsoa`}],[`path`,{d:`M19.08 19.08A10 10 0 1 1 4.92 4.92`,key:`1ablyi`}]]};ct.node;var lt=h(ct),ut={name:`circle-pause`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]],aliases:[`pause-circle`]};ut.node;var dt=h(ut),ft={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};ft.node;var pt=h(ft),mt={name:`git-commit-horizontal`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]],aliases:[`git-commit`]};mt.node;var ht=h(mt),X=e(t(),1),Z=n(),gt={Confirmed:`done`,Likely:`accent`,Unconfirmed:`stale`,"No cause found":`neutral`};function _t(e){let t=e.hypotheses.find(e=>e.status!==`refuted`);if(!e.rootCause){let t=e.hypotheses.filter(e=>e.status===`supported`||e.status===`confirmed`).length;return{word:`No cause found`,tone:gt[`No cause found`],basis:t===0?`nothing it found is supported`:`${t===1?`one finding is`:`${t} findings are`} supported, but not as a cause`}}let n=t?.status===`confirmed`?`Confirmed`:t?.status===`supported`?`Likely`:`Unconfirmed`,r=t?.evidence??[],i=r.filter(e=>e.direction===`supports`).length,a=r.filter(e=>e.direction===`contradicts`).length,o=i===1?`one piece`:`${i} pieces`;return{word:n,tone:gt[n],basis:i===0?`no evidence for it was recorded`:`${o} of evidence for it, ${a===0?`none`:a} against`}}function vt(e,t){return e.draft?t.alertCount>0&&!t.reported?`investigate`:`ask`:`investigate`}var yt=1500;function bt(e,t,n){let r=n.trim();if(r)return r;let i=e.nextSteps.map(e=>e.title).join(`; `),a=`Re-check Run #${t}. It found: ${e.summary.replace(/\.$/,``)}. Cause named: ${e.rootCause?.replace(/\.$/,``)||`none`}. Next steps it proposed: ${i||`none`}.`;return a.length>yt?`${a.slice(0,1499)}…`:a}function xt({title:e,sub:t,actions:n,children:r,testId:i,className:a,id:o}){let s=(0,X.useId)();return(0,Z.jsxs)(`section`,{id:o,"aria-labelledby":s,className:B(`flex min-h-0 min-w-0 flex-col gap-2.5 rounded-pool bg-surface-1 px-4 pt-3.5 pb-3`,a),"data-testid":i,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-baseline gap-3 whitespace-nowrap max-md:flex-wrap max-md:gap-y-1.5`,children:[(0,Z.jsx)(`h2`,{id:s,className:`shrink-0 text-heading`,children:e}),t,(0,Z.jsx)(`span`,{className:`flex-1`}),n]}),(0,Z.jsx)(Tt,{children:r})]})}function St(e){let t=e.scrollHeight-e.clientHeight>2,n=e.scrollTop+e.clientHeight,r=e.scrollHeight-n<=2;if(!t||r)return{overflows:t,rows:0,next:``,atEnd:r};let i=e.getBoundingClientRect().top-e.scrollTop,a=0,o=``;for(let t of Array.from(e.querySelectorAll(`[data-row]`)))if(t.getBoundingClientRect().bottom-i>n+2){a++;let e=t.dataset.row;o||=e&&e!==`true`?e:``}return{overflows:t,rows:a,next:o,atEnd:r}}function Ct(e){if(e.length<=28)return e;let t=e.slice(0,28);return`${t.slice(0,Math.max(t.lastIndexOf(` `),16))}…`}var wt=(e,t)=>e.overflows===t.overflows&&e.rows===t.rows&&e.next===t.next&&e.atEnd===t.atEnd;function Tt({children:e,className:t}){let n=(0,X.useRef)(null),[r,i]=(0,X.useState)({overflows:!1,rows:0,next:``,atEnd:!0}),a=(0,X.useCallback)(()=>{let e=n.current;if(!e)return;let t=St(e);i(e=>wt(e,t)?e:t)},[]);return(0,X.useEffect)(()=>{let e=n.current;if(!e)return;a();let t=new ResizeObserver(a);t.observe(e);let r=new MutationObserver(a);r.observe(e,{childList:!0,subtree:!0,characterData:!0});for(let n of Array.from(e.children))t.observe(n);return()=>{t.disconnect(),r.disconnect()}},[a]),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsx)(`div`,{ref:n,onScroll:a,className:B(`min-h-0 flex-1 overflow-y-auto overscroll-contain [scrollbar-width:thin]`,r.overflows&&!r.atEnd&&`[mask-image:linear-gradient(to_bottom,black_calc(100%-28px),transparent)]`,t),"data-testid":`card-body`,children:e}),r.overflows&&(0,Z.jsx)(`div`,{className:`flex h-6 shrink-0 items-end justify-end`,children:(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{let e=n.current;e&&(r.atEnd?e.scrollTo({top:0,behavior:`smooth`}):e.scrollBy({top:e.clientHeight*.8,behavior:`smooth`}))},className:`flex min-h-6 items-center gap-1 rounded-control px-1.5 text-meta text-accent transition-colors duration-(--dur-instant) hover:bg-surface-3`,"data-testid":`card-more`,children:[r.atEnd?`Back to top`:r.next?`${Ct(r.next)}${r.rows>1?` and ${r.rows-1} more`:``} below`:r.rows>0?`${r.rows} more below`:`More below`,(0,Z.jsx)(P,{className:B(`size-3`,r.atEnd&&`rotate-180`),"aria-hidden":!0})]})})]})}var Et=e=>typeof e==`string`&&Object.hasOwn(v,e)?v[e]:null;function Dt(e){let t=Et(e.metadata?.newStatus);return e.type===`status_changed`&&e.title===`Status changed`&&t?t:e.title}var Ot=e=>e?e.slice(0,7):null;function kt(e){let t=e.tag??Ot(e.sha);switch(e.kind){case`deployment`:return t?`Deploy ${t}`:`Deploy`;case`rollback`:return t?`Rollback to ${t}`:`Rollback`;case`release`:return`Release ${e.tag??Ot(e.sha)??``}`.trim();case`merge`:return e.pr?`Merged #${e.pr}`:`Merge`;case`config`:return`Config change`;case`migration`:return`Migration`;default:return t?`Commit ${t}`:`Commit`}}function At(e,t,n){let r=Math.round((Date.parse(t)-Date.parse(e))/6e4),i=n?`the alert`:`the incident opened`;return r<0?`after the incident opened`:r<120?`${r} ${r===1?`minute`:`minutes`} before ${i}`:`${Math.round(r/60)} hours before ${i}`}function jt(e){if(e.files&&e.files.count>0){let t=e.files.paths[0],n=e.files.count;return t?`${n} ${n===1?`file`:`files`}, including ${t}`:`${n} ${n===1?`file`:`files`}`}return e.title}function Mt(e){return e.type===`investigation_started`&&/\bresumed$/i.test(e.title)}function Nt(e,t){let n=e.metadata?.investigationId,r=typeof n==`string`?t.find(e=>e.id===n)??null:null,i={key:`t:${e.id}`,at:e.occurredAt};if(r&&Mt(e))return r.kind===`chat`?null:{...i,text:`${J(t,r)} continued`,tone:Be(r)===`working`?`live`:`accent`,runId:r.id};if(r&&e.type===`investigation_started`)return r.kind===`chat`?{...i,text:r.title?`You asked: ${r.title}`:`You asked a question`,tone:`plain`,runId:r.id}:{...i,text:`${J(t,r)} started`,tone:Be(r)===`working`?`live`:`accent`,runId:r.id};if(r&&e.type===`investigation_completed`){if(r.kind===`chat`)return null;let n=Be(r),a=l(n)?r.hasReport?`done`:/stopped/i.test(e.title)?`stopped`:`failed`:n,o=a===n?ze(r):a===`done`?Re(r.rootCause):a;return{...i,text:a===`failed`||a===`stopped`?`${J(t,r)} ${o}`:`${J(t,r)} concluded: ${o}`,tone:a===`failed`?`danger`:`accent`,runId:r.id}}if(e.type===`comment`)return{...i,text:`Note: ${e.title}`,tone:`plain`};let a=e.metadata?.priorIncidentId;if(e.type===`incident_created`)return typeof a==`string`&&e.description?{...i,text:e.description,tone:`plain`,incidentId:a}:{...i,text:`Incident opened`,tone:`plain`};if(e.type===`custom`&&e.description&&!Dt(e).includes(e.description))return{...i,text:`${Dt(e)}: ${e.description}`,tone:`plain`};let o=e.metadata?.mergedIntoId??e.metadata?.mergedFromId,s=e.metadata?.reason===`merged`&&typeof o==`string`?{incidentId:o}:{};return e.type===`alert_added`||e.type===`alert_removed`?{...i,text:e.description?`${e.title}: ${e.description}`:e.title,tone:e.type===`alert_added`?`danger`:`plain`,...s}:e.type===`recommendation_completed`?{...i,text:e.title,tone:`ok`}:{...i,text:Dt(e),tone:`plain`,...s}}function Pt(e,t,n){let r=new Set,i=[];for(let t of e){let e=t.metadata?.investigationId,a=t.type===`investigation_started`||t.type===`investigation_completed`;if(typeof e==`string`&&!a&&t.type!==`recommendation_completed`)continue;let o=Nt(t,n);if(!o)continue;let s=Mt(t)?t.id:`${t.type}:${String(e)}`;a&&r.has(s)||(a&&r.add(s),i.push(o))}for(let e of t)i.push({key:`c:${e.id}`,at:e.at,text:`${kt(e)}: ${e.title}`,tone:`accent`,url:e.url});return i.sort((e,t)=>Date.parse(t.at)-Date.parse(e.at))}function Ft(e){if(!e)return null;if(e.state===`no-repos`)return{text:`No repository is linked to this incident's services, so deploys and merges cannot show here.`,action:{label:`Link a repository`,to:`service`}};let t=e.sources.find(e=>e.problem)?.problem;return t?t.action===`add-credential`?{text:`Add a git host token, or sign in to git on this machine, to see deploys and merges`,action:{label:`Add a token`,to:`settings`}}:t.action===`replace-token`?{text:t.message,action:{label:`Replace the token`,to:`settings`}}:t.action===`pick-credential`?{text:t.message,action:{label:`Pick a credential`,to:`settings`}}:{text:t.message,action:null}:null}var It={danger:`bg-danger`,accent:`bg-accent`,live:`bg-live breathe`,ok:`bg-ok`,plain:`bg-text-3`},Lt=6;function Rt({o:e,wide:t}){let n=q(3e4),{incident:i,runs:a,timeline:o,timelineLoading:s}=e.record,c=e.changes,l=(0,X.useMemo)(()=>Pt(o,c?.timeline??[],a),[o,c?.timeline,a]),u=l.filter(e=>e.key.startsWith(`t:`)).length+(c?.total??0),d=e.allChanges?l:l.slice(0,Lt),f=Ft(c),p=c?.deploy??null,m=c?.state===`pending`||c?.refreshing;return(0,Z.jsx)(xt,{title:`What changed and when`,className:t?`md:col-span-2`:void 0,testId:`changes-card`,actions:u>Lt?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>e.setAllChanges(!e.allChanges),className:`text-meta text-accent hover:underline`,"aria-expanded":e.allChanges,"data-testid":`changes-all`,children:e.allChanges?`Latest ${Lt}`:`All ${u} events`}):null,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[p&&(0,Z.jsx)(Bt,{name:kt(p),detail:jt(p),at:p.at,started:i.createdAt,url:p.url,now:n,hasAlert:(i.alerts??[]).length>0}),f&&(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5 rounded-surface bg-surface-2 px-3 py-2`,"data-testid":`changes-problem`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-text-2`,children:f.text}),f.action&&(0,Z.jsx)(W,{variant:`secondary`,className:`h-[26px] shrink-0 bg-surface-3 hover:bg-surface-4`,asChild:!0,children:f.action.to===`service`&&i.service?(0,Z.jsx)(r,{to:`/services/$id`,params:{id:i.service.id},children:f.action.label}):(0,Z.jsx)(r,{to:`/settings`,search:{tab:`sources`},children:f.action.label})})]}),m&&!p&&(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 text-meta text-text-3`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`breathe size-1.5 rounded-full bg-live`}),`Reading the git history`]}),!s&&l.length===0?(0,Z.jsx)(`p`,{className:`text-text-3`,children:`No events yet.`}):(0,Z.jsx)(`ol`,{className:`flex flex-col`,"data-testid":`changes-timeline`,children:d.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 items-center gap-2.5 px-1 py-1.5 shadow-[inset_0_-1px_0_var(--hairline)]`,"data-row":e.text,"data-testid":`changes-row`,children:[(0,Z.jsx)(R,{label:F(e.at),side:`left`,children:(0,Z.jsx)(`span`,{className:`w-[104px] shrink-0 text-meta text-text-3 tabular-nums`,children:Ve(e.at,n)})}),(0,Z.jsx)(`span`,{"aria-hidden":!0,className:B(`size-1.5 shrink-0 rounded-full`,It[e.tone])}),(0,Z.jsx)(zt,{row:e,incidentId:i.id})]},e.key))})]})})}function zt({row:e,incidentId:t}){let n=`min-w-0 line-clamp-2`,i=(0,Z.jsx)(R,{label:e.text,children:(0,Z.jsx)(`span`,{className:n,dir:`auto`,children:e.text})});return e.runId?(0,Z.jsx)(r,{to:`/incidents/$id/conversation`,params:{id:t},search:{investigation:e.runId},className:B(n,`py-0.5 hover:text-accent`),dir:`auto`,children:e.text}):e.incidentId?(0,Z.jsx)(r,{to:`/incidents/$id`,params:{id:e.incidentId},className:B(n,`hover:text-accent`),dir:`auto`,"data-testid":`changes-merge-link`,children:e.text}):e.url?(0,Z.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:B(n,`hover:text-accent`),dir:`auto`,children:e.text}):i}function Bt({name:e,detail:t,at:n,started:r,url:i,now:a,hasAlert:o}){let s=Math.round((Date.parse(r)-Date.parse(n))/6e4),c=s>=0&&s<120?`, ${At(n,r,o)}`:``,l=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ht,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`shrink-0 font-medium`,children:e}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-text-2`,children:t}),(0,Z.jsx)(R,{label:`${F(n)}${c}`,children:(0,Z.jsx)(`span`,{className:`shrink-0 text-meta text-text-3`,children:Ve(n,a)})})]}),u=`flex min-w-0 items-center gap-2.5 rounded-surface bg-surface-2 px-3 py-2 whitespace-nowrap`;return i?(0,Z.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:B(u,`transition-colors duration-(--dur-instant) hover:bg-surface-3`),"data-testid":`changes-deploy`,children:l}):(0,Z.jsx)(`div`,{className:u,"data-testid":`changes-deploy`,children:l})}function Vt(e){return e?.metric&&e.series.length>0&&(e.state===`ok`||e.metric.source===`service`)?e:null}function Ht(e){let t=e.connection?`from ${e.connection.label}, `:``;return e.metric.source===`service`?`The service's metric, not this alert's, ${t}last 24 hours`:e.metric.source===`alert_current_rule`?`The alert's rule as loaded now; it may have changed since this alert fired, ${t}last 24 hours`:`The alert's own query, ${t}last 24 hours`}function Ut({view:e}){let{impact:t,pending:n,slow:r,failed:i,retry:a}=e,o=Vt(t),s=r||t?.state===`timeout`,c=i??(t?.state===`error`?t.error??`it refused the query`:null),l=o?Ht(o):n&&!r?`Asking the metrics source`:s||c?`The metrics source did not answer`:t?.history.alertCount===0?`No alert on this incident`:`From the alert alone`;return(0,Z.jsx)(xt,{title:`Impact`,sub:(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-meta text-text-3`,children:l}),testId:`impact-card`,children:o?(0,Z.jsx)(Wt,{impact:o}):n&&!r?(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-2`,"data-testid":`impact-pending`,children:[(0,Z.jsx)(`span`,{className:`text-meta text-text-3`,children:`Asking for the last 24 hours`}),(0,Z.jsx)(ke,{className:`min-h-[60px] flex-1 rounded-control`})]}):s||c?(0,Z.jsxs)(`div`,{className:`flex h-full flex-col items-start justify-center gap-2.5`,"data-testid":`impact-slow`,children:[(0,Z.jsx)(`p`,{className:`text-text-2`,children:s?`The metrics source has not answered for 10 seconds. Nothing else on this page waits for it.`:`The metrics source answered with an error: ${c}`}),(0,Z.jsx)(W,{variant:`secondary`,className:`h-7 bg-surface-3 hover:bg-surface-4`,onClick:a,"data-testid":`impact-retry`,children:`Try again`})]}):t?(0,Z.jsx)(Jt,{impact:t,firing:e.firing}):null})}function Wt({impact:e}){let t=(0,X.useMemo)(()=>Xe(e),[e]),n=e.series.length>1,r=e.metric.threshold,i=e.metric.unit,a=r&&e.now!==null?Kt(e.now,r):!1,o=e.metric.source===`service`?`Service metric`:n?`${e.series.length} series match`:`This alert's series`;return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 gap-5`,"data-testid":`impact-chart`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-meta text-text-3`,children:[(0,Z.jsx)(R,{label:e.metric.query,children:(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-0.5 w-2.5 bg-danger`}),o]})}),r&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`svg`,{"aria-hidden":!0,width:`10`,height:`2`,className:`shrink-0`,children:(0,Z.jsx)(`line`,{x1:`0`,y1:`1`,x2:`10`,y2:`1`,stroke:`var(--warn)`,strokeDasharray:`3 2`})}),`Alert fires `,Gt(r.op),` `,Y(r.value,i)]}),t.deploys.map(e=>(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`h-2.5 w-0.5 bg-accent`}),e.label]},`${e.x}-${e.label}`))]}),(0,Z.jsxs)(`div`,{className:`flex min-h-[60px] flex-1 gap-1.5`,children:[(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`relative w-10 shrink-0 text-right text-[11px] leading-3 text-text-3`,children:t.ticks.map(e=>(0,Z.jsx)(`span`,{className:`absolute right-0`,style:{top:`calc(${e.y/200*100}% - 6px)`},children:Y(e.value,i)},e.value))}),(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsxs)(`svg`,{viewBox:`0 0 720 200`,preserveAspectRatio:`none`,width:`100%`,height:`100%`,role:`img`,"aria-label":qt(e,o),className:`block`,children:[t.ticks.map(e=>(0,Z.jsx)(`line`,{x1:`0`,x2:720,y1:e.y,y2:e.y,stroke:`var(--hairline)`,vectorEffect:`non-scaling-stroke`},e.value)),t.thresholdY!==null&&(0,Z.jsx)(`line`,{x1:`0`,x2:720,y1:t.thresholdY,y2:t.thresholdY,stroke:`var(--warn)`,strokeDasharray:`4 4`,vectorEffect:`non-scaling-stroke`}),t.deploys.map(e=>(0,Z.jsx)(`line`,{x1:e.x,x2:e.x,y1:`0`,y2:200,stroke:`var(--accent)`,strokeWidth:`1.5`,vectorEffect:`non-scaling-stroke`},`${e.x}-${e.label}`)),t.area&&(0,Z.jsx)(`polygon`,{points:t.area,fill:`oklch(from var(--danger) l c h / 0.12)`}),t.lines.map((e,t)=>(0,Z.jsx)(`polyline`,{points:e,fill:`none`,stroke:`var(--danger)`,strokeWidth:n?1.25:2,strokeOpacity:n?.7:1,strokeLinejoin:`round`,vectorEffect:`non-scaling-stroke`},t))]})})]}),(0,Z.jsxs)(`div`,{className:`relative ml-[38px] h-4 text-meta text-text-3`,children:[t.xLabels.map(e=>(0,Z.jsx)(`span`,{className:`absolute`,style:{left:`${e.x}%`},children:e.label},e.x)),(0,Z.jsx)(`span`,{className:`absolute right-0`,children:`Now`})]})]}),e.now!==null&&(0,Z.jsx)(`dl`,{className:`flex w-[120px] shrink-0 flex-col justify-center gap-3`,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-meta text-text-3`,children:`Now`}),(0,Z.jsx)(`dd`,{className:B(`text-display`,a?`text-danger`:`text-text-1`),"data-testid":`impact-now`,children:Y(e.now,i)}),e.usual!==null&&(0,Z.jsxs)(`dd`,{className:`text-meta text-text-2`,children:[`Usually `,Y(e.usual,i)]})]})})]})}var Gt=e=>e.startsWith(`<`)?`below`:e===`==`?`at`:e===`!=`?`away from`:`above`;function Kt(e,t){switch(t.op){case`>`:return e>t.value;case`>=`:return e>=t.value;case`<`:return e<t.value;case`<=`:return e<=t.value;case`==`:return e===t.value;default:return e!==t.value}}function qt(e,t){let n=e.metric.unit,r=[`${t} over the last 24 hours`];return e.now!==null&&r.push(`now ${Y(e.now,n)}`),e.usual!==null&&r.push(`usually ${Y(e.usual,n)}`),e.metric.threshold&&r.push(`the alert fires at ${Y(e.metric.threshold.value,n)}`),r.join(`, `)}function Jt({impact:e,firing:t}){let n=q(3e4)??Date.now(),r=e.history,i=r.firingSince&&!r.resolvedAt?n-Date.parse(r.firingSince):null;return r.alertCount===0?(0,Z.jsx)(`div`,{className:`flex h-full flex-col`,"data-testid":`impact-no-alert`,children:(0,Z.jsx)(Yt,{impact:e})}):(0,Z.jsxs)(`div`,{className:`flex h-full flex-col gap-3.5`,"data-testid":`impact-no-source`,children:[(0,Z.jsxs)(`dl`,{className:`grid grid-cols-[repeat(auto-fit,minmax(9rem,1fr))] gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-meta text-text-3`,children:`Firing for`}),(0,Z.jsx)(`dd`,{className:B(`truncate text-display`,i===null?`text-text-2`:`text-danger`),children:i===null?`Not firing`:L(Math.max(0,i)/1e3)})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-meta text-text-3`,children:`Alerts`}),(0,Z.jsxs)(`dd`,{className:`truncate text-display`,children:[t,` of `,r.alertCount,` firing`]})]}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-meta text-text-3`,children:`Fired before`}),(0,Z.jsx)(`dd`,{className:`truncate text-display`,children:r.refiresThisWeek===0?`Not this week`:`${r.refiresThisWeek} ${r.refiresThisWeek===1?`time`:`times`} this week`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-meta text-text-3`,children:`When this alert fired, last 7 days`}),(0,Z.jsx)(`div`,{className:`relative h-6 overflow-hidden rounded-control bg-surface-2`,children:r.strip.map((e,t)=>{let i=Ze(e,n),a=t===r.strip.length-1,o=e.end?`Fired ${I(e.start)} for ${L((Date.parse(e.end)-Date.parse(e.start))/1e3)}`:`Firing since ${I(e.start)}`;return(0,Z.jsx)(R,{label:o,children:(0,Z.jsx)(`span`,{tabIndex:0,role:`img`,"aria-label":o,className:B(`absolute inset-y-0`,a?`bg-danger`:`bg-danger/45`),style:{left:`${i.left}%`,width:`${i.width}%`}})},e.start)})}),(0,Z.jsx)(`div`,{className:`flex justify-between text-meta text-text-3`,children:et(n).map((e,t)=>(0,Z.jsx)(`span`,{children:e},t))})]}),(0,Z.jsx)(Yt,{impact:e})]})}function Yt({impact:e}){let t=rt(e);return(0,Z.jsxs)(`div`,{className:`mt-auto flex min-w-0 items-center gap-3 rounded-surface bg-surface-2 px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-text-2`,children:t}),e.state===`not_configured`?(0,Z.jsx)(W,{variant:`secondary`,className:`h-[26px] shrink-0 bg-surface-3 hover:bg-surface-4`,asChild:!0,children:(0,Z.jsx)(r,{to:`/settings`,search:{tab:`sources`},"data-testid":`impact-connect`,children:`Connect Prometheus`})}):e.linkOut?(0,Z.jsx)(W,{variant:`secondary`,className:`h-[26px] shrink-0 bg-surface-3 hover:bg-surface-4`,asChild:!0,children:(0,Z.jsx)(`a`,{href:e.linkOut,target:`_blank`,rel:`noreferrer`,children:`Open the query`})}):null]})}function Xt(e,t){return n=>{let r=e.current;switch(n){case`copy`:r&&e.copy(r,t.commandRef.current);return;case`applied`:r&&e.apply(r);return;case`check`:r&&e.check(r);return;case`next-option`:e.nextOption();return;case`resolve`:e.record.openClose();return;case`resume`:t.resume();return;case`retry`:case`investigate`:t.investigate();return;case`ask`:t.ask();return;case`watch`:t.watch();return;case`services`:t.services?.();return}}}function Zt(e){let t=Math.floor(e/60);if(t<60)return Q(Math.max(1,t),`minute`);let n=Math.floor(t/60);return n<24?Q(n,`hour`):Q(Math.floor(n/24),`day`)}function Q(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function Qt(e){let t=[],n=e.alerts.filter(e=>i(e.status)).length,r=e.services.length>0?` on ${e.services.join(`, `)}`:``;if(e.alerts.length===0)t.push(`No alerts are correlated.`);else{let i=Math.min(...e.alerts.map(e=>Date.parse(e.triggeredAt))),a=Zt((e.now-i)/1e3),o=e.alerts.length;t.push(e.alerts.every(me)?o===1?`A webhook event arrived${r} ${a} ago.`:`${o} webhook events arrived${r}, the first ${a} ago.`:n>0?`${n} of ${Q(e.alerts.length,`alert`)} firing${r}, the first ${a} ago.`:`${Q(e.alerts.length,`alert`)}${r}, none firing now.`)}let a=e.runs[0],o=a?u(a.status,{hasEvents:!0}):null,s=null;if(!a)t.push(`No investigation yet.`);else if(o===`starting`||o===`working`||o===`stopping`)t.push(e.waiting?`An investigation waits for your approval.`:e.step?`An investigation is working now: ${e.step}.`:`An investigation is working now.`);else if(o===`done`)t.push(a.rootCause?`The last investigation concluded: ${a.rootCause}`:`The last investigation finished without naming a root cause.`);else if(o===`stopped`)t.push(`The last investigation was stopped.`);else if(a.endReason===`interrupted`){let e=N(a.error);t.push(e?`The last investigation was interrupted when PrismaLens restarted, and not resumed: ${e}`:`The last investigation was interrupted when PrismaLens restarted.`)}else{let n=0;for(;n<e.runs.length&&u(e.runs[n]?.status??``,{hasEvents:!0})===`failed`;)n++;s=M(a.error),t.push(`${n>1?`${n} investigations in a row failed`:`The last investigation failed`}: ${s.what.replace(/^The /,`the `)}`)}return e.noRepo&&t.push(`No repository is linked, so the agent read no code.`),{lines:t,next:e.ended?null:e.attention===`unacknowledged`?{kind:`acknowledge`,text:`Acknowledge it so others know it is taken.`}:e.noRepo?{kind:`link-repo`,text:`Link the service's repository, then investigate.`}:s?{kind:`investigate`,text:s.next??`Try again.`}:e.attention===`awaiting_close`?{kind:`close`,text:`Its alerts cleared. Resolve it, with the cause if you know it.`}:o===`done`?{kind:`resolve`,text:`Read the report, then resolve.`}:a?null:{kind:`investigate`,text:`Start an investigation.`}}}var $t={accent:`bg-accent/12`,plain:`bg-surface-2`,live:`bg-live/10`,warn:`bg-warn/10`,ok:`bg-ok/10`,danger:`bg-danger/12`},en={accent:`bg-accent`,plain:`bg-text-3`,live:`bg-live breathe`,warn:`bg-warn`,ok:`bg-ok`,danger:`bg-danger`};function tn({o:e,onAction:t,canStart:n=!0,compact:i=!1,watching:o=!1,omit:s=[],limited:c=!1}){let{incident:l,runs:u}=e.record,f=q(3e4)??Date.now(),[p,m]=(0,X.useState)(!1),h=z(),g=e.report,_=!!e.live&&(e.latestRun.awaiting||!!e.live.awaitingApprovalAt),v=g?.summary??Qt({now:f,alerts:l.alerts??[],services:Ke(l).map(e=>e.name),runs:u,noRepo:!1,attention:pe(l),ended:a(l.status),waiting:_}).lines.join(` `),y=Pe(l,f),b=Ke(l).map(e=>e.name),x=b.length>0||(l.alerts??[]).length>0?{services:b.join(`, `)||`No service`,firing:Ue(l.alerts??[],f)}:null,S=[];y===`worse`?S.push({k:`Alert trend`,v:`Getting worse`,tone:`text-danger`}):y===`steady`?S.push({k:`Alert trend`,v:`Steady`}):y===`clear`&&S.push({k:`Alert trend`,v:`Recovered`,tone:`text-ok`});let ee=tt(l.actualCauseCategory,g?.rootCauseCategory);ee&&S.push({k:`Cause`,v:d[ee]}),g?.culprit?.changeRef&&S.push({k:`Change`,v:g.culprit.changeRef}),g?.culprit?.mechanism&&S.push({k:`Mechanism`,v:g.culprit.mechanism});let C=e.latest,te=e.latestRun.state,w=h.data?.harnesses.find(e=>e.id===C?.harness),ne=Qe(C,te,C?J(u,C):``,w?.label,w?.loginHint),T=at({lastingFix:g?.nextSteps?.find(e=>e.kind===`lasting`)?.title,ended:l.status===`closed`,cause:l.actualCause,mergedInto:l.mergedInto,refiredAs:l.refiredAs,cleared:e.cleared,alertsCleared:l.status===`resolved`,runs:u.filter(e=>e.kind!==`chat`).length,noService:Ke(l).length===0,live:e.live?{name:J(u,e.live),waiting:_}:null,failed:ne.failed,interrupted:ne.interrupted,reported:!!g,option:e.current,stage:e.stage,checkable:e.checkable,hasNextOption:e.others.length>0,unit:e.impact.impact?.metric?.unit,threshold:e.impact.impact?.metric?.threshold,flagged:e.flagged}),E=o?[...s,`watch`]:s;T.primary&&E.includes(T.primary.id)&&(T.primary=void 0),T.secondary&&E.includes(T.secondary.id)&&(T.secondary=void 0);let D=o&&!T.primary&&!T.secondary;return(0,Z.jsxs)(`section`,{"aria-label":`Situation`,className:`flex min-w-0 shrink-0 flex-col overflow-hidden rounded-pool bg-surface-1`,"data-testid":`situation`,children:[i&&x&&(0,Z.jsxs)(`p`,{className:`flex min-w-0 flex-wrap items-center gap-x-1.5 px-4 pt-2.5 text-meta text-text-3`,"data-testid":`situation-where`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:x.services}),x.firing&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Z.jsx)(`span`,{className:x.firing.firing?`text-danger`:`text-ok`,children:x.firing.firing?`Alert still firing`:`Alert cleared`})]}),c&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Z.jsx)(`span`,{className:`text-warn`,"data-testid":`situation-limited`,children:`From code only; alerts and metrics not read`})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-x-6 gap-y-2 px-4 pt-3 pb-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>m(e=>!e),"aria-expanded":p,className:B(`min-h-6 min-w-0 flex-[1_1_360px] text-left text-[15px] leading-[22px] font-medium`,!p&&(i?`line-clamp-2`:`line-clamp-3`),!g&&`text-text-2`),dir:`auto`,"data-testid":`situation-brief`,children:nn(v)}),S.length>0&&(0,Z.jsx)(`dl`,{className:B(`flex min-w-0 shrink flex-wrap justify-end gap-x-6 gap-y-1`,i&&`max-sm:hidden`),"data-testid":`situation-facts`,children:S.slice(0,4).map(e=>(0,Z.jsxs)(`div`,{className:`flex max-w-[180px] min-w-0 flex-col`,children:[(0,Z.jsx)(`dt`,{className:`text-meta text-text-3`,children:e.k}),(0,Z.jsx)(R,{label:e.v,children:(0,Z.jsx)(`dd`,{className:B(`truncate font-medium`,e.tone),children:e.v})})]},e.k))})]}),!i&&(0,Z.jsx)(rn,{deps:e.dependencies}),!D&&(0,Z.jsxs)(`div`,{className:B(`flex min-h-11 items-center gap-2.5 py-2 pr-3 pl-4`,$t[T.tone]),"data-testid":`next-strip`,"data-tone":T.tone,children:[(0,Z.jsx)(`span`,{className:`shrink-0 text-meta font-medium text-text-3`,children:`Next`}),(0,Z.jsx)(`span`,{"aria-hidden":!0,className:B(`size-1.5 shrink-0 rounded-full`,en[T.tone])}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 text-text-1`,dir:`auto`,"aria-live":`polite`,"data-testid":`next-text`,children:[T.text,T.link&&(0,Z.jsxs)(Z.Fragment,{children:[` `,(0,Z.jsx)(r,{to:`/incidents/$id`,params:{id:T.link.incidentId},className:`font-medium underline-offset-2 hover:underline`,"data-testid":`next-refire`,children:T.link.label})]})]}),T.secondary&&(0,Z.jsx)(W,{variant:`secondary`,className:`h-7 shrink-0 bg-surface-3 hover:bg-surface-4`,onClick:()=>T.secondary&&t(T.secondary.id),disabled:e.busy||st(T.secondary.id)&&!n,"data-testid":`next-${T.secondary.id}`,children:T.secondary.label}),T.primary&&(0,Z.jsx)(W,{className:`h-7 shrink-0`,onClick:()=>T.primary&&t(T.primary.id),disabled:e.busy||st(T.primary.id)&&!n,"data-testid":`next-${T.primary.id}`,children:T.primary.label})]})]})}function nn(e){return e.replace(/```[\s\S]*?```/g,` `).replace(/^#+\s*/gm,``).replace(/\*\*|__|`/g,``).replace(/^\s*[-*]\s+/gm,``).replace(/\s*\n+\s*/g,` `).trim()}function rn({deps:e}){let{incidents:t}=Fe(),n=q(3e4)??Date.now();if(e.length===0)return null;let i=e.slice(0,3),a=e.length-i.length,o=e=>t.some(t=>t.service?.id===e&&[`worse`,`steady`].includes(Pe(t,n))),s=i.filter(e=>o(e.service.id)),c=s.length===0?`${i.length===1?`healthy`:i.length===2?`both healthy`:`all healthy`} at ${I(n)}.`:`${s.map(e=>e.service.displayName||e.service.name).join(` and `)} ${s.length===1?`has`:`have`} an alert firing.`;return(0,Z.jsxs)(`p`,{className:`flex min-w-0 items-center gap-2 px-4 pb-2.5 text-meta text-text-2`,"data-testid":`situation-depends`,children:[(0,Z.jsx)(pt,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Depends on`,` `,i.map((e,t)=>(0,Z.jsxs)(X.Fragment,{children:[t>0&&(t===i.length-1&&a===0?` and `:`, `),(0,Z.jsx)(r,{to:`/services/$id`,params:{id:e.service.id},className:`text-text-1 underline-offset-2 hover:underline`,children:e.service.displayName||e.service.name}),` `,`(`,p[e.service.type].toLowerCase(),`)`]},e.service.id)),a>0&&` and ${a} more`,`, `,c]})]})}var an={ready:{text:`Not applied`,tone:`text-text-3`},applied:{text:`You applied this`,tone:`text-text-2`},checking:{text:`Checking`,tone:`text-live`},checked:{text:``,tone:``},"checked-not_yet":{text:`Not working yet`,tone:`text-warn`},"checked-below_threshold":{text:`Below the threshold`,tone:`text-text-2`},"checked-could_not_check":{text:`Could not check`,tone:`text-warn`},"checked-it_worked":{text:`Worked`,tone:`text-ok`},worked:{text:`Worked`,tone:`text-ok`}};function on(e){return e.stage===`checked`?an[`checked-${e.check.verdict}`]:an[e.stage]}function sn({o:e,commandRef:t}){let{incident:n}=e.record,r=e.current,i=e.flagged,a=e.report&&r?`Undo what hurts users; fix the cause after.`:null;return(0,Z.jsx)(xt,{title:`Stop the impact`,id:`stop-the-impact`,sub:a&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-meta text-text-3`,children:a}),testId:`stop-impact-card`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[r&&e.stage?(0,Z.jsx)(ln,{o:e,option:r,stage:e.stage,flagged:i,commandRef:t}):e.report?(0,Z.jsx)(`p`,{className:`py-2 text-text-2`,"data-testid":`fix-empty`,children:`The report suggests no mitigation.`}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 py-2`,"data-testid":`fix-none`,children:[(0,Z.jsx)(`p`,{className:`text-text-2`,children:`No options yet. No run has reached a finding.`}),e.changes?.deploy&&(0,Z.jsxs)(`p`,{className:`text-text-3`,children:[kt(e.changes.deploy),` shipped`,` `,At(e.changes.deploy.at,n.createdAt,(n.alerts??[]).length>0),`.`]})]}),(0,Z.jsx)(un,{o:e}),e.others.map(t=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>e.pickOption(t),className:`flex min-w-0 flex-col rounded-surface bg-surface-2 px-3 py-2 text-left transition-colors duration-(--dur-instant) hover:bg-surface-3`,"data-row":t.title,"data-testid":`fix-other`,children:[(0,Z.jsx)(`span`,{className:`truncate`,dir:`auto`,children:t.title}),(0,Z.jsx)(`span`,{className:`truncate text-meta text-text-3`,dir:`auto`,children:cn(e,t)})]},t.id??t.title))]})})}function cn(e,t){let n=e.stageOf(t);return n.stage===`ready`?t.facts[0]??t.detail:`Applied at ${I(n.appliedAt)}. ${on(n).text}.`}function ln({o:e,option:t,stage:n,flagged:r,commandRef:i}){let[a,o]=(0,X.useState)(!1);(0,X.useEffect)(()=>{if(!a)return;let e=window.setTimeout(()=>o(!1),1500);return()=>window.clearTimeout(e)},[a]);let s=on(n),c=t.canUndo&&n.stage===`applied`,l=it(t),u=Ye(t);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-surface bg-surface-2 p-3`,"data-row":t.title,"data-testid":`fix-card`,"data-stage":n.stage,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2.5`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-title`,dir:`auto`,"data-testid":`fix-title`,children:t.title}),(0,Z.jsx)(`span`,{className:B(`shrink-0 text-meta font-medium`,s.tone),"data-testid":`fix-state`,children:s.text}),c&&(0,Z.jsx)(W,{variant:`secondary`,className:`h-[22px] shrink-0 rounded-[4px] bg-surface-3 px-2 text-meta hover:bg-surface-4`,onClick:()=>e.undo(t),disabled:e.busy,"data-testid":`fix-undo`,children:`Undo`})]}),l?(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5`,children:[(0,Z.jsx)(`code`,{ref:i,tabIndex:0,className:`min-w-0 flex-1 rounded-control bg-canvas px-2.5 py-2 font-mono text-mono break-all whitespace-pre-wrap text-text-1 select-all`,"data-testid":`fix-command`,children:l}),(0,Z.jsxs)(W,{variant:`secondary`,className:`h-8 shrink-0 gap-1.5 bg-surface-3 hover:bg-surface-4`,"aria-label":`Copy command`,onClick:async()=>{await e.copy(t,i.current)&&o(!0)},"data-testid":`fix-copy`,children:[(0,Z.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{"aria-live":`polite`,children:a?`Copied`:`Copy`})]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-text-2`,dir:`auto`,children:t.detail}),u&&u!==t.detail&&(0,Z.jsx)(`p`,{className:`text-text-2`,dir:`auto`,"data-testid":`fix-note`,children:u})]}),t.facts.length>0&&(0,Z.jsx)(`ul`,{className:`list-disc pl-4 text-text-2`,"data-testid":`fix-facts`,children:t.facts.map(e=>(0,Z.jsx)(`li`,{dir:`auto`,children:e},e))}),r&&l&&(0,Z.jsxs)(`p`,{className:`flex gap-1.5 text-meta text-warn`,"data-testid":`fix-flagged`,children:[(0,Z.jsx)(k,{className:`mt-0.5 size-3 shrink-0`,"aria-hidden":!0}),`The agent flagged text that tried to instruct it while it worked. Read this command before you run it.`]}),t.readOnly&&(0,Z.jsx)(`p`,{className:`text-meta text-text-3`,children:`From a report written before fixes could be marked applied.`})]})}function un({o:e}){let t=q(3e4),{incident:n}=e.record,i=e.ask;if(!i)return null;let a=e.askRun.state,o=a===`starting`||a===`working`,s=e.askRun.latestText,c=e.earlierAsks[0];return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5 rounded-surface bg-surface-2 px-3 py-2`,"data-row":`Your question`,"data-testid":`you-asked`,children:[(0,Z.jsxs)(`span`,{className:`text-meta text-text-3`,children:[`You asked `,Ne(i.startedAt??i.createdAt,t)]}),(0,Z.jsx)(r,{to:`/incidents/$id/conversation`,params:{id:n.id},search:{investigation:i.id},className:`font-medium hover:text-accent`,dir:`auto`,"data-testid":`you-asked-question`,children:i.title??`Your question`}),o?(0,Z.jsxs)(`span`,{className:`flex items-center gap-2 text-text-2`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`breathe size-1.5 rounded-full bg-live`}),`Answering.`,(0,Z.jsx)(r,{to:`/incidents/$id/conversation`,params:{id:n.id},search:{investigation:i.id},className:`text-accent hover:underline`,children:`Open the conversation`})]}):a===`failed`?(0,Z.jsx)(`span`,{className:`text-danger`,children:`The answer did not finish.`}):s?(0,Z.jsx)(`span`,{dir:`auto`,className:`text-text-1`,children:s}):null,c&&(0,Z.jsx)(r,{to:`/incidents/$id/conversation`,params:{id:n.id},search:{investigation:c.id},className:`truncate text-meta text-accent underline underline-offset-2`,"data-testid":`you-asked-earlier`,children:e.earlierAsks.length===1?`1 earlier question${c.title?`: ${c.title}`:``}`:`${e.earlierAsks.length} earlier questions`})]})}async function dn(e,t){try{if(!navigator.clipboard)throw Error(`no clipboard`);return await navigator.clipboard.writeText(e),!0}catch{if(t){let e=document.createRange();e.selectNodeContents(t);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(e),t.focus()}return!1}}var fn=1e4,$=e=>e.id??`#${e.index}`;function pn(){let e=Ge(),{incident:t,runs:n}=e,r=f(),{toast:a}=K(),o=We(n),s=Le(o?.id??null),c=s.investigation?.report??null,u=m({...g.fixes.forInvestigation.queryOptions({input:{id:o?.id??``}}),enabled:!!o}),d=(0,X.useMemo)(()=>$e(u.data),[u.data]),p=n.find(e=>e.kind===`chat`)??null,h=Le(p?.id??null),v=n.filter(e=>e.kind===`chat`).slice(1),x=n.find(e=>e.kind!==`chat`)??null,S=Le(x&&x.id!==o?.id?x.id:null),ee=x&&x.id===o?.id?s:S,C=x?Be(x):null,te=x&&C&&l(C)?x:null,w=m({...g.impact.forIncident.queryOptions({input:{id:t.id}}),retry:!1,refetchOnWindowFocus:!1,staleTime:6e4}),[ne,T]=(0,X.useState)(!1),E=w.isFetching;(0,X.useEffect)(()=>{if(T(!1),!E)return;let e=window.setTimeout(()=>T(!0),fn);return()=>window.clearTimeout(e)},[E]);let D=w.data??null,re=D?.checkable??!1,[O,ie]=(0,X.useState)(!1),ae=m({...g.changes.forIncident.queryOptions({input:{id:t.id,limit:O?200:6}}),placeholderData:e=>e,refetchInterval:e=>e.state.data?.refreshing?3e3:!1}),k=t.service?.id,oe=m({...g.services.getTopology.queryOptions({input:{id:k??``}}),enabled:!!k}),[se,A]=(0,X.useState)(0),[j,M]=(0,X.useState)({}),[N,P]=(0,X.useState)({}),[F,I]=(0,X.useState)({}),L=d.stop[Math.min(se,d.stop.length-1)]??null,R=d.stop.filter(e=>e!==L),z=t.alerts??[],ue=e=>{let t=$(e);return Je({option:e,copied:!!j[t],copyFailed:j[t]===`failed`,checking:!!N[t],check:F[t]??null,alerts:z})},de=()=>Promise.all([r.invalidateQueries({queryKey:g.fixes.forInvestigation.key()}),r.invalidateQueries({queryKey:le.all()}),r.invalidateQueries({queryKey:ce.all()})]),fe=e=>t=>a({title:e,description:y(t),variant:`destructive`}),B=_({mutationFn:e=>e.id?b.fixes.apply({id:e.id}):Promise.resolve(null),onSettled:de,onError:fe(`Not recorded`)}),pe=_({mutationFn:e=>e.id?b.fixes.undo({id:e.id}):Promise.resolve(null),onSettled:de,onError:fe(`Not undone`)}),V=async e=>{if(!e.id)return;let t=$(e);P(e=>({...e,[t]:!0}));try{let n=await b.fixes.check({id:e.id});I(e=>({...e,[t]:nt(n)}))}catch{I(e=>({...e,[t]:{verdict:`could_not_check`,at:new Date().toISOString(),retryable:!0}}))}finally{P(e=>({...e,[t]:!1})),de()}},me=(0,X.useRef)(new Set),H=(0,X.useRef)(V);H.current=V;let U=L?ue(L):null,W=U?.stage===`applied`&&re?Date.parse(U.appliedAt)+ot:null;return(0,X.useEffect)(()=>{if(W===null||!L)return;let e=$(L);if(me.current.has(e))return;let t=window.setTimeout(()=>{me.current.add(e),H.current(L)},Math.max(0,W-Date.now()));return()=>window.clearTimeout(t)},[W,L]),{record:e,report:c,reported:o,reportInvestigation:s.investigation,flagged:u.data?.flagged??(c?.flaggedContent?.length??0)>0,options:d,current:L,others:R,stage:U,stageOf:ue,nextOption:()=>A(e=>(e+1)%Math.max(1,d.stop.length)),pickOption:e=>A(d.stop.indexOf(e)),copy:async(e,t)=>{let n=it(e);if(!n)return!1;let r=await dn(n,t);return M(t=>({...t,[$(e)]:r?`ok`:`failed`})),r},apply:e=>B.mutate(e),undo:e=>pe.mutate(e),check:V,busy:B.isPending||pe.isPending,ask:p,askRun:h,earlierAsks:v,latest:x,latestRun:ee,live:te,impact:{impact:D,pending:w.isPending,slow:ne&&w.isFetching&&!D,failed:w.error?y(w.error):null,firing:z.filter(e=>i(e.status)).length,retry:()=>void w.refetch()},checkable:re,changes:ae.data,allChanges:O,setAllChanges:ie,dependencies:oe.data?.upstream??[],cleared:z.length>0&&!z.some(e=>i(e.status))}}var mn=e=>e&&e.state!==`unavailable`?e:null;function hn(e){let t=mn(e);if(!t)return`No snapshot`;let n=_n(gn(t.sources));return t.state===`not-saved`?`${n}, not saved`:n}function gn(e){let t=t=>e.filter(e=>e.status===t).length,n=t(`found`),r=t(`empty`);return{found:n,empty:r,skipped:t(`skipped`),notRead:t(`not-read`),read:n+r}}function _n(e){return[`${e.read} read`,...e.skipped?[`${e.skipped} skipped`]:[],...e.notRead?[`${e.notRead} not read`]:[]].join(`, `)}var vn={found:{text:`Data found`,tone:`ok`},empty:{text:`Nothing in the window`,tone:`neutral`},skipped:{text:`Skipped`,tone:`warn`},"not-read":{text:`Not read`,tone:`neutral`}},yn={stored:`Set in PrismaLens`,env:`From environment`,none:`Not set`},bn={found:`bg-ok`,empty:`bg-text-3`,skipped:`bg-warn`,notRead:`bg-[repeating-linear-gradient(135deg,var(--text-3)_0_2px,transparent_2px_5px)]`};function xn({c:e}){return e.found+e.empty+e.skipped+e.notRead?(0,Z.jsx)(`div`,{className:`flex h-2 gap-0.5 overflow-hidden rounded-full`,"aria-hidden":!0,children:[`found`,`empty`,`skipped`,`notRead`].map(t=>e[t]>0&&(0,Z.jsx)(`span`,{className:B(`h-full rounded-full`,bn[t]),style:{flexGrow:e[t]}},t))}):null}var Sn=[{key:`found`,label:`Data found`,Icon:re,tone:`text-ok`},{key:`empty`,label:`Nothing in the window`,Icon:O,tone:`text-text-2`},{key:`skipped`,label:`Skipped`,Icon:dt,tone:`text-warn`},{key:`notRead`,label:`Not read`,Icon:lt,tone:`text-text-2`}];function Cn({preRun:e}){if(e.state===`unavailable`)return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,"data-testid":`coverage-unavailable`,children:[(0,Z.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`b`,{className:`font-semibold`,children:`No snapshot for this run`}),(0,Z.jsx)(E,{word:{text:`No snapshot`,tone:`neutral`}})]}),(0,Z.jsx)(`p`,{className:`text-text-2`,children:`This follow-up has no stored snapshot, so it ran without telemetry.`})]});let t=e.sources,n=gn(t);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-testid":`pre-run-coverage`,children:[e.telemetrySkipped&&(0,Z.jsxs)(`p`,{className:`text-text-2`,"data-testid":`coverage-telemetry-skipped`,children:[`The telemetry read was skipped: `,e.telemetrySkipped]}),e.state===`not-saved`&&(0,Z.jsxs)(`p`,{className:`flex items-start gap-2 rounded-surface bg-warn/10 px-2.5 py-2`,"data-testid":`coverage-not-saved`,children:[(0,Z.jsx)(k,{className:`mt-0.5 size-4 shrink-0 text-warn`,"aria-hidden":!0}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`b`,{className:`font-semibold`,children:`Snapshot not saved.`}),` This run read it; a follow-up will not have it.`]})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`p`,{className:`flex items-baseline gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[28px] leading-8 font-semibold tabular-nums`,"data-testid":`coverage-read`,children:n.read}),(0,Z.jsxs)(`span`,{className:`text-title font-normal text-text-2`,children:[n.read===1?`source`:`sources`,` read before the run`]})]}),(0,Z.jsx)(`p`,{className:`sr-only`,"data-testid":`coverage-line`,children:_n(n)}),(n.skipped>0||n.notRead>0)&&(0,Z.jsx)(`p`,{className:`text-text-2`,"aria-hidden":!0,children:[...n.skipped?[`${n.skipped} skipped`]:[],...n.notRead?[`${n.notRead} not read`]:[]].join(` · `)})]}),(0,Z.jsx)(xn,{c:n}),(0,Z.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-meta`,children:Sn.filter(e=>n[e.key]>0).map(({key:e,label:t,Icon:r,tone:i})=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(r,{className:B(`size-3.5`,i),"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`text-text-2`,children:t}),(0,Z.jsx)(`b`,{className:`font-semibold tabular-nums`,children:n[e]})]},e))}),t.length>0&&(0,Z.jsx)(`ul`,{className:`flex flex-col divide-y divide-hairline`,"data-testid":`coverage-sources`,children:t.map((e,t)=>(0,Z.jsx)(wn,{source:e},t))}),(0,Z.jsx)(Tn,{preRun:e})]})}function wn({source:e}){let[t,n]=(0,X.useState)(!1),i=vn[e.status];return(0,Z.jsxs)(`li`,{className:`py-2`,"data-testid":`coverage-source`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,Z.jsx)(se,{kind:e.kind,small:!0}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,Z.jsx)(`b`,{className:`font-semibold`,children:e.label}),e.services?.length?(0,Z.jsx)(`span`,{className:`text-text-2`,children:e.services.join(`, `)}):null,(0,Z.jsx)(E,{word:i,testId:`coverage-result`})]}),(0,Z.jsxs)(`p`,{className:`text-meta text-text-2`,dir:`auto`,children:[e.detail,e.truncated?` (truncated)`:``]})]}),e.status===`skipped`&&(0,Z.jsx)(W,{variant:`secondary`,size:`sm`,asChild:!0,children:(0,Z.jsx)(r,{to:`/settings`,search:{tab:`sources`,...e.connectionId?{source:e.connectionId}:{}},"data-testid":`coverage-fix`,children:`Fix`})}),(0,Z.jsx)(W,{variant:`text`,size:`icon-sm`,"aria-expanded":t,"aria-label":`Details of ${e.label}`,onClick:()=>n(!t),children:(0,Z.jsx)(P,{className:B(`size-4`,t&&`rotate-180`),"aria-hidden":!0})})]}),t&&(0,Z.jsxs)(`dl`,{className:`mt-2 ml-8 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-meta`,children:[(0,Z.jsx)(`dt`,{className:`text-text-3`,children:`Connection`}),(0,Z.jsxs)(`dd`,{children:[e.label,` · `,D(e.kind)]}),(0,Z.jsx)(`dt`,{className:`text-text-3`,children:`Deployment`}),(0,Z.jsx)(`dd`,{children:e.deployment??`Any deployment`}),(0,Z.jsx)(`dt`,{className:`text-text-3`,children:`Credential`}),(0,Z.jsxs)(`dd`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(oe,{text:yn[e.credentialFrom??`none`]??`Not set`}),e.overridesEnv&&(0,Z.jsxs)(`span`,{className:`text-text-2`,"data-testid":`coverage-over`,children:[`Over `,(0,Z.jsx)(`code`,{className:`font-mono`,children:e.overridesEnv})]})]})]})]})}function Tn({preRun:e}){let t=e.notConfigured.map(e=>`No ${D(e.kind)} is set up for ${e.services.join(`, `)||`this service`}.`);return t.length?(0,Z.jsx)(`ul`,{className:`text-meta text-text-3`,"data-testid":`coverage-notes`,children:t.map(e=>(0,Z.jsx)(`li`,{children:e},e))}):null}var En={Confirmed:`text-ok`,Likely:`text-accent`,Unconfirmed:`text-warn`,"No cause found":`text-text-3`};function Dn({o:e,onInvestigate:t}){let n=q(3e4),{incident:i,runs:a}=e.record,[o,s]=(0,X.useState)(!1),c=e.report,l=e.reported,u=e.latest,d=u&&e.latestRun.state===`failed`&&u.id!==l?.id?u:null,f=c?_t(c).word:null,p=l??d,m=(l?e.reportInvestigation?.preRun:e.latestRun.investigation?.preRun)??null,h=e=>({to:`/incidents/$id/conversation`,params:{id:i.id},search:{investigation:e}});return(0,Z.jsx)(xt,{title:`Why`,testId:`why-card`,sub:(0,Z.jsxs)(Z.Fragment,{children:[f&&(0,Z.jsx)(`span`,{className:B(`shrink-0 text-meta font-medium`,En[f]),"data-testid":`why-tag`,children:f===`No cause found`?`No cause named`:f}),!f&&d&&(0,Z.jsx)(`span`,{className:`shrink-0 text-meta font-medium text-danger`,"data-testid":`why-tag`,children:`No cause yet`}),l&&(0,Z.jsxs)(`span`,{className:`min-w-0 truncate text-meta text-text-3`,children:[`From `,J(a,l),`,`,` `,Ne(l.completedAt??l.createdAt,n)]})]}),actions:(0,Z.jsxs)(Z.Fragment,{children:[a.length>0&&!e.live&&(0,Z.jsx)(W,{variant:`secondary`,className:`h-6 shrink-0 bg-surface-2 px-2 text-meta hover:bg-surface-3`,onClick:t,"data-testid":`why-investigate`,children:`Investigate again`}),p&&(0,Z.jsxs)(r,{...h(p.id),className:`inline-flex min-h-6 shrink-0 items-center text-meta text-accent hover:underline`,"data-testid":`why-transcript`,children:[J(a,p),` transcript`]})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[e.live&&(0,Z.jsxs)(r,{...h(e.live.id),className:`flex min-w-0 items-center gap-2 rounded-control bg-live/10 px-2.5 py-1.5 whitespace-nowrap transition-colors duration-(--dur-instant) hover:bg-live/15`,"data-testid":`why-live`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`breathe size-1.5 shrink-0 rounded-full bg-live`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[J(a,e.live),` `,e.latestRun.awaiting||e.live.awaitingApprovalAt?`waits for your approval in the box below.`:`is investigating.`,c?` This finding stands until it reports.`:` Its finding lands here when it reports.`]}),(0,Z.jsx)(`span`,{className:`shrink-0 text-meta text-accent`,children:`Watch`})]}),d&&(0,Z.jsx)(On,{o:e,name:J(a,d),standing:!!c}),c?(0,Z.jsx)(kn,{o:e,lasting:o,setLasting:s}):!e.live&&!d?(0,Z.jsx)(`p`,{className:`text-text-3`,"data-testid":`why-none`,children:a.length===0?`No run yet. A run reads the alert, the code and the telemetry, then names a likely cause.`:`No run has reached a finding yet.`}):null,m&&(0,Z.jsx)(`section`,{"aria-label":`Read before the run`,className:`mt-1 rounded-surface bg-surface-2 px-3 py-3`,"data-testid":`why-coverage`,children:(0,Z.jsx)(Cn,{preRun:m})})]})})}function On({o:e,name:t,standing:n}){let r=e.latestRun.investigation,i=(0,X.useMemo)(()=>Ie(e.latestRun.events,{cwd:r?.workspace?.cwd,ended:!0}),[e.latestRun.events,r?.workspace?.cwd]),a=r?.error??e.latest?.error??null,o=He(`The agent`,a),s=z().data?.harnesses.find(t=>t.id===e.latest?.harness),c=M(a,s?.label,s?.loginHint),l=(r?.endReason??e.latest?.endReason)===`interrupted`;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`rounded-surface bg-danger/12 px-3 py-2.5`,"data-row":`What failed`,"data-testid":`why-failed`,children:[(0,Z.jsxs)(`div`,{className:`font-semibold text-danger`,children:[l?`${t} was interrupted when PrismaLens restarted`:`${t} stopped before a finding`,n?`; the finding below stands`:``]}),(0,Z.jsx)(`div`,{className:`text-text-1`,children:l?N(a)??`Its last command may or may not have completed.`:c.next?`${c.what} ${c.next}`:o.said})]}),!n&&i.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`text-meta text-text-3`,children:`Its last steps`}),(0,Z.jsx)(`ol`,{className:`flex flex-col`,children:i.slice(-3).map(e=>(0,Z.jsxs)(`li`,{className:`flex gap-2.5 px-1 py-1.5 shadow-[inset_0_-1px_0_var(--hairline)]`,"data-row":e.title,children:[(0,Z.jsx)(`span`,{className:`w-16 shrink-0 text-meta text-text-3 tabular-nums`,children:I(e.at)}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-text-2`,children:e.title})]},e.n))})]})]})}function kn({o:e,lasting:t,setLasting:n}){let i=e.report,{incident:a}=e.record;if(!i||!e.reported)return null;let o=e.reportInvestigation?.workspace?.cwd,s=i.hypotheses.find(e=>e.status!==`refuted`)?.evidence??[],c=i.ruledOut.length,l=i.coverage.notQueried.length,u=e.options.lasting,d=e.reported.id;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`line-clamp-3 text-[15px] leading-[22px]`,dir:`auto`,"data-testid":`why-cause`,children:nn(i.rootCause??i.summary)}),s.length===0?(0,Z.jsx)(`p`,{className:`text-text-3`,children:`No evidence recorded for this conclusion.`}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1`,"data-testid":`why-evidence`,children:s.map((t,n)=>{let i=A(t.source,o);return(0,Z.jsx)(`li`,{"data-row":`Evidence`,children:(0,Z.jsx)(R,{label:t.observation,children:(0,Z.jsxs)(r,{to:`/incidents/$id/conversation`,params:{id:a.id},search:{investigation:d,...t.toolCallId?{call:t.toolCallId}:{},...je(t.source,e.reportInvestigation?.workspace)?{file:t.source}:{}},className:`flex min-w-0 items-baseline gap-2.5 rounded-control bg-surface-2 px-2.5 py-1.5 transition-colors duration-(--dur-instant) hover:bg-surface-3`,"data-testid":`why-evidence-row`,children:[(0,Z.jsx)(`span`,{className:`w-[52px] shrink-0 text-meta text-text-3`,children:t.direction===`supports`?`For`:`Against`}),(0,Z.jsx)(`span`,{className:`line-clamp-2 min-w-0 flex-1`,dir:`auto`,children:nn(t.observation)}),(0,Z.jsx)(`span`,{className:`max-w-[40%] shrink-0 truncate font-mono text-mono text-text-3`,children:i})]})})},n)})}),t&&u&&(0,Z.jsxs)(`div`,{id:`lasting-fix`,className:`rounded-control bg-surface-2 px-2.5 py-2`,"data-row":`Lasting fix`,"data-testid":`why-lasting`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,dir:`auto`,children:u.title}),(0,Z.jsx)(`p`,{className:`text-text-2`,dir:`auto`,children:nn(u.detail)}),it(u)?(0,Z.jsx)(`code`,{className:`mt-1 block font-mono text-mono break-all whitespace-pre-wrap text-text-1`,children:it(u)}):Ye(u)&&(0,Z.jsx)(`p`,{className:`text-text-2`,dir:`auto`,children:Ye(u)})]}),(0,Z.jsxs)(`div`,{className:`flex gap-4.5 text-meta whitespace-nowrap`,children:[(0,Z.jsx)(r,{to:`/incidents/$id/conversation`,params:{id:a.id},search:{investigation:d},className:`inline-flex min-h-6 items-center text-text-2 hover:underline`,"data-testid":`why-ruled-out`,children:c===0?`Nothing ruled out`:`${c} ruled out`}),l>0&&(0,Z.jsx)(r,{to:`/incidents/$id/conversation`,params:{id:a.id},search:{investigation:d},className:`inline-flex min-h-6 min-w-0 items-center text-warn hover:underline`,title:i.coverage.notQueried.join(`, `),"data-testid":`why-unchecked`,children:(0,Z.jsxs)(`span`,{className:`truncate`,children:[`Not checked: `,i.coverage.notQueried[0],l>1&&` and ${l-1} more`]})}),(0,Z.jsx)(`span`,{className:`flex-1`}),u&&(0,Z.jsx)(`button`,{type:`button`,"aria-expanded":t,"aria-controls":`lasting-fix`,onClick:()=>{n(!t),window.setTimeout(()=>document.getElementById(`lasting-fix`)?.scrollIntoView({block:`nearest`,behavior:`smooth`}),50)},className:`text-accent hover:underline`,"data-testid":`why-lasting-toggle`,children:`Lasting fix`})]})]})}function An(e,t,n=`text/markdown;charset=utf-8`){let r=URL.createObjectURL(new Blob([t],{type:n})),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),URL.revokeObjectURL(r)}function jn({open:e,onOpenChange:t}){let n=Ge(),{toast:r}=K(),[i,a]=(0,X.useState)(``);return(0,Z.jsx)(be,{open:e,onOpenChange:t,children:(0,Z.jsxs)(_e,{"data-testid":`note-dialog`,children:[(0,Z.jsxs)(he,{children:[(0,Z.jsx)(ve,{children:`Add a note`}),(0,Z.jsx)(ye,{children:`It goes on the incident's timeline. The agent doesn't get it as a message.`})]}),(0,Z.jsx)(j,{value:i,onChange:e=>a(e.target.value),rows:4,"aria-label":`Note`,"data-testid":`note-text`}),(0,Z.jsxs)(ge,{children:[(0,Z.jsx)(W,{variant:`text`,onClick:()=>t(!1),children:`Cancel`}),(0,Z.jsx)(W,{onClick:()=>n.addNote(i.trim(),()=>{a(``),t(!1)},e=>r({title:`Note not saved`,description:y(e),variant:`destructive`})),disabled:!i.trim()||n.isSavingNote,"data-testid":`note-save`,children:`Add note`})]})]})})}function Mn(e,t){let n=e.service?`, ${e.service.displayName||e.service.name}`:``,r=[`INC-${e.number} ${e.title}${n}. Severity ${c[e.severity]}.`];if(e.mergedInto)r.push(`Merged into INC-${e.mergedInto.number}.`);else if(e.status===`closed`)r.push(`Resolved.`);else if(e.status===`resolved`)r.push(`Alerts cleared.`);else{let n=Ue(e.alerts??[],t);n&&r.push(`${n.text}.`)}let i=(e.investigations??[]).filter(e=>(e.kind??`investigation`)===`investigation`),a=e.actualCause??(e=>e.reduce((e,t)=>!e||t.createdAt>e.createdAt?t:e,null))(i.filter(e=>e.rootCause))?.rootCause;return a?r.push(`${e.actualCause?`Cause`:`Likely cause`}: ${a}`):i.some(e=>x(e.status))?r.push(`An investigation is running; no cause yet.`):r.push(`No cause found yet.`),r.join(`
2
2
  `)}function Nn({open:e,onOpenChange:t,incident:n,now:r}){let i=f(),{toast:a}=K(),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1);e!==u&&(d(e),e&&(s(Mn(n,r)),l(!1)));let p=(0,X.useRef)(null),m=(0,X.useId)(),h=_({...g.timeline.create.mutationOptions(),onSuccess:()=>{i.invalidateQueries({queryKey:le.all()}),t(!1)},onError:e=>a({title:`Copied, but not logged`,description:y(e),variant:`destructive`})});return(0,Z.jsx)(be,{open:e,onOpenChange:t,children:(0,Z.jsxs)(_e,{className:`flex h-[360px] w-[min(560px,calc(100%-2rem))] flex-col`,"data-testid":`status-update-dialog`,children:[(0,Z.jsxs)(he,{children:[(0,Z.jsx)(ve,{children:`Status update`}),(0,Z.jsx)(ye,{children:`Drafted from what is recorded on this incident. Copying adds it to the timeline.`})]}),(0,Z.jsx)(`label`,{htmlFor:m,className:`sr-only`,children:`Update text`}),(0,Z.jsx)(j,{id:m,ref:p,value:o,onChange:e=>s(e.target.value),className:`min-h-0 flex-1 resize-none`,dir:`auto`,"data-testid":`status-update-text`}),c&&(0,Z.jsx)(`p`,{className:`text-meta text-warn`,role:`alert`,"data-testid":`status-update-blocked`,children:`This browser blocked the clipboard. The text is selected: press Ctrl+C, then close. Nothing was logged.`}),(0,Z.jsxs)(ge,{children:[(0,Z.jsx)(W,{variant:`text`,onClick:()=>t(!1),children:`Cancel`}),(0,Z.jsx)(W,{variant:`primary`,disabled:!o.trim()||h.isPending,onClick:async()=>{let e=o.trim();try{if(!navigator.clipboard)throw Error(`no clipboard`);await navigator.clipboard.writeText(e)}catch{l(!0),p.current?.focus(),p.current?.select();return}h.mutate({incidentId:n.id,type:`comment`,title:`Status update`,description:e,source:`user`})},"data-testid":`status-update-copy`,children:`Copy and log it`})]})]})})}var Pn=Object.keys(c);function Fn({incident:e,view:t,reportRunId:n,onResolve:i,onReopen:l,onEditCause:u,onInvestigateAgain:d,trailing:p}){Ae(H(e)?`${e.title} / ${t}`:`INC-${e.number} ${Me(e.title)} / ${t}`);let m=S();qe((0,X.useCallback)(()=>void m({to:`/threads`}),[m]));let h=q(3e4),{toast:b}=K(),x=f(),[E,D]=(0,X.useState)(!1),[re,O]=(0,X.useState)(!1),[k,oe]=(0,X.useState)(!1),[se,A]=(0,X.useState)(!1),j=Ue(e.alerts??[],h),M=H(e),N=e.mergedInto,P=!e.mergedIntoId&&o(e.status),F=!N&&s(`close`,e.status),I=!N&&s(`reopen`,e.status),L=_({...g.incidents.update.mutationOptions(),onSuccess:()=>Promise.all([x.invalidateQueries({queryKey:ce.all()}),x.invalidateQueries({queryKey:le.all()})]),onError:e=>b({title:`Severity not changed`,description:y(e),variant:`destructive`})}),z=_({...g.investigations.exportMarkdown.mutationOptions(),onSuccess:({filename:e,markdown:t})=>An(e,t),onError:e=>b({title:`Export failed`,description:y(e),variant:`destructive`})});return(0,Z.jsxs)(`header`,{className:`flex h-(--header-h) min-w-0 shrink-0 items-center gap-3 bg-surface-1 pr-3 pl-2 whitespace-nowrap`,"data-testid":`incident-header`,"data-title-row":!0,children:[(0,Z.jsx)(R,{label:`Back to threads`,children:(0,Z.jsx)(W,{variant:`text`,size:`icon`,className:`shrink-0`,asChild:!0,children:(0,Z.jsx)(r,{to:`/threads`,"aria-label":`Back to threads`,"data-testid":`incident-back`,children:(0,Z.jsx)(ue,{className:`size-4`})})})}),(0,Z.jsxs)(`h1`,{className:`min-w-[104px] shrink truncate text-title`,children:[!M&&(0,Z.jsxs)(`span`,{className:`sr-only`,children:[`INC-`,e.number,` `]}),(0,Z.jsx)(R,{label:`The incident's latest run`,children:(0,Z.jsx)(r,{to:`/incidents/$id`,params:{id:e.id},className:`inline-flex min-h-6 max-w-full items-center underline-offset-[3px] hover:underline`,"data-testid":`crumb-incident`,dir:`auto`,children:M?e.title:Me(e.title)})})]}),(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-text-3 max-sm:hidden`,children:`/`}),(0,Z.jsx)(`span`,{className:`shrink-0 text-body font-semibold max-sm:hidden`,"aria-current":`page`,"data-testid":`crumb-view`,children:t}),!M&&(0,Z.jsx)(`span`,{className:`shrink-0 rounded-control bg-surface-2 px-2 text-meta font-medium`,style:{color:`var(--sev-${e.severity})`},"data-testid":`header-severity`,children:c[e.severity]}),M?null:N?(0,Z.jsxs)(r,{to:`/incidents/$id`,params:{id:N.id},className:`shrink-0 text-text-3 underline-offset-2 hover:text-text-1 hover:underline max-sm:hidden`,"data-testid":`header-state`,children:[`Merged into INC-`,N.number]}):a(e.status)?(0,Z.jsx)(`span`,{className:`shrink-0 text-text-3 max-sm:hidden`,"data-testid":`header-state`,children:v[e.status]}):j&&(0,Z.jsxs)(`span`,{className:B(`flex shrink-0 items-center gap-1.5 max-lg:hidden`,j.firing?`text-danger`:`text-text-3`),"data-testid":`header-firing`,children:[j.firing&&(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`size-[7px] rounded-full bg-danger`}),j.text]}),(0,Z.jsx)(`span`,{className:`flex-1`}),p,F&&!M&&(0,Z.jsx)(W,{variant:`secondary`,className:`h-7 shrink-0 bg-surface-2 hover:bg-surface-3 max-sm:hidden`,onClick:()=>j?.firing?O(!0):i(),"data-testid":`header-resolve`,children:`Resolve`}),I&&(0,Z.jsx)(W,{variant:`secondary`,className:`h-7 shrink-0 bg-surface-2 hover:bg-surface-3`,onClick:l,"data-testid":`header-reopen`,children:`Reopen`}),(0,Z.jsxs)(De,{modal:!1,children:[(0,Z.jsx)(Ce,{asChild:!0,children:(0,Z.jsx)(W,{variant:`secondary`,size:`icon`,className:`size-7 shrink-0 bg-surface-2 text-text-2 hover:bg-surface-3`,"aria-label":`More actions`,"data-testid":`header-more`,children:(0,Z.jsx)(fe,{className:`size-4`})})}),(0,Z.jsxs)(Te,{align:`end`,className:`w-60`,children:[F&&!M&&(0,Z.jsx)(G,{className:`sm:hidden`,onClick:()=>j?.firing?O(!0):i(),"data-testid":`header-resolve-menu`,children:`Resolve`}),(0,Z.jsx)(G,{onClick:()=>A(!0),"data-testid":`header-note`,children:`Add a note`}),(0,Z.jsx)(G,{onClick:()=>oe(!0),"data-testid":`header-status-update`,children:`Write a status update`}),!N&&(0,Z.jsxs)(Se,{children:[(0,Z.jsx)(Oe,{"data-testid":`header-severity-menu`,children:`Change severity`}),(0,Z.jsx)(we,{children:(0,Z.jsx)(xe,{value:e.severity,onValueChange:t=>t!==e.severity&&L.mutate({id:e.id,severity:t}),children:Pn.map(e=>(0,Z.jsx)(Ee,{value:e,disabled:L.isPending,"data-testid":`header-severity-${e}`,children:c[e]},e))})})]}),d&&(0,Z.jsx)(G,{onClick:d,"data-testid":`header-investigate-again`,children:`Investigate again`}),P&&(0,Z.jsx)(G,{onClick:()=>D(!0),"data-testid":`header-merge`,children:`Merge into another incident`}),n&&(0,Z.jsx)(G,{disabled:z.isPending,onClick:()=>z.mutate({id:n}),"data-testid":`header-export`,children:`Export report as Markdown`}),N&&(0,Z.jsx)(G,{asChild:!0,children:(0,Z.jsxs)(r,{to:`/incidents/$id`,params:{id:N.id},children:[`Merged into INC-`,N.number]})}),e.status===`closed`&&(0,Z.jsx)(G,{onClick:u,"data-testid":`header-edit-cause`,children:`Edit cause`})]})]}),(0,Z.jsx)(jn,{open:se,onOpenChange:A}),(0,Z.jsx)(Nn,{open:k,onOpenChange:oe,incident:e,now:h}),(0,Z.jsx)(ne,{open:re,onOpenChange:O,children:(0,Z.jsxs)(ie,{"data-testid":`resolve-firing-confirm`,children:[(0,Z.jsxs)(T,{children:[(0,Z.jsx)(C,{children:`Resolve while the alert is firing?`}),(0,Z.jsxs)(te,{children:[e.title,` is still firing. If it keeps firing after you resolve, PrismaLens opens a new incident and links it to this one.`]})]}),(0,Z.jsxs)(w,{children:[(0,Z.jsx)(ee,{children:`Cancel`}),(0,Z.jsx)(ae,{className:U({variant:`danger-fill`}),onClick:i,"data-testid":`resolve-anyway`,children:`Resolve anyway`})]})]})}),P&&(0,Z.jsx)(V,{open:E,onOpenChange:D,incident:e})]})}export{pn as a,Xt as c,vt as d,bt as f,hn as i,Ut as l,Dn as n,sn as o,mn as r,tn as s,Fn as t,Rt as u};
@@ -1 +1 @@
1
- import{Xt as e,_t as t,c as n,gt as r}from"./desktop-Bqso9PNq.js";import{a as i,n as a,t as o}from"./jsx-runtime-Wy9s6hX0.js";import{i as s}from"./WorkspaceFields-DCSJCThm.js";import{E as c}from"./source-words-B5oOdiQU.js";import{c as l}from"./select-98_n4DVz.js";import{r as u}from"./RingTick-DkMvLoUV.js";import{t as d}from"./button-DmIfWVZ8.js";var f=i(a()),p=o();function m({runId:e}){let r=n.runWorkspaces.listForRun.queryOptions({input:{runId:e}}),i=t(r),a=i.data?.workspaces??[];return a.length?(0,p.jsxs)(`section`,{className:`pool mt-3 px-3 py-2 text-body`,"data-testid":`kept-workspaces`,children:[(0,p.jsx)(`p`,{className:`text-meta text-text-2`,children:a.length===1?`This run's workspace was kept`:`${a.length} of this run's workspaces were kept`}),(0,p.jsx)(h,{workspaces:a.map(t=>({...t,runId:e})),canEdit:i.data?.canEdit??!1,refresh:r.queryKey})]}):null}function h({workspaces:t,canEdit:i,refresh:a}){let o=e(),[m,h]=(0,f.useState)(null),g=r(n.runWorkspaces.open.mutationOptions()),_=r({...n.runWorkspaces.remove.mutationOptions(),onSettled:()=>{o.invalidateQueries({queryKey:a}),o.invalidateQueries({queryKey:n.runWorkspaces.removals.key()})}}),v=async e=>{let t=await _.mutateAsync(e);if(!t.removed)throw Error(`Not removed: ${s[t.reason]??t.reason}.`)};return(0,p.jsxs)(p.Fragment,{children:[t.map(e=>(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 py-1.5`,children:[(0,p.jsxs)(`div`,{className:`min-w-0 flex-1 basis-64`,children:[(0,p.jsx)(l,{className:`block truncate`,children:e.dir}),(0,p.jsxs)(`span`,{className:`text-meta text-text-3`,children:[s[e.reason]??e.reason,`, since`,` `,new Date(e.keptAt).toLocaleString()]})]}),i&&(0,p.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,p.jsx)(d,{size:`sm`,variant:`secondary`,disabled:g.isPending,onClick:()=>g.mutate({runId:e.runId,dir:e.dir}),children:`Open folder`}),(0,p.jsx)(d,{size:`sm`,variant:`text`,onClick:()=>h({runId:e.runId,dir:e.dir}),children:`Remove`})]})]},e.dir)),(0,p.jsx)(u,{error:g.error}),(0,p.jsx)(c,{open:m!==null,onOpenChange:e=>!e&&h(null),title:`Remove this workspace?`,description:(0,p.jsx)(`p`,{children:`Its uncommitted changes and new files are deleted with it.`}),confirmLabel:`Remove`,isPending:_.isPending,onConfirm:()=>m?v(m):void 0})]})}export{m as n,h as t};
1
+ import{Xt as e,_t as t,c as n,gt as r}from"./desktop-yb-lqHMd.js";import{a as i,n as a,t as o}from"./jsx-runtime-Wy9s6hX0.js";import{i as s}from"./WorkspaceFields-CXSg1krp.js";import{E as c}from"./source-words-CCeTLwOy.js";import{c as l}from"./select-hkRu0Dxf.js";import{r as u}from"./RingTick-Zd_duqBv.js";import{t as d}from"./button-DmIfWVZ8.js";var f=i(a()),p=o();function m({runId:e}){let r=n.runWorkspaces.listForRun.queryOptions({input:{runId:e}}),i=t(r),a=i.data?.workspaces??[];return a.length?(0,p.jsxs)(`section`,{className:`pool mt-3 px-3 py-2 text-body`,"data-testid":`kept-workspaces`,children:[(0,p.jsx)(`p`,{className:`text-meta text-text-2`,children:a.length===1?`This run's workspace was kept`:`${a.length} of this run's workspaces were kept`}),(0,p.jsx)(h,{workspaces:a.map(t=>({...t,runId:e})),canEdit:i.data?.canEdit??!1,refresh:r.queryKey})]}):null}function h({workspaces:t,canEdit:i,refresh:a}){let o=e(),[m,h]=(0,f.useState)(null),g=r(n.runWorkspaces.open.mutationOptions()),_=r({...n.runWorkspaces.remove.mutationOptions(),onSettled:()=>{o.invalidateQueries({queryKey:a}),o.invalidateQueries({queryKey:n.runWorkspaces.removals.key()})}}),v=async e=>{let t=await _.mutateAsync(e);if(!t.removed)throw Error(`Not removed: ${s[t.reason]??t.reason}.`)};return(0,p.jsxs)(p.Fragment,{children:[t.map(e=>(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 py-1.5`,children:[(0,p.jsxs)(`div`,{className:`min-w-0 flex-1 basis-64`,children:[(0,p.jsx)(l,{className:`block truncate`,children:e.dir}),(0,p.jsxs)(`span`,{className:`text-meta text-text-3`,children:[s[e.reason]??e.reason,`, since`,` `,new Date(e.keptAt).toLocaleString()]})]}),i&&(0,p.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,p.jsx)(d,{size:`sm`,variant:`secondary`,disabled:g.isPending,onClick:()=>g.mutate({runId:e.runId,dir:e.dir}),children:`Open folder`}),(0,p.jsx)(d,{size:`sm`,variant:`text`,onClick:()=>h({runId:e.runId,dir:e.dir}),children:`Remove`})]})]},e.dir)),(0,p.jsx)(u,{error:g.error}),(0,p.jsx)(c,{open:m!==null,onOpenChange:e=>!e&&h(null),title:`Remove this workspace?`,description:(0,p.jsx)(`p`,{children:`Its uncommitted changes and new files are deleted with it.`}),confirmLabel:`Remove`,isPending:_.isPending,onConfirm:()=>m?v(m):void 0})]})}export{m as n,h as t};
@@ -1 +1 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-Wy9s6hX0.js";import{A as r,P as i,V as a,Xt as o,_t as s,c,gt as l,r as u,z as d}from"./desktop-Bqso9PNq.js";import{n as f}from"./useNavigate-I5E4IRt2.js";import{A as p,D as m,E as h,O as g,T as _,k as v,q as y}from"./AgentDetail-DNNZ2RSQ.js";import{F as b}from"./Hint-BCpVhAvV.js";import{c as x}from"./select-98_n4DVz.js";import{t as S}from"./button-DmIfWVZ8.js";import{C,S as w,b as T,w as E,x as D,y as O}from"./use-repositories-orpc-c6hPOKjE.js";import{n as k}from"./CopyButton-DKP5JHET.js";function A(e){let t=a(e,{kind:`investigation`});return i(e.status,t?.status,{reason:e.reopenReason,at:e.reopenedAt,latestRunAt:a(e)?.createdAt},r(e))}var j=e(t()),M=n(),N=e=>e.service?.displayName||e.service?.name||e.services?.[0]?.displayName||e.services?.[0]?.name;function P({open:e,onOpenChange:t,incident:n}){let[r,i]=(0,j.useState)(null),a=f(),A=o(),{toast:P}=k(),{data:F,isLoading:I}=s({...c.incidents.list.queryOptions({input:{open:!0,limit:100}}),enabled:e}),L=(F?.data??[]).filter(e=>e.id!==n.id),R=l({...c.incidents.merge.mutationOptions(),onSuccess:e=>{z(!1),a({to:`/incidents/$id`,params:{id:e.id}}),A.invalidateQueries({queryKey:b.all()})},onError:e=>P({title:`Not merged`,description:u(e),variant:`destructive`})}),z=e=>{e||i(null),t(e)};return(0,M.jsx)(O,{open:e,onOpenChange:z,children:(0,M.jsx)(T,{className:r?void 0:`h-[400px] gap-0 p-0`,"data-testid":`merge-dialog`,children:r?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(C,{children:[(0,M.jsxs)(E,{children:[`Merge INC-`,n.number,` into INC-`,r.number,`?`]}),(0,M.jsx)(D,{"data-testid":`merge-sentence`,children:y(n,r,N(n))})]}),(0,M.jsxs)(w,{children:[(0,M.jsx)(S,{variant:`text`,onClick:()=>i(null),children:`Back`}),(0,M.jsx)(S,{variant:`primary`,disabled:R.isPending,onClick:()=>R.mutate({id:n.id,targetId:r.id}),"data-testid":`confirm-merge`,children:`Merge`})]})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(C,{className:`sr-only`,children:[(0,M.jsxs)(E,{children:[`Merge INC-`,n.number,` into`]}),(0,M.jsx)(D,{children:`An open incident`})]}),(0,M.jsxs)(_,{className:`min-h-0`,loop:!0,children:[(0,M.jsx)(g,{placeholder:`Search open incidents`,"data-testid":`merge-search`}),(0,M.jsxs)(p,{label:`Open incidents`,className:`[scrollbar-width:thin]`,children:[(0,M.jsx)(h,{children:I?`Loading`:`No other open incident.`}),(0,M.jsx)(m,{children:L.map(e=>{let t=N(e);return(0,M.jsxs)(v,{value:`INC-${e.number} ${e.title} ${t??``}`,onSelect:()=>i(e),"data-testid":`merge-option`,"data-number":e.number,children:[(0,M.jsxs)(x,{className:`shrink-0 text-meta text-text-3`,children:[`INC-`,e.number]}),(0,M.jsxs)(`span`,{className:`grid min-w-0 flex-1`,children:[(0,M.jsx)(`span`,{className:`truncate`,children:e.title}),(0,M.jsxs)(`span`,{className:`truncate text-meta text-text-3`,children:[t??`No service`,d(e.investigations?.[0]?.status??``)?`, run working`:``]})]})]},e.id)})})]})]})]})})})}export{A as n,P as t};
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-Wy9s6hX0.js";import{A as r,P as i,V as a,Xt as o,_t as s,c,gt as l,r as u,z as d}from"./desktop-yb-lqHMd.js";import{n as f}from"./useNavigate-I5E4IRt2.js";import{A as p,D as m,E as h,O as g,T as _,k as v,q as y}from"./AgentDetail-CbhnttdO.js";import{F as b}from"./Hint-Od6cnmvm.js";import{c as x}from"./select-hkRu0Dxf.js";import{t as S}from"./button-DmIfWVZ8.js";import{C,S as w,b as T,w as E,x as D,y as O}from"./use-repositories-orpc-Ban_zGD7.js";import{n as k}from"./CopyButton-DKP5JHET.js";function A(e){let t=a(e,{kind:`investigation`});return i(e.status,t?.status,{reason:e.reopenReason,at:e.reopenedAt,latestRunAt:a(e)?.createdAt},r(e))}var j=e(t()),M=n(),N=e=>e.service?.displayName||e.service?.name||e.services?.[0]?.displayName||e.services?.[0]?.name;function P({open:e,onOpenChange:t,incident:n}){let[r,i]=(0,j.useState)(null),a=f(),A=o(),{toast:P}=k(),{data:F,isLoading:I}=s({...c.incidents.list.queryOptions({input:{open:!0,limit:100}}),enabled:e}),L=(F?.data??[]).filter(e=>e.id!==n.id),R=l({...c.incidents.merge.mutationOptions(),onSuccess:e=>{z(!1),a({to:`/incidents/$id`,params:{id:e.id}}),A.invalidateQueries({queryKey:b.all()})},onError:e=>P({title:`Not merged`,description:u(e),variant:`destructive`})}),z=e=>{e||i(null),t(e)};return(0,M.jsx)(O,{open:e,onOpenChange:z,children:(0,M.jsx)(T,{className:r?void 0:`h-[400px] gap-0 p-0`,"data-testid":`merge-dialog`,children:r?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(C,{children:[(0,M.jsxs)(E,{children:[`Merge INC-`,n.number,` into INC-`,r.number,`?`]}),(0,M.jsx)(D,{"data-testid":`merge-sentence`,children:y(n,r,N(n))})]}),(0,M.jsxs)(w,{children:[(0,M.jsx)(S,{variant:`text`,onClick:()=>i(null),children:`Back`}),(0,M.jsx)(S,{variant:`primary`,disabled:R.isPending,onClick:()=>R.mutate({id:n.id,targetId:r.id}),"data-testid":`confirm-merge`,children:`Merge`})]})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(C,{className:`sr-only`,children:[(0,M.jsxs)(E,{children:[`Merge INC-`,n.number,` into`]}),(0,M.jsx)(D,{children:`An open incident`})]}),(0,M.jsxs)(_,{className:`min-h-0`,loop:!0,children:[(0,M.jsx)(g,{placeholder:`Search open incidents`,"data-testid":`merge-search`}),(0,M.jsxs)(p,{label:`Open incidents`,className:`[scrollbar-width:thin]`,children:[(0,M.jsx)(h,{children:I?`Loading`:`No other open incident.`}),(0,M.jsx)(m,{children:L.map(e=>{let t=N(e);return(0,M.jsxs)(v,{value:`INC-${e.number} ${e.title} ${t??``}`,onSelect:()=>i(e),"data-testid":`merge-option`,"data-number":e.number,children:[(0,M.jsxs)(x,{className:`shrink-0 text-meta text-text-3`,children:[`INC-`,e.number]}),(0,M.jsxs)(`span`,{className:`grid min-w-0 flex-1`,children:[(0,M.jsx)(`span`,{className:`truncate`,children:e.title}),(0,M.jsxs)(`span`,{className:`truncate text-meta text-text-3`,children:[t??`No service`,d(e.investigations?.[0]?.status??``)?`, run working`:``]})]})]},e.id)})})]})]})]})})})}export{A as n,P as t};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./useNavigate-I5E4IRt2.js";import{a as t,n,t as r}from"./jsx-runtime-Wy9s6hX0.js";import{c as i,d as a,p as o}from"./AgentDetail-DNNZ2RSQ.js";import{I as s,L as c,R as l}from"./Hint-BCpVhAvV.js";import{r as u}from"./use-threads-orpc-rBrvQXJf.js";import{i as d,r as f,t as p}from"./Composer-MAXlRLhF.js";var m=t(n(),1),h=r();function g({subject:t,branch:n,incident:r=null,note:g=!1,top:_,slash:v,place:y,placeholder:b,autoFocus:x=!0,onRepeat:S}){let C=o(),w=u(),T=s(),E=c(),D=l(),O=e(),[k,A]=(0,m.useState)({}),j=(0,m.useRef)(null),M=C.harnesses.find(e=>e.id===k.harness)??C.effective,N=M?.id,P=k.model??(N?C.models[N]??C.model:``)??``,F=k.effort===void 0?N?C.efforts[N]??null:null:k.effort,I=k.accessLevel??i(M,C.axes).level.level,L=M?a(M):null,R={accessLevel:I,...k.harness?{harness:k.harness}:{},...k.model===void 0?{}:{model:k.model},...k.effort===void 0?{}:{effort:k.effort}},z=async(e,{text:n,files:r})=>{let i={title:(n.split(`
1
+ import{n as e}from"./useNavigate-I5E4IRt2.js";import{a as t,n,t as r}from"./jsx-runtime-Wy9s6hX0.js";import{c as i,d as a,p as o}from"./AgentDetail-CbhnttdO.js";import{I as s,L as c,R as l}from"./Hint-Od6cnmvm.js";import{r as u}from"./use-threads-orpc-mbpsuq3G.js";import{i as d,r as f,t as p}from"./Composer-DIYA4JDp.js";var m=t(n(),1),h=r();function g({subject:t,branch:n,incident:r=null,note:g=!1,top:_,slash:v,place:y,placeholder:b,autoFocus:x=!0,onRepeat:S}){let C=o(),w=u(),T=s(),E=c(),D=l(),O=e(),[k,A]=(0,m.useState)({}),j=(0,m.useRef)(null),M=C.harnesses.find(e=>e.id===k.harness)??C.effective,N=M?.id,P=k.model??(N?C.models[N]??C.model:``)??``,F=k.effort===void 0?N?C.efforts[N]??null:null:k.effort,I=k.accessLevel??i(M,C.axes).level.level,L=M?a(M):null,R={accessLevel:I,...k.harness?{harness:k.harness}:{},...k.model===void 0?{}:{model:k.model},...k.effort===void 0?{}:{effort:k.effort}},z=async(e,{text:n,files:r})=>{let i={title:(n.split(`
2
2
  `)[0]??n).slice(0,120),description:n,severity:e,...t.kind===`service`?{serviceId:t.serviceId}:{}},a=j.current&&!(j.current.fields.serviceId&&j.current.fields.serviceId!==i.serviceId)?j.current:null;if(a){let e=Object.fromEntries(Object.entries(i).filter(([e,t])=>a.fields[e]!==t));Object.keys(e).length&&await D.mutateAsync({id:a.id,...e})}let o=a?.id??(await T.mutateAsync(i)).id;j.current={id:o,fields:i};let s=await Promise.all(r.map(e=>f(o,e)));if(g){j.current=null,await O({to:`/incidents/$id`,params:{id:o}});return}let c=await E.mutateAsync({id:o,brief:n,...R,...s.length?{attachments:s.map(e=>e.id)}:{}});j.current=null,await O({to:`/incidents/$id/conversation`,params:{id:o},search:{investigation:c.investigationId}})};return(0,h.jsx)(p,{state:`ready`,onSend:async e=>{if(r)return z(r,e);let{text:n,files:i}=e,a=crypto.randomUUID(),o=await Promise.all(i.map(e=>d({draftKey:a},e))),s=await w.mutateAsync({subject:t,text:n,...y?{place:y}:{},...R,...o.length?{draftKey:a,attachments:o.map(e=>e.id)}:{}});await O({to:`/threads/$id`,params:{id:s.investigationId}})},placeholder:b??(r?`What's wrong?`:`Ask or describe a change`),choice:{harness:M,model:P,effort:F,accessLevel:I},onChoice:e=>A(t=>({...t,...e.harnessId?{harness:e.harnessId,effort:void 0}:{},...e.model===void 0?{}:{model:e.model},...e.effort===void 0?{}:{effort:e.effort},...e.accessLevel?{accessLevel:e.accessLevel}:{}})),branch:n,blockedReason:C.isLoading||r&&g?null:L,autoFocus:x,top:_,slash:v,...S&&!r?{onRepeat:e=>S({brief:e,subject:t,...N?{harness:N}:{},model:P,effort:F,accessLevel:I})}:{}})}export{g as t};