Files
archie/ui/dist/assets/HarnessPage.js
T
sam a5137a4eca refactor(ui): audit leftovers use Alert, Item, CodeView and Tooltip
Inline error paragraphs become destructive Alerts, divided record lists
become Item rows, the redirect URI box uses CodeView, and icon-button
title hints use Tooltip. Native titles remain on truncated values and on
disabled controls.
2026-10-26 22:35:47 +11:00

1 line
6.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{t as e}from"./badge.js";import{A as t,C as n,Ct as r,M as i,S as a,Xt as o,_t as s,b as c,dt as l,ir as u,jn as d,k as f,l as p,st as m,t as h,x as g,xn as _}from"./PageHeader.js";import{N as v,d as y,l as b,n as x,r as S,u as C}from"./createLucideIcon.js";import{A as w,C as T,Ct as E,D,E as O,O as k,T as A,Y as j,Z as M,a as N,ct as ee,dt as P,et as F,ft as I,lt as L,o as R,pt as z,q as B,tt as V,ut as H,w as U}from"./index.js";function W(e,t=Date.now()){if(!e.captured)return`unconfigured`;if(!e.expires_at)return`ready`;let n=Date.parse(e.expires_at);return Number.isNaN(n)?`ready`:n<=t?`expired`:n-t<=18e5?`expiring`:`ready`}function G(e,t,n=80,r=24){let i=t.protocol===`https:`?`wss:`:`ws:`,a=new URLSearchParams({profile:e,cols:String(n),rows:String(r)}).toString();return`${i}//${t.host}/api/harness/terminal?${a}`}var K={class:`flex h-full min-h-0 flex-col gap-2`},q={key:0,class:`text-sm text-fg-muted`,role:`status`},J=i({__name:`SetupTerminal`,props:{profile:{}},setup(e){let t=e,r=_(null),i=_(`connecting`),o=null,u=null,d=null,h=null;function g(){try{d?.fit()}catch{}}return l(()=>{let e=r.value;if(!e)return;o=new R({convertEol:!0,cursorBlink:!0,fontFamily:`'IBM Plex Mono', ui-monospace, monospace`,fontSize:13,theme:{background:`#0b0f14`,foreground:`#e6edf3`,cursor:`#e6edf3`,selectionBackground:`#264f78`}}),d=new N,o.loadAddon(d),o.open(e),g(),o.focus();let n=new WebSocket(G(t.profile,window.location,o?.cols??80,o?.rows??24));u=n,n.binaryType=`arraybuffer`,n.onopen=()=>{i.value=`open`},n.onmessage=e=>{o&&(typeof e.data==`string`?o.write(e.data):o.write(new Uint8Array(e.data)))},n.onerror=()=>{i.value=`failed`},n.onclose=()=>{i.value=`closed`},o.onData(e=>{n.readyState===WebSocket.OPEN&&n.send(e)}),h=new ResizeObserver(g),h.observe(e)}),m(()=>{h?.disconnect(),h=null,u?.close(),u=null,o?.dispose(),o=null,d=null}),(e,t)=>(s(),n(`div`,K,[i.value===`open`?a(``,!0):(s(),n(`p`,q,[i.value===`connecting`?(s(),n(p,{key:0},[f(`Connecting…`)],64)):i.value===`closed`?(s(),n(p,{key:1},[f(`The terminal session ended.`)],64)):(s(),n(p,{key:2},[f(`Could not open the setup terminal.`)],64))])),c(`div`,{ref_key:`host`,ref:r,class:`min-h-0 flex-1 overflow-hidden rounded-md border border-border bg-[#0b0f14] p-2`},null,512)]))}}),Y={key:1,class:`flex flex-col gap-2`},X={class:`flex flex-wrap items-end gap-3`},Z={class:`flex flex-col gap-1 text-sm`},Q={class:`h-96`},$=i({__name:`HarnessPage`,setup(i){let m=_(null),N=_(!0),R=_(null),G=_(!1),K=_(``),q=_(!1),$={ready:{label:`Ready`,variant:`ok`},expiring:{label:`Expiring soon`,variant:`warn`},expired:{label:`Expired`,variant:`danger`},unconfigured:{label:`Not set up`,variant:`idle`}};l(te);async function te(){N.value=!0,R.value=null,G.value=!1;try{let e=await S.harnessBindings();m.value={terminal:e.terminal,bindings:e.bindings??[],profiles:e.profiles??[]},K.value=m.value.profiles[0]??``}catch(e){let t=e instanceof x?e.status:void 0;t===501||t===503?G.value=!0:R.value=e instanceof Error?e.message:String(e),m.value=null}finally{N.value=!1}}function ne(){m.value?.terminal&&K.value&&(q.value=!0)}function re(e){return e.scopes?.length?e.scopes.join(`, `):`–`}return(i,l)=>(s(),n(`div`,null,[t(h,{title:`Harness`}),R.value?(s(),g(d(y),{key:0,variant:`destructive`,class:`mb-4`},{default:o(()=>[t(d(b),null,{default:o(()=>[...l[1]||=[f(`Could not load the harness`,-1)]]),_:1}),t(d(C),null,{default:o(()=>[f(u(R.value),1)]),_:1})]),_:1})):a(``,!0),N.value?(s(),n(`div`,Y,[t(d(V),{class:`h-24 w-full`}),t(d(V),{class:`h-40 w-full`})])):G.value?(s(),g(d(F),{key:2},{default:o(()=>[t(d(M),null,{default:o(()=>[t(d(j),null,{default:o(()=>[...l[2]||=[f(`Harness bindings are not configured`,-1)]]),_:1})]),_:1})]),_:1})):m.value?(s(),n(p,{key:3},[m.value.terminal?(s(),g(d(w),{key:1},{default:o(()=>[c(`div`,X,[c(`div`,Z,[t(d(E),{for:`harness-profile`,class:`text-fg-muted`},{default:o(()=>[...l[5]||=[f(`Profile`,-1)]]),_:1}),t(d(z),{modelValue:K.value,"onUpdate:modelValue":l[0]||=e=>K.value=e,disabled:!m.value.profiles.length},{default:o(()=>[t(d(L),{id:`harness-profile`,size:`sm`,class:`min-w-48`},{default:o(()=>[t(d(ee),{placeholder:`No profiles configured`})]),_:1}),t(d(I),null,{default:o(()=>[t(d(P),null,{default:o(()=>[(s(!0),n(p,null,r(m.value.profiles,e=>(s(),g(d(H),{key:e,value:e},{default:o(()=>[f(u(e),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1})]),_:1},8,[`modelValue`,`disabled`])]),t(d(v),{disabled:!K.value,onClick:ne},{default:o(()=>[...l[6]||=[f(`Open setup terminal`,-1)]]),_:1},8,[`disabled`])])]),_:1})):(s(),g(d(y),{key:0,class:`mb-4`},{default:o(()=>[t(d(b),null,{default:o(()=>[...l[3]||=[f(`Setup terminal unavailable`,-1)]]),_:1}),t(d(C),null,{default:o(()=>[...l[4]||=[f(`Start the daemon with a container runtime and a harness token to log in to a CLI from here.`,-1)]]),_:1})]),_:1})),q.value&&K.value?(s(),g(d(w),{key:2},{default:o(()=>[c(`div`,Q,[t(J,{profile:K.value},null,8,[`profile`])])]),_:1})):a(``,!0),t(d(w),null,{default:o(()=>[t(d(k),null,{default:o(()=>[t(d(T),null,{default:o(()=>[t(d(A),null,{default:o(()=>[t(d(U),null,{default:o(()=>[...l[7]||=[f(`Service`,-1)]]),_:1}),t(d(U),null,{default:o(()=>[...l[8]||=[f(`Status`,-1)]]),_:1}),t(d(U),null,{default:o(()=>[...l[9]||=[f(`Expires`,-1)]]),_:1}),t(d(U),null,{default:o(()=>[...l[10]||=[f(`Scopes`,-1)]]),_:1}),t(d(U),null,{default:o(()=>[...l[11]||=[f(`Updated`,-1)]]),_:1})]),_:1})]),_:1}),t(d(D),null,{default:o(()=>[m.value.bindings.length?a(``,!0):(s(),g(d(A),{key:0},{default:o(()=>[t(d(O),{colspan:`5`,class:`text-fg-muted`},{default:o(()=>[...l[12]||=[f(`No credential bindings.`,-1)]]),_:1})]),_:1})),(s(!0),n(p,null,r(m.value.bindings,n=>(s(),g(d(A),{key:n.service},{default:o(()=>[t(d(O),{class:`font-medium`},{default:o(()=>[f(u(n.service),1)]),_:2},1024),t(d(O),null,{default:o(()=>[t(d(e),{variant:$[d(W)(n)].variant},{default:o(()=>[f(u($[d(W)(n)].label),1)]),_:2},1032,[`variant`])]),_:2},1024),t(d(O),null,{default:o(()=>[t(d(B),{at:n.expires_at,absolute:``},null,8,[`at`])]),_:2},1024),t(d(O),{class:`text-fg-muted`},{default:o(()=>[f(u(re(n)),1)]),_:2},1024),t(d(O),{class:`text-fg-muted`},{default:o(()=>[t(d(B),{at:n.updated_at},null,8,[`at`])]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})]),_:1})],64)):a(``,!0)]))}});export{$ as default};