fix(webui): list services with the State Store marked down when it is unreachable

This commit is contained in:
sam committed 2026-10-06 00:48:45 +11:00
1 parent d427671fc5
commit 2e579663c1
4 files changed
+29 -16

No files matched your search

+17
View File
@@ -89,6 +89,9 @@ const (
StateUp = "up"
StateDegraded = "degraded"
StateDown = "down"
// StateUnknown is a service whose record cannot be read because the
// State Store holding it is unreachable.
StateUnknown = "unknown"
)
// Service is one expected service as the mesh view shows it: its newest
@@ -123,6 +126,20 @@ func Mesh(records []storecontract.Presence, now time.Time) []Service {
return services
}
// Unreachable is the mesh view when the State Store cannot be read: the store
// is down and every other service is unknown, since its record lives there.
func Unreachable() []Service {
services := make([]Service, 0, len(Services()))
for _, name := range Services() {
service := Service{Presence: storecontract.Presence{Service: name}, State: StateUnknown}
if name == StateStore {
service.State, service.Detail = StateDown, "unreachable"
}
services = append(services, service)
}
return services
}
func state(record storecontract.Presence, reported bool, now time.Time) string {
switch {
case !reported || Stale(record.ReportedAt, now):
+7 -11
View File
@@ -12,23 +12,19 @@ type serviceView struct {
}
// handleServices lists every expected service with its presence and the
// control-plane resource versions it applied.
// control-plane resource versions it applied. Both live in the State Store, so
// when it cannot be read the list still answers, naming the store as down.
func (s *Server) handleServices(w http.ResponseWriter, r *http.Request) {
if s.Presence == nil {
http.Error(w, "presence unavailable", http.StatusServiceUnavailable)
return
}
records, err := s.Presence.ListPresence(r.Context())
if err != nil {
http.Error(w, "presence unavailable", http.StatusServiceUnavailable)
return
mesh := presence.Unreachable()
if records, err := s.Presence.ListPresence(r.Context()); err == nil {
mesh = presence.Mesh(records, s.clock())
}
applied, err := s.readApplyStatus(r.Context())
if err != nil {
http.Error(w, "apply status unavailable", http.StatusServiceUnavailable)
return
}
mesh := presence.Mesh(records, s.clock())
// Apply status is decoration on the list; without it the list still stands.
applied, _ := s.readApplyStatus(r.Context())
out := make([]serviceView, 0, len(mesh))
for _, service := range mesh {
view := serviceView{Service: service, Applied: []applyStatusRecord{}}
+1 -1
View File
@@ -18,7 +18,7 @@ Defaulting to \`null\`.`),null)}function mS(e){return fS(e)&&!Number.isNaN(e)&&e
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=JT(c),u=e+1<n.length?JT(n[e+1]):null;if(l&&u&&Ste(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=JT(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>qT(e)),rows:r.map(e=>e.map(e=>qT(e)))});continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.push({kind:`h${d[1].length}`,inline:qT(d[2])});continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tag!==e)&&(s(),i={tag:e,items:[]}),i.items.push((f||p)[1]);continue}if(c.startsWith(`>`)){o(),s(),t.push({kind:`blockquote`,inline:qT(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function JT(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function Ste(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Cte={class:`[overflow-wrap:anywhere]`},wte={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},Tte={class:`font-mono text-[0.85em]`},Ete={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},Dte={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},Ote={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},kte={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},Ate={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},jte={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},Mte={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},Nte={key:8,class:`mb-2.5 last:mb-0`},Pte=I({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=J(()=>xte(t.text));return(e,t)=>(B(),V(`div`,Cte,[(B(!0),V(z,null,L(n.value,(e,t)=>(B(),V(z,{key:t},[e.kind===`pre`?(B(),V(`pre`,wte,[U(`code`,Tte,j(e.code),1)])):e.kind===`table`?(B(),V(`table`,Ete,[U(`thead`,null,[U(`tr`,null,[(B(!0),V(z,null,L(e.head,(e,t)=>(B(),V(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[W(KT,{inline:e},null,8,[`inline`])]))),128))])]),U(`tbody`,null,[(B(!0),V(z,null,L(e.rows,(e,t)=>(B(),V(`tr`,{key:t},[(B(!0),V(z,null,L(e,(e,t)=>(B(),V(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[W(KT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(B(),V(`blockquote`,Dte,[W(KT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(B(),V(`h1`,Ote,[W(KT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(B(),V(`h2`,kte,[W(KT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(B(),V(`h3`,Ate,[W(KT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(B(),V(`ul`,jte,[(B(!0),V(z,null,L(e.items,(e,t)=>(B(),V(`li`,{key:t},[W(KT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(B(),V(`ol`,Mte,[(B(!0),V(z,null,L(e.items,(e,t)=>(B(),V(`li`,{key:t},[W(KT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(B(),V(`p`,Nte,[W(KT,{inline:e.inline},null,8,[`inline`])])):K(``,!0)],64))),128))]))}}),Fte={class:`truncate`},Ite=I({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=$i(`RouterLink`);return B(),H(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:P(()=>[W(N(Ku),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),U(`span`,Fte,j(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),Lte={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},Rte={class:`font-semibold text-foreground`},zte={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},Bte=I({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=J(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=J(()=>t.tool.parameters||t.tool.Parameters||``),i=J(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=J(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(B(),H(Ite,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(B(),V(`div`,Lte,[W(N(qd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),U(`span`,Rte,j(n.value),1),r.value?(B(),V(`code`,zte,j(r.value),1)):K(``,!0),U(`span`,{class:A(N(Y)(`text-fg-muted`,i.value&&`text-danger`))},j(a.value),3)]))}}),Vte={key:0,class:`mb-2 grid gap-0.5 text-xs`},Hte={key:1,class:`mb-2 flex flex-wrap gap-1.5`},Ute={key:3,class:`whitespace-pre-wrap`},YT=I({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(B(),V(`div`,{class:A([`flex`,e.assistant?`justify-start`:`justify-end`])},[U(`div`,{class:A(N(Y)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(B(),V(`div`,Vte,[(B(!0),V(z,null,L(e.tools,(t,n)=>(B(),H(Bte,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):K(``,!0),e.media.length?(B(),V(`div`,Hte,[(B(!0),V(z,null,L(e.media,(e,t)=>(B(),H(pte,{key:t,attachment:e},null,8,[`attachment`]))),128))])):K(``,!0),e.assistant?(B(),H(Pte,{key:2,text:e.text},null,8,[`text`])):(B(),V(`div`,Ute,j(e.text),1)),R(t.$slots,`default`)],2)],2))}}),Wte={class:`w-full self-center justify-self-center py-6 text-center`},Gte={class:`grid gap-2`},Kte=[`onCLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>LA?`${n.slice(0,LA).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var zA=[`title`],BA=I({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=J(()=>uA(n.event)),a=J(()=>RA(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=J(()=>n.event.at?vk(n.event.at):`—`);return(e,t)=>(B(),H(N(PA),{class:A(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[Rl(Ll(o,[`prevent`]),[`enter`]),Rl(Ll(o,[`prevent`]),[`space`])]},{default:P(()=>[W(N($),{class:`font-medium`},{default:P(()=>[G(j(n.event.kind||n.event.type||`event`),1)]),_:1}),W(N($),{class:`font-mono`},{default:P(()=>[G(j(i.value>0?`#${i.value}`:`—`),1)]),_:1}),W(N($),{class:`w-[55%] max-w-0`},{default:P(()=>[U(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},j(a.value.text),9,zA)]),_:1}),W(N($),null,{default:P(()=>[G(j(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),VA=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function HA(e){return(Number(e?.task_id)||0)>0}function UA(e,t){return t===`tasks`?HA(e):t!==`system`||!HA(e)}function WA(e,t){return e.filter(e=>UA(e,t))}function GA(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function KA(e,t){return`${e}:${t??0}`}function qA(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=KA(RA(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var JA={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},YA={class:`max-h-[28rem] overflow-y-auto`},XA=[`aria-expanded`,`aria-label`,`onClick`],ZA=[`title`],QA=I({__name:`LiveActivityCard`,setup(e){let t=uE(),{activity:n,streamKind:r,streamState:i}=ju(bO()),a=M(`all`),o=J(()=>WA(n.value,a.value)),s=J(()=>GA(o.value.length,a.value)),c=Jt(new Set),l=J(()=>qA(o.value));function u(e){c.has(e)?c.delete(e):c.add(e)}function d(e){return c.has(e.key)}function f(e){return RA(e.representative)}function p(e){return e.representative.at?vk(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(B(),H(N(dk),null,{default:P(()=>[W(N(gk),null,{default:P(()=>[W(N(_k),null,{default:P(()=>[...t[1]||=[G(`Live activity`,-1)]]),_:1}),W(N(fk),{class:`flex items-center gap-2`},{default:P(()=>[W(N(AA),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:N(VA)},null,8,[`modelValue`,`options`]),W(N(ck),{variant:N(r)},{default:P(()=>[G(j(N(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),W(N(pk),null,{default:P(()=>[U(`div`,JA,[U(`div`,YA,[W(N(MA),null,{default:P(()=>[W(N(IA),{class:`sticky top-0 z-10 bg-card`},{default:P(()=>[W(N(PA),null,{default:P(()=>[W(N(FA),null,{default:P(()=>[...t[2]||=[G(`Event`,-1)]]),_:1}),W(N(FA),null,{default:P(()=>[...t[3]||=[G(`Task`,-1)]]),_:1}),W(N(FA),null,{default:P(()=>[...t[4]||=[G(`Detail`,-1)]]),_:1}),W(N(FA),null,{default:P(()=>[...t[5]||=[G(`When`,-1)]]),_:1})]),_:1})]),_:1}),W(N(NA),null,{default:P(()=>[o.value.length?K(``,!0):(B(),H(N(PA),{key:0},{default:P(()=>[W(N($),{colspan:`4`},{default:P(()=>[W(N(ek),null,{default:P(()=>[W(N(rk),null,{default:P(()=>[W(N(ok),null,{default:P(()=>[G(j(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),o.value.length?(B(!0),V(z,{key:1},L(l.value,e=>(B(),V(z,{key:e.key},[e.count===1?(B(),H(BA,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(B(),V(z,{key:1},[W(N(PA),{class:A(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&m(e.taskID),onKeydown:[Rl(Ll(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),Rl(Ll(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`space`])]},{default:P(()=>[W(N($),{class:`font-medium`},{default:P(()=>[U(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":d(e),"aria-label":`${d(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:Ll(t=>u(e.key),[`stop`])},[d(e)?(B(),H(N($u),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(B(),H(N(ed),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),G(` `+j(e.label)+` `,1),W(N(ck),{variant:`idle`},{default:P(()=>[G(`×`+j(e.count),1)]),_:2},1024)],8,XA)]),_:2},1024),W(N($),{class:`font-mono`},{default:P(()=>[G(j(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),W(N($),{class:`w-[55%] max-w-0`},{default:P(()=>[U(`span`,{class:`block truncate`,title:f(e).truncated?f(e).full:void 0},j(f(e).text),9,ZA)]),_:2},1024),W(N($),null,{default:P(()=>[G(j(p(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),d(e)?(B(!0),V(z,{key:0},L(e.events,(t,n)=>(B(),H(BA,{key:`${e.key}:${n}`,event:t,onO Line truncated
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function yM(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function bM(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function xM(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function SM(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var CM=M([]),wM=M([]),TM=M(!0),EM=M(null),DM=M(null),OM=M(!1),kM=M(null);async function AM(){try{let e=await X.eventTypes();TM.value=e.enabled!==!1,CM.value=e.event_types||[],wM.value=e.proposals||[],EM.value=null}catch(e){EM.value=e.message||String(e)}}function jM(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function MM(e){kM.value=null,DM.value=e}function NM(e){let t=VM.value.find(t=>String(t.id)===e.sample_id);MM({mode:`proposal`,id:null,source:e.source,name:``,rule:jM(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function PM(e=``){MM({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function FM(e){MM({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:jM(e.rule),headersText:``,body:``,exampleHeaders:{}})}function IM(){DM.value=null}async function LM(){let e=DM.value;if(e){OM.value=!0;try{if(e.mode===`edit`&&e.id)await X.eventTypeUpdate(e.id,{name:e.name,rule:SM(e.rule)});else{let t=e.mode===`paste`?vM(e.headersText):e.exampleHeaders;await X.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:SM(e.rule),example:{headers:t,body:e.body}})}DM.value=null,await AM()}catch(e){kM.value=e.message||String(e)}finally{OM.value=!1}}}var RM=M(null);async function zM(){let e=RM.value;if(RM.value=null,e)try{await X.eventTypeDelete(e.id),await AM()}catch(e){EM.value=e.message||String(e)}}var BM=100,VM=M([]),HM=M(!0),UM=M(null),WM=M(!0),GM=M(null);async function KM(){try{let e=await X.captures(BM);HM.value=e.enabled!==!1,VM.value=e.captures||[],UM.value=null}catch(e){UM.value=e.message||String(e)}finally{WM.value=!1}}function qM(e){let t=VM.value.find(t=>t.id===e);return t&&(GM.value=t),!!t}function JM(){VM.value.length&&(GM.value=VM.value[0])}function YM(){xO(`captures`,()=>{KM(),AM()})}var XM=`archie.theme`,ZM=`archie.density`,QM=`archie.motion`,$M=`archie.tooltips`;function eN(e,t,n){try{let r=localStorage.getItem(e);return t.includes(r)?r:n}catch{return n}}function tN(e,t){try{localStorage.setItem(e,t)}catch{}}function nN(e){if(e!==`system`)return e;try{return matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}catch{return`dark`}}var rN=Au(`appearance`,()=>{let e=M(eN(XM,[`system`,`dark`,`light`],`dark`)),t=M(eN(ZM,[`comfortable`,`compact`],`comfortable`)),n=M(eN(QM,[`system`,`reduced`],`system`)),r=M(eN($M,[`on`,`off`],`on`)===`on`),i=!1;function a(){document.documentElement.dataset.theme=nN(e.value)}function o(t){e.value=t,a(),tN(XM,t)}function s(e){t.value=e,document.documentElement.dataset.density=e,tN(ZM,e)}function c(e){n.value=e,document.documentElement.dataset.motion=e,tN(QM,e)}function l(e){r.value=e,tN($M,e?`on`:`off`)}function u(){if(!i){i=!0,a(),document.documentElement.dataset.density=t.value,document.documentElement.dataset.motion=n.value;try{matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{e.value===`system`&&a()})}catch{}}}return{theme:e,density:t,motion:n,tooltipsEnabled:r,initialize:u,setTheme:o,setDensity:s,setMotion:c,setTooltips:l}}),iN=I({__name:`Tooltip`,props:{defaultOpen:{type:Boolean},open:{type:Boolean},delayDuration:{},disableHoverableContent:{type:Boolean},disableClosingTrigger:{type:Boolean},disabled:{type:Boolean},ignoreNonKeyboardFocus:{type:Boolean}},emits:[`update:open`],setup(e,{emit:t}){let n=e,r=zh(n,t),{tooltipsEnabled:i}=ju(rN());return(e,t)=>(B(),H(N(BC),q({"data-slot":`tooltip`},N(r),{disabled:n.disabled||!N(i)}),{default:P(t=>[R(e.$slots,`default`,ye(as(t)))]),_:3},16,[`disabled`]))}}),aN=I({inheritAttrs:!1,__name:`TooltipContent`,props:{forceMount:{type:Boolean},ariaLabel:{},asChild:{type:Boolean},as:{},side:{},sideOffset:{default:0},align:{},alignOffset:{},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`escapeKeyDown`,`pointerDownOutside`],setup(e,{emit:t}){let n=e,r=t,i=zh(ow(n,`class`),r);return(e,t)=>(B(),H(N(WC),null,{default:P( Line truncated
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function yM(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function bM(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function xM(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function SM(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var CM=M([]),wM=M([]),TM=M(!0),EM=M(null),DM=M(null),OM=M(!1),kM=M(null);async function AM(){try{let e=await X.eventTypes();TM.value=e.enabled!==!1,CM.value=e.event_types||[],wM.value=e.proposals||[],EM.value=null}catch(e){EM.value=e.message||String(e)}}function jM(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function MM(e){kM.value=null,DM.value=e}function NM(e){let t=VM.value.find(t=>String(t.id)===e.sample_id);MM({mode:`proposal`,id:null,source:e.source,name:``,rule:jM(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function PM(e=``){MM({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function FM(e){MM({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:jM(e.rule),headersText:``,body:``,exampleHeaders:{}})}function IM(){DM.value=null}async function LM(){let e=DM.value;if(e){OM.value=!0;try{if(e.mode===`edit`&&e.id)await X.eventTypeUpdate(e.id,{name:e.name,rule:SM(e.rule)});else{let t=e.mode===`paste`?vM(e.headersText):e.exampleHeaders;await X.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:SM(e.rule),example:{headers:t,body:e.body}})}DM.value=null,await AM()}catch(e){kM.value=e.message||String(e)}finally{OM.value=!1}}}var RM=M(null);async function zM(){let e=RM.value;if(RM.value=null,e)try{await X.eventTypeDelete(e.id),await AM()}catch(e){EM.value=e.message||String(e)}}var BM=100,VM=M([]),HM=M(!0),UM=M(null),WM=M(!0),GM=M(null);async function KM(){try{let e=await X.captures(BM);HM.value=e.enabled!==!1,VM.value=e.captures||[],UM.value=null}catch(e){UM.value=e.message||String(e)}finally{WM.value=!1}}function qM(e){let t=VM.value.find(t=>t.id===e);return t&&(GM.value=t),!!t}function JM(){VM.value.length&&(GM.value=VM.value[0])}function YM(){xO(`captures`,()=>{KM(),AM()})}var XM=`archie.theme`,ZM=`archie.density`,QM=`archie.motion`,$M=`archie.tooltips`;function eN(e,t,n){try{let r=localStorage.getItem(e);return t.includes(r)?r:n}catch{return n}}function tN(e,t){try{localStorage.setItem(e,t)}catch{}}function nN(e){if(e!==`system`)return e;try{return matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}catch{return`dark`}}var rN=Au(`appearance`,()=>{let e=M(eN(XM,[`system`,`dark`,`light`],`dark`)),t=M(eN(ZM,[`comfortable`,`compact`],`comfortable`)),n=M(eN(QM,[`system`,`reduced`],`system`)),r=M(eN($M,[`on`,`off`],`on`)===`on`),i=!1;function a(){document.documentElement.dataset.theme=nN(e.value)}function o(t){e.value=t,a(),tN(XM,t)}function s(e){t.value=e,document.documentElement.dataset.density=e,tN(ZM,e)}function c(e){n.value=e,document.documentElement.dataset.motion=e,tN(QM,e)}function l(e){r.value=e,tN($M,e?`on`:`off`)}function u(){if(!i){i=!0,a(),document.documentElement.dataset.density=t.value,document.documentElement.dataset.motion=n.value;try{matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,()=>{e.value===`system`&&a()})}catch{}}}return{theme:e,density:t,motion:n,tooltipsEnabled:r,initialize:u,setTheme:o,setDensity:s,setMotion:c,setTooltips:l}}),iN=I({__name:`Tooltip`,props:{defaultOpen:{type:Boolean},open:{type:Boolean},delayDuration:{},disableHoverableContent:{type:Boolean},disableClosingTrigger:{type:Boolean},disabled:{type:Boolean},ignoreNonKeyboardFocus:{type:Boolean}},emits:[`update:open`],setup(e,{emit:t}){let n=e,r=zh(n,t),{tooltipsEnabled:i}=ju(rN());return(e,t)=>(B(),H(N(BC),q({"data-slot":`tooltip`},N(r),{disabled:n.disabled||!N(i)}),{default:P(t=>[R(e.$slots,`default`,ye(as(t)))]),_:3},16,[`disabled`]))}}),aN=I({inheritAttrs:!1,__name:`TooltipContent`,props:{forceMount:{type:Boolean},ariaLabel:{},asChild:{type:Boolean},as:{},side:{},sideOffset:{default:0},align:{},alignOffset:{},avoidCollisions:{type:Boolean},collisionBoundary:{},collisionPadding:{},arrowPadding:{},sticky:{},hideWhenDetached:{type:Boolean},positionStrategy:{},updatePositionStrategy:{},class:{type:[Boolean,null,String,Object,Array]}},emits:[`escapeKeyDown`,`pointerDownOutside`],setup(e,{emit:t}){let n=e,r=t,i=zh(ow(n,`class`),r);return(e,t)=>(B(),H(N(WC),null,{default:P( Line truncated
`)}};vJ.defaultYaml={explicit:!1,version:`1.2`},vJ.defaultTags={"!!":`tag:yaml.org,2002:`};function yJ(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function bJ(e){let t=new Set;return dJ(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function xJ(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function SJ(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=bJ(e);let a=xJ(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(rJ(t.node)||aJ(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function CJ(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=CJ(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=CJ(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=CJ(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=CJ(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function wJ(e,t,n){if(Array.isArray(e))return e.map((e,t)=>wJ(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!sJ(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var TJ=class{constructor(e){Object.defineProperty(this,Qq,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!eJ(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=wJ(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?CJ(i,{"":o},``,o):o}},EJ=class extends TJ{constructor(e){super(Kq),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],dJ(e,{Node:(e,t)=>{($q(t)||sJ(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(wJ(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=DJ(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(yJ(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function DJ(e,t,n){if($q(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(aJ(t)){let r=0;for(let i of t.items){let t=DJ(e,i,n);t>r&&(r=t)}return r}if(nJ(t)){let r=DJ(e,t.key,n),i=DJ(e,t.value,n);return Math.max(r,i)}return 1}var OJ=e=>!e||typeof e!=`function`&&typeof e!=`object`,kJ=class extends TJ{constructor(e){super(Xq),this.value=e}toJSON(e,t){return t?.keep?this.value:wJ(this.value,e,t)}toString(){return String(this.value)}};kJ.BLOCK_FOLDED=`BLOCK_FOLDED`,kJ.BLOCK_LITERAL=`BLOCK_LITERAL`,kJ.PLAIN=`PLAIN`,kJ.QUOTE_DOUBLE=`QUOTE_DOUBLE`,kJ.QUOTE_SINGLE=`QUOTE_SINGLE`;var AJ=`tag:yaml.org,2002:`;function jJ(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function MJ(e,t,n){if(eJ(e)&&(e=e.contents),oJ(e))return e;if(nJ(e)){let t=n.schema[Jq].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new EJ(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=AJ+t.slice(2));let l=jJ(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new kJ(e);return c&&(c.node=t),t Line truncated
`)?LJ(n,t):n.includes(`
`)?`
+4 -4
View File
@@ -22,7 +22,7 @@ interface AppliedRecord {
interface Service {
service: string;
state: "up" | "degraded" | "down";
state: "up" | "degraded" | "down" | "unknown";
version: string;
install_type: string;
started_at: string;
@@ -35,10 +35,10 @@ const services = ref<Service[]>([]);
const error = ref<string | null>(null);
let timer: ReturnType<typeof setInterval> | undefined;
const tone = { up: "ok", degraded: "warn", down: "danger" } as const;
const tone = { up: "ok", degraded: "warn", down: "danger", unknown: "idle" } as const;
function uptime(service: Service): string {
if (service.state === "down") return "";
if (!service.started_at || service.state === "down") return "";
const seconds = Math.max(
0,
Math.round((Date.now() - Date.parse(service.started_at)) / 1000),
@@ -89,7 +89,7 @@ onUnmounted(() => clearInterval(timer));
<TableCell>
<span class="font-mono font-medium">{{ service.service }}</span>
<span v-if="service.detail" class="ml-2 text-sm text-fg-muted"
>degraded: {{ service.detail }}</span
>{{ service.state }}: {{ service.detail }}</span
>
</TableCell>
<TableCell class="text-sm">