feat(dashboard): render task actions, statuses and filters from the server catalog
Three surfaces stopped keeping hand-synced copies of the lifecycle vocabulary, so a status or action added on the backend shows up without a frontend change: - task actions render label/variant/confirm from taskstate.ActionCatalog via actionFor(); unknown actions no longer vanish behind a hardcoded switch and a new action needs no frontend case - status labels and pill severities come from taskstate.Statuses via statusLabel()/statusKind(); the local copy and the dom.js switch are gone - the status filter vocabulary and the "needs you" grouping derive from statusIds()/attentionStatusIds(); a new status appears in the filter and in the settings page's Work lifecycle card, driven by /api/task-meta Regenerated ui/dist so the embedded binary ships the new dashboard.
This commit is contained in:
1 parent
23e0895ea2
commit
cf06cd6a08
8 files changed
+332
-120
No files matched your search
Vendored
+13
-13
@@ -1,13 +1,13 @@
|
||||
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function e(e,n,...r){let[i,...a]=e.split(`.`),o=document.createElement(i||`div`);a.length&&(o.className=a.join(` `)),n!==void 0&&(typeof n!=`object`||n instanceof Node)&&(r.unshift(n),n=null);for(let[e,t]of Object.entries(n||{}))t!=null&&t!==!1&&(e.startsWith(`on`)&&typeof t==`function`?o.addEventListener(e.slice(2).toLowerCase(),t):e===`class`?o.className=[o.className,t].filter(Boolean).join(` `):e===`html`?o.innerHTML=t:o.setAttribute(e,t===!0?``:String(t)));return t(o,r),o}function t(e,t){for(let n of t.flat(1/0))n!=null&&n!==!1&&e.append(n instanceof Node?n:document.createTextNode(String(n)))}function n(e,...n){return e.replaceChildren(),t(e,n),e}function r(t,n=`idle`){return e(`span.pill.pill-${n}`,t)}function i(e){switch(e){case`running`:return`info`;case`merged`:case`pr_open`:return`ok`;case`parked`:case`waiting_human`:return`warn`;case`dead`:case`rejected`:return`danger`;default:return`idle`}}function a(e){if(!e)return`—`;let t=e instanceof Date?e:new Date(e),n=Math.floor((Date.now()-t.getTime())/1e3);if(!Number.isFinite(n))return`—`;if(n<45)return`just now`;let r=[[`min`,60],[`hr`,3600],[`day`,86400],[`wk`,604800]],i=`min`,a=60;for(let[e,t]of r)n>=t&&([i,a]=[e,t]);let o=Math.floor(n/a);return`${o} ${i}${o===1?``:`s`} ago`}function o(e){return e==null||Number.isNaN(e)?`—`:new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e)}function s(t,n){return e(`div.empty`,e(`div.empty-title`,t),n&&e(`div`,n))}var c={dashboard:`<rect x="3" y="3" width="7" height="9" rx="1.5"/><rect x="14" y="3" width="7" height="5" rx="1.5"/><rect x="14" y="12" width="7" height="9" rx="1.5"/><rect x="3" y="16" width="7" height="5" rx="1.5"/>`,chat:`<path d="M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v7a2.5 2.5 0 0 1-2.5 2.5H11l-4.5 4v-4.1A2.5 2.5 0 0 1 4 12.5z"/><path d="M8 8h8M8 11h5"/>`,tasks:`<path d="M9 6h11M9 12h11M9 18h11"/><path d="M4 6l1 1 2-2M4 12l1 1 2-2M4 18l1 1 2-2"/>`,logs:`<path d="M4 5h16M4 10h16M4 15h10M4 20h7"/>`,skills:`<path d="M12 3l2.6 5.6 6.1.8-4.5 4.2 1.2 6-5.4-3-5.4 3 1.2-6L3.3 9.4l6.1-.8z"/>`,workflows:`<path d="M4 7h6a3 3 0 0 1 3 3v4a3 3 0 0 0 3 3h4"/><path d="M17 4l3 3-3 3"/><path d="M7 21l-3-3 3-3"/>`,memory:`<circle cx="12" cy="12" r="3.2"/><path d="M12 3v3.4M12 17.6V21M3 12h3.4M17.6 12H21M5.6 5.6l2.4 2.4M16 16l2.4 2.4M18.4 5.6L16 8M8 16l-2.4 2.4"/>`,channels:`<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3.5 7l8.5 6 8.5-6"/>`,captures:`<path d="M12 3v11M12 14l-4-4M12 14l4-4"/><path d="M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4"/>`,mappings:`<circle cx="5" cy="7" r="2"/><circle cx="5" cy="17" r="2"/><circle cx="19" cy="12" r="2"/><path d="M7 7l10 5M7 17l10-5"/>`,settings:`<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-2.9 1.2V21a2 2 0 1 1-4 0v-.1A1.7 1.7 0 0 0 7 19.4a1.7 1.7 0 0 0-1.9.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1A1.7 1.7 0 0 0 3 15H3a2 2 0 1 1 0-4h.1A1.7 1.7 0 0 0 4.6 7a1.7 1.7 0 0 0-.3-1.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1A1.7 1.7 0 0 0 9 3.6V3a2 2 0 1 1 4 0v.1A1.7 1.7 0 0 0 15 4.6h.1a1.7 1.7 0 0 0 1.9-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.9V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/>`,search:`<circle cx="11" cy="11" r="7"/><path d="M20 20l-3.6-3.6"/>`,moon:`<path d="M20 14.5A8.5 8.5 0 0 1 9.5 4a8.5 8.5 0 1 0 10.5 10.5z"/>`,sun:`<circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M19.1 4.9l-1.4 1.4M6.3 17.7l-1.4 1.4"/>`,refresh:`<path d="M20 11a8 8 0 1 0-1.2 5.2"/><path d="M20 4v7h-7"/>`,bell:`<path d="M18 9a6 6 0 1 0-12 0c0 6-2 7-2 7h16s-2-1-2-7"/><path d="M13.7 20a2 2 0 0 1-3.4 0"/>`,trendUp:`<path d="M4 17L10 11l4 4 6-6"/><path d="M14 7h6v6"/>`,trendDown:`<path d="M4 7l6 6 4-4 6 6"/><path d="M14 17h6v-6"/>`,check:`<path d="M4.5 12.5l5 5 10-11"/>`,help:`<circle cx="12" cy="12" r="9"/><path d="M9.6 9.4a2.5 2.5 0 1 1 3.3 2.4c-.6.2-.9.8-.9 1.4v.4"/><path d="M12 17.2h.01"/>`};function l(e,{size:t=18,className:n=``}={}){let r=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);return r.setAttribute(`viewBox`,`0 0 24 24`),r.setAttribute(`width`,String(t)),r.setAttribute(`height`,String(t)),r.setAttribute(`fill`,`none`),r.setAttribute(`stroke`,`currentColor`),r.setAttribute(`stroke-width`,`1.6`),r.setAttribute(`stroke-linecap`,`r
Line truncated
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var m=class extends Error{constructor(e,t){super(e),this.status=t}},h={summary:()=>d(`/api/summary`),tasks:()=>d(`/api/tasks`),task:e=>d(`/api/tasks/${e}`),taskAction:async(e,t)=>{let n=await fetch(`/api/tasks/${e}/action`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({action:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new m(await p(n),n.status);return n.json()},setup:()=>d(`/api/setup`),workflows:()=>d(`/api/workflows`),workRequest:async e=>{let t=await fetch(`/api/work-requests`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new m(await p(t),t.status);return t.json()},skills:()=>d(`/api/skills`),channels:()=>d(`/api/channels`),channelReload:async e=>{let t=await fetch(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:`{}`,signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new m(await p(t),t.status);return t.json()},config:()=>d(`/api/config`),version:()=>d(`/api/version`),configUpdate:async e=>{let t=await fetch(`/api/config`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({updates:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new m(await p(t),t.status);return t.json()},configReset:async e=>{let t=await fetch(`/api/config/reset`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({key:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new m(await p(t),t.status);return t.json()},logs:e=>d(`/api/logs`+f(e)),captures:e=>d(`/api/captures`+f({limit:e})),mappings:()=>d(`/api/mappings`),mappingCreate:async e=>{let t=await fetch(`/api/mappings`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new m(await p(t),t.status);return t.json()},mappingUpdate:async(e,t)=>{let n=await fetch(`/api/mappings/${e}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(t),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new m(await p(n),n.status);return n.json()},mappingDelete:async e=>{let t=await fetch(`/api/mappings/${e}`,{method:`DELETE`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new m(await p(t),t.status)},mappingPreview:async(e,t)=>{let n=await fetch(`/api/mappings/preview`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({capture_id:e,fields:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new m(await p(n),n.status);return n.json()},memory:()=>d(`/api/memory`),chatSessions:()=>d(`/api/chat/sessions`),chatMessages:e=>d(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>d(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:async e=>{let t=await fetch(`/api/chat/cancel`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new m(await p(t),t.status);return t.json()},chatMessage:async(e,t)=>{let n=await fetch(`/api/chat/message`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({channel_id:e,source_id:u(),text:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new m(await p(n),n.status);return n.json()},chatPersona:async(e,t)=>{let n=await fetch(`/api/chat/persona`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e,name:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new m(await p(n),n.status);return n.json()},chatUpdate:()=>d(`/api/chat/update`),chatUpdateDefer:async e=>{let t=await fetch(`/api/chat/update/defer`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({snapshot:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new m(await p(t),t.status);return t.json()},chatUpdateInstall:async e=>{let t=await fetch(`/api/chat/update/install`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({snapshot:e}),signal:AbortSignal.timeout(12e4)});if(!t.ok)throw new m(await p(t),t.status);return t.json()},chatDangerous:()=>d(`/api/chat/dangerous`),chatDangerousRequest:async(e,t)=>{let n=await fetch(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({spec:t}),signal:AbortSign
Line truncated
|
||||
<path d="${l(150,240)}" fill="none" stroke="var(--border)"
|
||||
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function e(e=globalThis.crypto){if(typeof e?.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues==`function`)e.getRandomValues(t);else for(let e=0;e<t.length;e+=1)t[e]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,e=>e.toString(16).padStart(2,`0`));return`${n.slice(0,4).join(``)}-${n.slice(4,6).join(``)}-${n.slice(6,8).join(``)}-${n.slice(8,10).join(``)}-${n.slice(10).join(``)}`}async function t(e){let t=await fetch(e,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(15e3)});if(t.status===401)throw new i(`unauthorised`,401);if(!t.ok)throw new i(`${t.status} ${t.statusText}`,t.status);return t.json()}function n(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e||{}))r!==``&&r!=null&&t.set(n,r);let n=t.toString();return n?`?${n}`:``}async function r(e){try{let t=(await e.text()).trim();if(t)return t.split(`
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var i=class extends Error{constructor(e,t){super(e),this.status=t}},a={summary:()=>t(`/api/summary`),tasks:()=>t(`/api/tasks`),taskMeta:()=>t(`/api/task-meta`),task:e=>t(`/api/tasks/${e}`),taskAction:async(e,t)=>{let n=await fetch(`/api/tasks/${e}/action`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({action:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},setup:()=>t(`/api/setup`),workflows:()=>t(`/api/workflows`),workRequest:async e=>{let t=await fetch(`/api/work-requests`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},skills:()=>t(`/api/skills`),channels:()=>t(`/api/channels`),channelReload:async e=>{let t=await fetch(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:`{}`,signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},config:()=>t(`/api/config`),version:()=>t(`/api/version`),configUpdate:async e=>{let t=await fetch(`/api/config`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({updates:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},configReset:async e=>{let t=await fetch(`/api/config/reset`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({key:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},logs:e=>t(`/api/logs`+n(e)),captures:e=>t(`/api/captures`+n({limit:e})),mappings:()=>t(`/api/mappings`),mappingCreate:async e=>{let t=await fetch(`/api/mappings`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},mappingUpdate:async(e,t)=>{let n=await fetch(`/api/mappings/${e}`,{method:`PATCH`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(t),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},mappingDelete:async e=>{let t=await fetch(`/api/mappings/${e}`,{method:`DELETE`,headers:{Accept:`application/json`,"X-Archie-CSRF":`1`},signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status)},mappingPreview:async(e,t)=>{let n=await fetch(`/api/mappings/preview`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify({capture_id:e,fields:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},memory:()=>t(`/api/memory`),chatSessions:()=>t(`/api/chat/sessions`),chatMessages:e=>t(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>t(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:async e=>{let t=await fetch(`/api/chat/cancel`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatMessage:async(t,n)=>{let a=await fetch(`/api/chat/message`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({channel_id:t,source_id:e(),text:n}),signal:AbortSignal.timeout(15e3)});if(!a.ok)throw new i(await r(a),a.status);return a.json()},chatPersona:async(e,t)=>{let n=await fetch(`/api/chat/persona`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({session_id:e,name:t}),signal:AbortSignal.timeout(15e3)});if(!n.ok)throw new i(await r(n),n.status);return n.json()},chatUpdate:()=>t(`/api/chat/update`),chatUpdateDefer:async e=>{let t=await fetch(`/api/chat/update/defer`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({snapshot:e}),signal:AbortSignal.timeout(15e3)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatUpdateInstall:async e=>{let t=await fetch(`/api/chat/update/install`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({snapshot:e}),signal:AbortSignal.timeout(12e4)});if(!t.ok)throw new i(await r(t),t.status);return t.json()},chatDangerous:()=>t(`/api/chat/dangerous`),chatDangerousRequest:async(e,t)=>{let n=await fetch(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.str
Line truncated
|
||||
<path d="${c(150,240)}" fill="none" stroke="var(--border)"
|
||||
stroke-width="12" stroke-linecap="round"/>
|
||||
<path d="${l(150,240)}" fill="none" stroke="${a}"
|
||||
<path d="${c(150,240)}" fill="none" stroke="${i}"
|
||||
stroke-width="12" stroke-linecap="round"
|
||||
stroke-dasharray="${c}"
|
||||
stroke-dashoffset="${c*(1-i/100)}"
|
||||
class="gauge-value"/>`,e(`div.gauge-wrap`,u,e(`div.gauge-center`,e(`div.gauge-pct`,`${Math.round(i)}%`),e(`div.gauge-label`,n)))}function x(t){let n=t.reduce((e,t)=>e+(t.value||0),0)||1;return e(`div`,e(`div.segbar`,...t.filter(e=>e.value>0).map(t=>e(`span`,{class:`segbar-part segbar-${t.kind||`idle`}`,style:`width:${(t.value/n*100).toFixed(1)}%`,title:`${t.label}: ${t.value}`}))),e(`div.segbar-legend`,...t.map(t=>e(`span.segbar-key`,e(`span`,{class:`segbar-dot segbar-${t.kind||`idle`}`}),t.label))))}var S=`archie.setup-complete.dismissed.v1`;function C(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(S),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function w(e=globalThis.localStorage){e?.setItem?.(S,`1`)}var T=new Set([`waiting_human`,`parked`]);function E(e=[]){let t=e.filter(e=>T.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}function D(){let t=e(`div`),i=e(`tbody`),a=e(`div.grid.grid-4`),c=e(`div`),u=e(`div`),d=e(`div.dash-top`,c,u),f=e(`div`),p=e(`div.hero-actions-inner`),m=e(`h1.hero-title`,A()),_=r(`connecting`,`idle`),y=[],b=new Map;S(),D();let x=g(e=>{y.unshift(e),y.splice(50),T()},e=>{_.className=`pill pill-${e===`live`?`ok`:`warn`}`,_.textContent=e});t.addEventListener(`archie:teardown`,x);function S(){n(t,e(`div.hero`,e(`div`,m,e(`p.hero-sub`,`Your agent's control room — what it is working on, what needs you, and what it is spending.`)),e(`div.hero-actions`,p)),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Health`)),d),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Throughput`),e(`span.dash-section-note`,`Across all repositories`)),a),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Right now`)),e(`div.dash-split`,f,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Live activity`),e(`p.card-sub`,`Last 50, newest first`)),_),e(`div.table-scroll`,e(`table.table`,e(`thead`,e(`tr`,...[`Event`,`Task`,`Detail`,`When`].map(t=>e(`th`,t)))),i)))))),T()}function T(){if(!y.length){n(i,e(`tr`,e(`td`,{colspan:4},s(`Waiting for activity`,`Events appear here as Archie works.`))));return}n(i,...y.map(e=>O(e,b)))}async function D(){try{let[e,t,n,r]=await Promise.all([h.summary(),h.setup().catch(()=>null),h.workflows().catch(()=>null),h.tasks().catch(()=>[])]);b.clear();for(let e of r)e.owner&&e.repo&&e.issue_number&&b.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);T(),k(r),m.textContent=t?.operator?`${A()}, ${t.operator}`:A(),P(e),F(t),I(e,n),L(e)}catch(t){n(a,e(`div.card`,s(`Cannot reach archied`,String(t.message||t)))),n(p,e(`button.btn.btn-primary`,{onclick:D},l(`refresh`,{size:15}),`Retry`))}}function k(t){let r=E(t),i=r.attention.count,a=r.running.count;n(p,i>0&&e(`a.btn.btn-attention`,{href:r.attention.href},l(`tasks`,{size:15}),`${i} need${i===1?`s`:``} you`),a>0&&e(`a.btn`,{href:r.running.href},l(`workflows`,{size:15}),`${a} running`),e(`a.btn`,{href:`#/logs`},l(`logs`,{size:15}),`Logs`),e(`button.btn.btn-primary`,{onclick:D},l(`refresh`,{size:15}),`Refresh`))}function P(e){let t=e?.statuses||{},r=(t.merged||0)+(t.pr_open||0),i=(t.parked||0)+(t.waiting_human||0),s=Object.values(t).reduce((e,t)=>e+t,0),c=e?.tokens_by_day||[];n(a,v({label:`Working now`,value:t.running||0,compare:`${t.queued||0} waiting to start`,series:c.map(e=>e.tokens||0)}),v({label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),v({label:`Delivered`,value:r,compare:s?`${Math.round(r/s*100)}% of all tasks`:`No tasks yet`}),v({label:`Tokens used`,value:o(c.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${c.length||0} days`,trend:N(c.map(e=>e.tokens||0)),goodDirection:`down`,series:c.map(e=>e.tokens||0)}))}function F(t){let r=C(t),i=r.kind===`omit`||r.kind===`dismissed`;if(d.classList.toggle(`dash-top-standalone`,i),i)return n(c);let a=r.remaining;if(a.length){let r=Math.round((t.steps.length-a.length)/t.steps.length*100);n(c,e(`div.card.setup`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Finish setting up`),e(`p.card-sub`,`Archie needs these before it can work on its own.`)),e(`span.setup-pct`,`${r}%`)),e(`div.setup-bar`,e(`div.setup-bar-fill`,{style:`width:${r}%`})),e(`ul.setup-list`,...t.steps.map(R))));return}n(c,e(`div.card.setup.setup-done`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Setup complete`),e(`p.card-sub`,`Archie is configured and ready to work.`)),e(`div.setup-complete-actions`,e(`span.setup-pct`,l(`check`,{size:16})),e(`button.icon-btn.setup-dismiss`,{type:`button`,title:`Dismiss setup complete`,"aria-label":`Dismiss setup complete`,onclick:()=>{w(),F(t)}},`×`)))))}function
Line truncated
|
||||
`)},e(`td.strong`,t.label||t.id),e(`td.mono`,t.install_type||`—`),e(`td.mono`,t.running_version||`—`),e(`td.mono`,t.latest_available||`—`),e(`td`,r(pe[t.status]||t.status,me[t.status]||`idle`)))))))):ge(`How each component is deployed, and whether what's running matches what's installed.`,s(`No components reported`,`The configured update-check command returned nothing.`))}function ge(t,...n){return e(`div.card.cfg-section`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Update status`),e(`p.card-sub`,t))),...n)}function _e(){let t=e(`div.cfg-page`),r=e(`div`),i=e(`div`);a(),o(),c();function a(){n(t,e(`div.page-head`,e(`div`,e(`h1.page-title`,`Configuration`),e(`p.page-sub`,`What archied is actually running with right now.`)),e(`div.page-actions`,e(`button.btn`,{onclick:()=>{o(),c()}},`Refresh`))),i,r)}async function o(){try{l(await h.config(),o)}catch(t){n(r,e(`div.card`,s(`Cannot reach archied`,String(t.message||t))))}}async function c(){try{let e=await h.version();n(i,he(e?.components||[]))}catch(t){if(t?.status===501){n(i);return}n(i,e(`div.card`,s(`Update status unavailable`,String(t.message||t))))}}function l(t,i){if(!t||Object.keys(t).length===0){n(r,e(`div.card`,s(`No configuration loaded`,`archied is running without a config file wired into the dashboard, so there is nothing to show.`)));return}let a={locked:t.locked||{},overridden:t.overridden||[],onSaved:i},o=[t.reload?.overlay_unavailable&&e(`div.card.cfg-notice`,e(`p`,`The runtime config overlay is not in effect: ${t.reload.overlay_unavailable}`)),t.reload?.last_error&&e(`div.card.cfg-notice`,e(`p`,`The last config reload failed; the running config is unchanged: ${t.reload.last_error}`))];n(r,...o,ye(t.identity,a),be(t.repositories),Se(t.models,t.providers),we(t.budgets,a),Te(t.storage,t.containers,a),De(t.web,a),ve(t.provenance))}return t}function ve(t){return t?.length?J(`Configuration sources`,`Applied from top to bottom; later entries take precedence over earlier ones.`,e(`div.kv-list`,...t.map(e=>q(`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,e.path)))):J(`Configuration sources`,`The files that supplied the running configuration.`,s(`Source provenance is unavailable.`))}function J(t,n,...r){return e(`div.card.cfg-section`,e(`div.card-head`,e(`div`,e(`h2.card-title`,t),e(`p.card-sub`,n))),...r)}function ye(t,n){return t?J(`Identity`,`Who Archie is on the forge, and how it addresses commits and comments.`,e(`div.kv-list`,q(`Bot account`,t.bot_user,{key:`bot_user`,type:`string`,raw:t.bot_user,...n}),q(`Commit author email`,t.bot_email,{key:`bot_email`,type:`string`,raw:t.bot_email,...n}),q(`Pickup label`,t.label,{key:`label`,type:`string`,raw:t.label,...n}),q(`Forge type`,t.forge_type,{key:`forge.type`,type:`string`,raw:t.forge_type,...n}),q(`Forge host`,t.forge_host,{key:`forge.host`,type:`string`,raw:t.forge_host,...n}),q(`Max diff size (lines)`,t.diff_cap_lines||`Unlimited`,{key:`diff_cap_lines`,type:`int`,raw:t.diff_cap_lines,...n}))):J(`Identity`,`Who Archie is on the forge.`,s(`Not available`))}function be(t){return t?.length?J(`Repositories`,`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request.`,e(`div.table-scroll`,e(`table.table`,e(`thead`,e(`tr`,...[`Repository`,`Base branch`,`Ecosystem`,`Quality gate`,`Protected paths`].map(t=>e(`th`,t)))),e(`tbody`,...t.map(t=>e(`tr`,e(`td.strong`,`${t.owner}/${t.name}`),e(`td.mono`,t.base),e(`td`,t.ecosystem||`go`),e(`td.mono`,xe(t.gate)),e(`td.mono`,t.protect?.length?t.protect.join(`, `):`—`))))))):J(`Repositories`,`The repositories Archie polls for work.`,s(`No repositories configured`,`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`))}function xe(e){return e?.length?e.map(e=>e.join(` `)).join(` → `):`—`}function Se(t,n){let i=Object.entries(t||{}),a=Object.entries(n||{}),o=i.length?e(`div.kv-list`,...i.map(([e,t])=>q(Ce(e),t))):s(`No model roles configured`,`Assign a model to at least one role (e.g. "builder") in [models].`),c=a.length?e(`div.table-scroll`,e(`table.table`,e(`thead`,e(`tr`,...[`Provider`,`Class`,`Base URL`,`API key env var`,`Status`].map(t=>e(`th`,t)))),e(`tbody`,...a.map(([t,n])=>e(`tr`,e(`td.strong`,t),e(`td`,n.class),e(`td.mono`,n.base_url||`default`),e(`td.mono`,n.api_key_env||`—`),e(`td`,n.configured?r(`configured`,`ok`):r(`missing credentials`,`warn`))))))):s(`No providers configured`,`Add a [providers.<name>] entry so a model role above has something to run on.`);return J(`Models & providers`,`Which model handles each stage of work, and which LLM providers are wired up. Only the environment variable NAME is shown, never its value.`,e(`h3.cfg-subhead`,`Model roles`),o,e(`h3.cfg-subhead`,`Providers`),c)}function Ce(e){return e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown role`}function we(t,n){return t?J(`Budgets`,`The limits every autonomous stage runs under, so a stuck task cannot run forever.`,e(`div.kv-list`,q(`Max steps`,t.max_steps||`Unlimited`,{key:`budLine truncated
|
||||
stroke-dasharray="${s}"
|
||||
stroke-dashoffset="${s*(1-r/100)}"
|
||||
class="gauge-value"/>`,y(`div.gauge-wrap`,l,y(`div.gauge-center`,y(`div.gauge-pct`,`${Math.round(r)}%`),y(`div.gauge-label`,t)))}function j(e){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return y(`div`,y(`div.segbar`,...e.filter(e=>e.value>0).map(e=>y(`span`,{class:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`}))),y(`div.segbar-legend`,...e.map(e=>y(`span.segbar-key`,y(`span`,{class:`segbar-dot segbar-${e.kind||`idle`}`}),e.label))))}var M=`archie.setup-complete.dismissed.v1`;function N(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(M),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function P(e=globalThis.localStorage){e?.setItem?.(M,`1`)}var F=new Set([`waiting_human`,`parked`]);function I(e=[]){let t=e.filter(e=>F.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}function L(){let e=y(`div`),t=y(`tbody`),n=y(`div.grid.grid-4`),r=y(`div`),i=y(`div`),s=y(`div.dash-top`,r,i),c=y(`div`),l=y(`div.hero-actions-inner`),u=y(`h1.hero-title`,B()),d=S(`connecting`,`idle`),f=[],p=new Map;h(),_();let m=o(e=>{f.unshift(e),f.splice(50),g()},e=>{d.className=`pill pill-${e===`live`?`ok`:`warn`}`,d.textContent=e});e.addEventListener(`archie:teardown`,m);function h(){x(e,y(`div.hero`,y(`div`,u,y(`p.hero-sub`,`Your agent's control room — what it is working on, what needs you, and what it is spending.`)),y(`div.hero-actions`,l)),y(`div.dash-section`,y(`div.dash-section-head`,y(`h2.dash-section-title`,`Health`)),s),y(`div.dash-section`,y(`div.dash-section-head`,y(`h2.dash-section-title`,`Throughput`),y(`span.dash-section-note`,`Across all repositories`)),n),y(`div.dash-section`,y(`div.dash-section-head`,y(`h2.dash-section-title`,`Right now`)),y(`div.dash-split`,c,y(`div.card`,y(`div.card-head`,y(`div`,y(`h2.card-title`,`Live activity`),y(`p.card-sub`,`Last 50, newest first`)),d),y(`div.table-scroll`,y(`table.table`,y(`thead`,y(`tr`,...[`Event`,`Task`,`Detail`,`When`].map(e=>y(`th`,e)))),t)))))),g()}function g(){if(!f.length){x(t,y(`tr`,y(`td`,{colspan:4},T(`Waiting for activity`,`Events appear here as Archie works.`))));return}x(t,...f.map(e=>R(e,p)))}async function _(){try{let[e,t,n,r]=await Promise.all([a.summary(),a.setup().catch(()=>null),a.workflows().catch(()=>null),a.tasks().catch(()=>[])]);p.clear();for(let e of r)e.owner&&e.repo&&e.issue_number&&p.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);g(),v(r),u.textContent=t?.operator?`${B()}, ${t.operator}`:B(),b(e),C(t),E(e,n),k(e)}catch(e){x(n,y(`div.card`,T(`Cannot reach archied`,String(e.message||e)))),x(l,y(`button.btn.btn-primary`,{onclick:_},D(`refresh`,{size:15}),`Retry`))}}function v(e){let t=I(e),n=t.attention.count,r=t.running.count;x(l,n>0&&y(`a.btn.btn-attention`,{href:t.attention.href},D(`tasks`,{size:15}),`${n} need${n===1?`s`:``} you`),r>0&&y(`a.btn`,{href:t.running.href},D(`workflows`,{size:15}),`${r} running`),y(`a.btn`,{href:`#/logs`},D(`logs`,{size:15}),`Logs`),y(`button.btn.btn-primary`,{onclick:_},D(`refresh`,{size:15}),`Refresh`))}function b(e){let t=e?.statuses||{},r=(t.merged||0)+(t.pr_open||0),i=(t.parked||0)+(t.waiting_human||0),a=Object.values(t).reduce((e,t)=>e+t,0),o=e?.tokens_by_day||[];x(n,O({label:`Working now`,value:t.running||0,compare:`${t.queued||0} waiting to start`,series:o.map(e=>e.tokens||0)}),O({label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),O({label:`Delivered`,value:r,compare:a?`${Math.round(r/a*100)}% of all tasks`:`No tasks yet`}),O({label:`Tokens used`,value:w(o.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${o.length||0} days`,trend:U(o.map(e=>e.tokens||0)),goodDirection:`down`,series:o.map(e=>e.tokens||0)}))}function C(e){let t=N(e),n=t.kind===`omit`||t.kind===`dismissed`;if(s.classList.toggle(`dash-top-standalone`,n),n)return x(r);let i=t.remaining;if(i.length){let t=Math.round((e.steps.length-i.length)/e.steps.length*100);x(r,y(`div.card.setup`,y(`div.card-head`,y(`div`,y(`h2.card-title`,`Finish setting up`),y(`p.card-sub`,`Archie needs these before it can work on its own.`)),y(`span.setup-pct`,`${t}%`)),y(`div.setup-bar`,y(`div.setup-bar-fill`,{style:`width:${t}%`})),y(`ul.setup-list`,...e.steps.map(A))));return}x(r,y(`div.card.setup.setup-done`,y(`div.card-head`,y(`div`,y(`h2.card-title`,`Setup complete`),y(`p.card-sub`,`Archie is configured and ready to work.`)),y(`div.setup-complete-actions`,y(`span.setup-pct`,D(`check`,{size:16})),y(`button.icon-btn.setup-dismiss`,{type:`button`,title:`Dismiss setup complete`,"aria-label":`Dismiss setup complete`,onclick:()=>{P(),C(e)}},`×`)))))}function
Line truncated
|
||||
`)},y(`td.strong`,e.label||e.id),y(`td.mono`,e.install_type||`—`),y(`td.mono`,e.running_version||`—`),y(`td.mono`,e.latest_available||`—`),y(`td`,S(xe[e.status]||e.status,Se[e.status]||`idle`)))))))):we(`How each component is deployed, and whether what's running matches what's installed.`,T(`No components reported`,`The configured update-check command returned nothing.`))}function we(e,...t){return y(`div.card.cfg-section`,y(`div.card-head`,y(`div`,y(`h2.card-title`,`Update status`),y(`p.card-sub`,e))),...t)}function Te(){let e=y(`div.cfg-page`),t=y(`div`),n=y(`div`),r=y(`div`);i(),o(),s(),c();function i(){x(e,y(`div.page-head`,y(`div`,y(`h1.page-title`,`Configuration`),y(`p.page-sub`,`What archied is actually running with right now.`)),y(`div.page-actions`,y(`button.btn`,{onclick:()=>{o(),s(),c()}},`Refresh`))),n,r,t)}async function o(){try{l(await a.config(),o)}catch(e){x(t,y(`div.card`,T(`Cannot reach archied`,String(e.message||e))))}}async function s(){try{let e=await a.version();x(n,Ce(e?.components||[]))}catch(e){if(e?.status===501){x(n);return}x(n,y(`div.card`,T(`Update status unavailable`,String(e.message||e))))}}async function c(){try{let e=await a.taskMeta();x(r,De(e))}catch(e){x(r,J(`Work lifecycle`,`The task statuses and operator actions archied ships.`,T(`Lifecycle unavailable`,String(e.message||e))))}}function l(e,n){if(!e||Object.keys(e).length===0){x(t,y(`div.card`,T(`No configuration loaded`,`archied is running without a config file wired into the dashboard, so there is nothing to show.`)));return}let r={locked:e.locked||{},overridden:e.overridden||[],onSaved:n},i=[e.reload?.overlay_unavailable&&y(`div.card.cfg-notice`,y(`p`,`The runtime config overlay is not in effect: ${e.reload.overlay_unavailable}`)),e.reload?.last_error&&y(`div.card.cfg-notice`,y(`p`,`The last config reload failed; the running config is unchanged: ${e.reload.last_error}`))];x(t,...i,je(e.identity,r),Me(e.repositories),Pe(e.models,e.providers),Ie(e.budgets,r),Le(e.storage,e.containers,r),ze(e.web,r),Ee(e.provenance))}return e}function Ee(e){return e?.length?J(`Configuration sources`,`Applied from top to bottom; later entries take precedence over earlier ones.`,y(`div.kv-list`,...e.map(e=>q(`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,e.path)))):J(`Configuration sources`,`The files that supplied the running configuration.`,T(`Source provenance is unavailable.`))}function J(e,t,...n){return y(`div.card.cfg-section`,y(`div.card-head`,y(`div`,y(`h2.card-title`,e),y(`p.card-sub`,t))),...n)}function De(e){let t=e?.statuses||[],n=e?.actions||[],r=t.length?y(`div.kv-list`,...t.map(e=>Oe(e))):T(`No statuses reported`,`The server did not return any lifecycle statuses.`),i=n.length?y(`div.kv-list`,...n.map(e=>ke(e))):T(`No actions reported`,`The server did not return any operator actions.`);return J(`Work lifecycle`,`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,y(`h3.cfg-subhead`,`Statuses`),r,y(`h3.cfg-subhead`,`Actions`),i)}function Oe(e){let t=e.label??m(e.id),n=e.kind??h(e.id);return y(`div.kv`,y(`span.kv-label`,e.id),y(`span.kv-value`,S(t,n)))}function ke(e){let t=e.label??e.id,n=Ae(e.kind),r=n?`button.btn.btn-small.${n}`:`button.btn.btn-small`;return y(`div.kv`,y(`span.kv-label`,e.id),y(`span.kv-value`,y(r,{type:`button`,disabled:!0},t)))}function Ae(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function je(e,t){return e?J(`Identity`,`Who Archie is on the forge, and how it addresses commits and comments.`,y(`div.kv-list`,q(`Bot account`,e.bot_user,{key:`bot_user`,type:`string`,raw:e.bot_user,...t}),q(`Commit author email`,e.bot_email,{key:`bot_email`,type:`string`,raw:e.bot_email,...t}),q(`Pickup label`,e.label,{key:`label`,type:`string`,raw:e.label,...t}),q(`Forge type`,e.forge_type,{key:`forge.type`,type:`string`,raw:e.forge_type,...t}),q(`Forge host`,e.forge_host,{key:`forge.host`,type:`string`,raw:e.forge_host,...t}),q(`Max diff size (lines)`,e.diff_cap_lines||`Unlimited`,{key:`diff_cap_lines`,type:`int`,raw:e.diff_cap_lines,...t}))):J(`Identity`,`Who Archie is on the forge.`,T(`Not available`))}function Me(e){return e?.length?J(`Repositories`,`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request.`,y(`div.table-scroll`,y(`table.table`,y(`thead`,y(`tr`,...[`Repository`,`Base branch`,`Ecosystem`,`Quality gate`,`Protected paths`].map(e=>y(`th`,e)))),y(`tbody`,...e.map(e=>y(`tr`,y(`td.strong`,`${e.owner}/${e.name}`),y(`td.mono`,e.base),y(`td`,e.ecosystem||`go`),y(`td.mono`,Ne(e.gate)),y(`td.mono`,e.protect?.length?e.protect.join(`, `):`—`))))))):J(`Repositories`,`The repositories Archie polls for work.`,T(`No repositories configured`,`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`))}function Ne(e){return e?.length?e.map(e=>e.join(` `)).join(` → `):`—`}function Pe(e,t){let n=Object.entries(e||{}),r=Object.entries(t||{}),i=n.length?y(`Line truncated
|
||||
<div class="chat-page-content">
|
||||
<header class="chat-topbar">
|
||||
<div><span class="chat-kicker">ARCHIE WORKSPACE</span><h1 class="page-title">Chat</h1></div>
|
||||
@@ -72,10 +72,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;function tt(){let e=document.createElement(`template`);e.innerHTML=et.trim();let t=e.content.firstElementChild,n={};for(let e of t.querySelectorAll(`[data-chat-ref]`))n[e.dataset.chatRef]=e;return{root:t,refs:n}}function Y(t){let n=document.createDocumentFragment(),r=/(~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|`[^`]+`|\[[^\]]+\]\(https?:\/\/[^\s)]+\)|\*[^*]+\*|_[^_]+_)/g,i=0;for(let a of t.matchAll(r)){a.index>i&&n.append(document.createTextNode(t.slice(i,a.index)));let r=a[0];if(r.startsWith(`~~`))n.append(e(`del`,r.slice(2,-2)));else if(r.startsWith(`**`)||r.startsWith(`__`))n.append(e(`strong`,r.slice(2,-2)));else if(r.startsWith("`"))n.append(e(`code`,r.slice(1,-1)));else if(r.startsWith(`[`)){let t=r.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)$/);n.append(e(`a`,{href:t[2],target:`_blank`,rel:`noreferrer`},t[1]))}else n.append(e(`em`,r.slice(1,-1)));i=a.index+r.length}return i<t.length&&n.append(document.createTextNode(t.slice(i))),n}function nt(t){let n=e(`div.chat-bubble-text`),r=String(t||``).split(`
|
||||
`),i=[],a=null,o=null,s=()=>{i.length&&(n.append(e(`p`,Y(i.join(` `)))),i=[])},c=()=>{a&&n.append(a),a=null};for(let t=0;t<r.length;t++){let l=r[t];if(l.startsWith("```")){s(),c(),o?(n.append(e(`pre`,e(`code`,o.join(`
|
||||
`)))),o=null):o=[];continue}if(o){o.push(l);continue}let u=rt(l),d=t+1<r.length?rt(r[t+1]):null;if(u&&d&&it(d)&&u.length===d.length){s(),c();let i=[];for(t+=2;t<r.length;t++){let e=rt(r[t]);if(!e||e.length!==u.length){t--;break}i.push(e)}let a=e(`tbody`);for(let t of i)a.append(e(`tr`,...t.map(t=>e(`td`,Y(t)))));n.append(e(`table`,e(`thead`,e(`tr`,...u.map(t=>e(`th`,Y(t))))),a));continue}if(!l.trim()){s(),c();continue}let f=l.match(/^(#{1,3})\s+(.+)$/);if(f){s(),c(),n.append(e(`h${f[1].length}`,Y(f[2])));continue}let p=l.match(/^\s*[-*]\s+(.+)$/),m=l.match(/^\s*\d+[.)]\s+(.+)$/);if(p||m){s();let t=m?`ol`:`ul`;(!a||a.tagName.toLowerCase()!==t)&&(c(),a=e(t)),a.append(e(`li`,Y((p||m)[1])));continue}if(l.startsWith(`>`)){s(),c(),n.append(e(`blockquote`,Y(l.replace(/^>\s?/,``))));continue}i.push(l)}return s(),c(),o&&n.append(e(`pre`,e(`code`,o.join(`
|
||||
`)))),n}function rt(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 it(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}function at(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function ot(){return e(`div.chat-bubble-row.assistant`,e(`div.chat-bubble`,e(`div.chat-bubble-meta`,`Archie`),e(`div.chat-tools`),e(`div.chat-bubble-text`)))}function st(t){let n=t.from??t.From??``,r=t.text??t.Text??``,i=n!==`web`;return e(`div.chat-bubble-row.${i?`assistant`:`user`}`,e(`div.chat-bubble`,e(`div.chat-bubble-meta`,i?`Archie`:`You`),i?ct(t,r):e(`div.chat-bubble-text`,r)))}function ct(t,n){let r=t.tool_calls||t.ToolCalls||[],i=[e(`div.chat-tools`)];for(let t of r){let n=!!(t.err||t.Err);i[0].append(e(`div.chat-tool`+(n?`.failed`:``),e(`span.chat-tool-icon`,`🔧`),e(`span.chat-tool-name`,t.name||t.Name||`tool`),e(`span.chat-tool-summary`,t.summary||t.Summary||t.err||t.Err||`done`)))}return i.push(nt(n)),i}function X(e,t){let n=nt(t);return typeof e?.replaceWith==`function`?e.replaceWith(n):e?.parentNode&&e.parentNode.replaceChild(n,e),n}function lt(t,n){let r=n?.tool??``;if(!t||!r)return null;let i=n.parameters??``,a=n.text??``,o=e(`div.chat-tool`,e(`span.chat-tool-icon`,`🔧`),e(`span.chat-tool-name`,r),i&&e(`code.chat-tool-parameters`,i),e(`span.chat-tool-summary`,a));return n.failed&&(o.className=`chat-tool failed`),ut(t).append(o),o}function ut(t){let n=t.querySelector(`.chat-tools`);if(n)return n;let r=e(`div.chat-tools`);return t.append(r),r}var dt=`archie.web.chat.channel`;function Z(){let e=localStorage.getItem(dt);return e||(e=u(),localStorage.setItem(dt,e)),e}function ft(e){return{text:e,sourceID:u()}}function pt(e){return{...e}}function mt(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?pt(e.turn):ft(r),isRetry:n}}function ht({sessionList:t,sessionTools:n,sessions:r,currentSession:i,onSelect:a}){if(t.replaceChildren(),n.hidden=!i,!r.length){t.append(e(`div.chat-empty`,`Your conversations will appear here.`));return}for(let n of r)t.append(e(`button.chat-session`,{class:i===n.session_id?`active`:``,onclick:()=>a(n.session_id)},e(`strong`,at(n)),e(`span`,new Date(n.last_active_at).toLocaleString())))}function gt(t,n,r){t.persona.replaceChildren(e(`option`,{value:``},`Personality`));for(let r of n.personas||[])t.persona.append(e(`option`,{value:r},r));t.persona.value=n.active_persona||``;let i=n.providers||[];t.provider.hidden=i.length===0,t.provider.replaceChildren(e(`option`,{value:``},`Provider`));for(let n of i)t.provider.append(e(`option`,{value:n},n));t.provider.value=n.active_provider||i[0]||``,_t(t,n,t.provider.value),t.restart.hidden=!n.restart_available,t.dangerousPanel.hidden=!n.dangerous_available,n.dangerous_available&&r()}function _t(t,n,r){let i=n.models_by_provider||{},a=r&&i[r]?i[r]:n.models||[];t.model.replaceChildren(e(`option`,{value:``},`Model`));for(let n of a)t.model.append(e(`option`,{value:n},n));t.model.value=n.active_model||``}function vt(t,n){let r=(n||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e),i=e(`div.chat-command-list`);r.length||i.append(e(`span`,`Send a message to begin.`));for(let t of r)i.append(e(`div.chat-command-item`,e(`code`,t.usage||t.command),e(`span`,t.description||``)));return t.replaceChildren(e(`summary`,`Available commands (${r.length})`),i),r}function yt(t,n,{onDefer:r,onInstall:i}){t.replaceChildren();let a=n?.snapshot||null,o=n?.available||[];if(!o.length){t.append(e(`span`,a?.deferred?`Update deferred.`:`Archie is up to date.`));return}t.append(e(`div`,e(`strong`,`Update available`),e(`span`,o.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `))),e(`div.chat-update-actions`,e(`button.btn`,{onclick:r},`Defer`),n.can_install?e(`button.btn.btn-primary`,{onclick:i},`Install update`):null))}function bt(t,n,{onRequest:r,onDecision:i}){t.replaceChildren();let a=n?.checkpoints||[],o=n?.pending||[],s=e(`select.chat-select`,{"aria-label":`Checkpoint`},e(`option`,{value:``},`Select checkpoint`),...a.map(t=>e(`option`,{value:t.Number??t.number},`${t.Number??t.number} — ${t.Label??t.label??`checkpoint`}`))),c=e(`input.chat-dangerous-input`,{placeholder:`Process name or id`,"aria-label":`Process name or id`}),l=(e,t)=>()=>r(e,String(t.value||t).trim()),u=(t,n,r)=>e(`button.btn`,{onclick:()=>i(t,n)},r),d=o.length?o.map(t=>e(`div.chat-dangerous-pending`,e(`span`,t.description),e(`div.chat-update-actions`,u(t.id,`approve`,`Approve`),u(t.id,`permanent`,`Approve for 24h`),u(t.id,`deny`,`Deny`)))):[e(`span.chat-hint`,`No pending dangerous actions.`)];t.append(e(`div.chat-dangerous-head`,e(`strong`,`Dangerous actions`),e(`span.chat-hint`,`Every action requires approval.`)),e(`div.chat-dangerous-controls`,e(`div`,s,e(`button.btn`,{onclick:l(`rollback`,s)},`Request rollback`)),e(`div`,c,e(`button.btn`,{
Line truncated
|
||||
`;function pt(){let e=document.createElement(`template`);e.innerHTML=ft.trim();let t=e.content.firstElementChild,n={};for(let e of t.querySelectorAll(`[data-chat-ref]`))n[e.dataset.chatRef]=e;return{root:t,refs:n}}function Y(e){let t=document.createDocumentFragment(),n=/(~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|`[^`]+`|\[[^\]]+\]\(https?:\/\/[^\s)]+\)|\*[^*]+\*|_[^_]+_)/g,r=0;for(let i of e.matchAll(n)){i.index>r&&t.append(document.createTextNode(e.slice(r,i.index)));let n=i[0];if(n.startsWith(`~~`))t.append(y(`del`,n.slice(2,-2)));else if(n.startsWith(`**`)||n.startsWith(`__`))t.append(y(`strong`,n.slice(2,-2)));else if(n.startsWith("`"))t.append(y(`code`,n.slice(1,-1)));else if(n.startsWith(`[`)){let e=n.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)$/);t.append(y(`a`,{href:e[2],target:`_blank`,rel:`noreferrer`},e[1]))}else t.append(y(`em`,n.slice(1,-1)));r=i.index+n.length}return r<e.length&&t.append(document.createTextNode(e.slice(r))),t}function mt(e){let t=y(`div.chat-bubble-text`),n=String(e||``).split(`
|
||||
`),r=[],i=null,a=null,o=()=>{r.length&&(t.append(y(`p`,Y(r.join(` `)))),r=[])},s=()=>{i&&t.append(i),i=null};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.append(y(`pre`,y(`code`,a.join(`
|
||||
`)))),a=null):a=[];continue}if(a){a.push(c);continue}let l=ht(c),u=e+1<n.length?ht(n[e+1]):null;if(l&&u&>(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=ht(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}let i=y(`tbody`);for(let e of r)i.append(y(`tr`,...e.map(e=>y(`td`,Y(e)))));t.append(y(`table`,y(`thead`,y(`tr`,...l.map(e=>y(`th`,Y(e))))),i));continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.append(y(`h${d[1].length}`,Y(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.tagName.toLowerCase()!==e)&&(s(),i=y(e)),i.append(y(`li`,Y((f||p)[1])));continue}if(c.startsWith(`>`)){o(),s(),t.append(y(`blockquote`,Y(c.replace(/^>\s?/,``))));continue}r.push(c)}return o(),s(),a&&t.append(y(`pre`,y(`code`,a.join(`
|
||||
`)))),t}function ht(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 gt(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}function _t(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function vt(){return y(`div.chat-bubble-row.assistant`,y(`div.chat-bubble`,y(`div.chat-bubble-meta`,`Archie`),y(`div.chat-tools`),y(`div.chat-bubble-text`)))}function yt(e){let t=e.from??e.From??``,n=e.text??e.Text??``,r=t!==`web`;return y(`div.chat-bubble-row.${r?`assistant`:`user`}`,y(`div.chat-bubble`,y(`div.chat-bubble-meta`,r?`Archie`:`You`),r?bt(e,n):y(`div.chat-bubble-text`,n)))}function bt(e,t){let n=e.tool_calls||e.ToolCalls||[],r=[y(`div.chat-tools`)];for(let e of n){let t=!!(e.err||e.Err);r[0].append(y(`div.chat-tool`+(t?`.failed`:``),y(`span.chat-tool-icon`,`🔧`),y(`span.chat-tool-name`,e.name||e.Name||`tool`),y(`span.chat-tool-summary`,e.summary||e.Summary||e.err||e.Err||`done`)))}return r.push(mt(t)),r}function X(e,t){let n=mt(t);return typeof e?.replaceWith==`function`?e.replaceWith(n):e?.parentNode&&e.parentNode.replaceChild(n,e),n}function xt(e,t){let n=t?.tool??``;if(!e||!n)return null;let r=t.parameters??``,i=t.text??``,a=y(`div.chat-tool`,y(`span.chat-tool-icon`,`🔧`),y(`span.chat-tool-name`,n),r&&y(`code.chat-tool-parameters`,r),y(`span.chat-tool-summary`,i));return t.failed&&(a.className=`chat-tool failed`),St(e).append(a),a}function St(e){let t=e.querySelector(`.chat-tools`);if(t)return t;let n=y(`div.chat-tools`);return e.append(n),n}var Ct=`archie.web.chat.channel`;function Z(){let t=localStorage.getItem(Ct);return t||(t=e(),localStorage.setItem(Ct,t)),t}function wt(t){return{text:t,sourceID:e()}}function Tt(e){return{...e}}function Et(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?Tt(e.turn):wt(r),isRetry:n}}function Dt({sessionList:e,sessionTools:t,sessions:n,currentSession:r,onSelect:i}){if(e.replaceChildren(),t.hidden=!r,!n.length){e.append(y(`div.chat-empty`,`Your conversations will appear here.`));return}for(let t of n)e.append(y(`button.chat-session`,{class:r===t.session_id?`active`:``,onclick:()=>i(t.session_id)},y(`strong`,_t(t)),y(`span`,new Date(t.last_active_at).toLocaleString())))}function Ot(e,t,n){e.persona.replaceChildren(y(`option`,{value:``},`Personality`));for(let n of t.personas||[])e.persona.append(y(`option`,{value:n},n));e.persona.value=t.active_persona||``;let r=t.providers||[];e.provider.hidden=r.length===0,e.provider.replaceChildren(y(`option`,{value:``},`Provider`));for(let t of r)e.provider.append(y(`option`,{value:t},t));e.provider.value=t.active_provider||r[0]||``,kt(e,t,e.provider.value),e.restart.hidden=!t.restart_available,e.dangerousPanel.hidden=!t.dangerous_available,t.dangerous_available&&n()}function kt(e,t,n){let r=t.models_by_provider||{},i=n&&r[n]?r[n]:t.models||[];e.model.replaceChildren(y(`option`,{value:``},`Model`));for(let t of i)e.model.append(y(`option`,{value:t},t));e.model.value=t.active_model||``}function At(e,t){let n=(t||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e),r=y(`div.chat-command-list`);n.length||r.append(y(`span`,`Send a message to begin.`));for(let e of n)r.append(y(`div.chat-command-item`,y(`code`,e.usage||e.command),y(`span`,e.description||``)));return e.replaceChildren(y(`summary`,`Available commands (${n.length})`),r),n}function jt(e,t,{onDefer:n,onInstall:r}){e.replaceChildren();let i=t?.snapshot||null,a=t?.available||[];if(!a.length){e.append(y(`span`,i?.deferred?`Update deferred.`:`Archie is up to date.`));return}e.append(y(`div`,y(`strong`,`Update available`),y(`span`,a.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `))),y(`div.chat-update-actions`,y(`button.btn`,{onclick:n},`Defer`),t.can_install?y(`button.btn.btn-primary`,{onclick:r},`Install update`):null))}function Mt(e,t,{onRequest:n,onDecision:r}){e.replaceChildren();let i=t?.checkpoints||[],a=t?.pending||[],o=y(`select.chat-select`,{"aria-label":`Checkpoint`},y(`option`,{value:``},`Select checkpoint`),...i.map(e=>y(`option`,{value:e.Number??e.number},`${e.Number??e.number} — ${e.Label??e.label??`checkpoint`}`))),s=y(`input.chat-dangerous-input`,{placeholder:`Process name or id`,"aria-label":`Process name or id`}),c=(e,t)=>()=>n(e,String(t.value||t).trim()),l=(e,t,n)=>y(`button.btn`,{onclick:()=>r(e,t)},n),u=a.length?a.map(e=>y(`div.chat-dangerous-pending`,y(`span`,e.description),y(`div.chat-update-actions`,l(e.id,`approve`,`Approve`),l(e.id,`permanent`,`Approve for 24h`),l(e.id,`deny`,`Deny`)))):[y(`span.chat-hint`,`No pending dangerous actions.`)];e.append(y(`div.chat-dangerous-head`,y(`strong`,`Dangerous actions`),y(`span.chat-hint`,`Every action requires approval.`)),y(`div.chat-dangerous-controls`,y(`div`,o,y(`button.btn`,{onclick:c(`rollback`,o)},`Request rollback`)),y(`div`,s,y(`button.btn`,{
Line truncated
|
||||
|
||||
`);i=a.pop()||``;for(let e of a){let t=e.split(`
|
||||
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(S=n.session_id),n.type===`delta`&&(f+=n.text,d=X(d,f)),n.type===`tool`&<(u.querySelector(`.chat-bubble`)??u,n),n.type===`done`&&(p=!0,f||(f=n.text,d=X(d,f))),n.type===`error`)throw Error(n.text)}if(r)break}if(!p)throw Error(`chat stream ended before completion`);d.isConnected&&(d=X(d,f)),c.textContent=`Ready`,await R()}catch(t){if(t.name===`AbortError`&&!m)d=X(d,`Turn stopped.`),c.textContent=`Stopped`;else{d=X(d,`Unable to complete that turn: ${t.message||t}`);let n=pt(r),i=e(`button.btn.chat-retry`,{type:`button`,onclick:()=>H({turn:n,replyBubble:u})},`Retry`);u.append(i),c.textContent=`Error — retry available`}}finally{clearTimeout(h),T=null,w=!1,o.disabled=!1,s.disabled=!0,a.disabled=!1,a.focus()}}o.onclick=()=>H(),s.onclick=()=>{let e=S;c.textContent=`Stopping…`,e&&h.chatCancel(e).catch(()=>{}),T?.abort()},a.oninput=P,a.onkeydown=e=>{if(!_.hidden&&k.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&k.some(e=>e.command===a.value.trim())){e.preventDefault(),N(),H();return}if(e.key===`ArrowDown`){e.preventDefault(),A=(A+1)%k.length,P();return}if(e.key===`ArrowUp`){e.preventDefault(),A=(A+k.length-1)%k.length,P();return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),F(A);return}if(e.key===`Escape`){e.preventDefault(),N();return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),H())},l.onchange=async()=>{!S||!l.value||(await h.chatPersona(S,l.value),D.active_personas={...D.active_personas||{},[S]:l.value},c.textContent=`Personality: ${l.value}`)},u.onchange=async()=>{_t({model:d},D,u.value),u.value&&await U(`/model --provider ${u.value}`)},d.onchange=async()=>{d.value&&await U(`/model ${d.value}`)};async function U(e){try{let t=await h.chatMessage(Z(),e);c.textContent=t.reply||`Model updated`,await R()}catch(e){c.textContent=`Model update failed: ${e.message||e}`}}b.onclick=I;let ee={retry:()=>z(`/retry`),undo:()=>z(`/undo`),title:()=>B(`/title`,`Session title`),branch:()=>B(`/branch`,`Branch name (optional)`),compress:()=>z(`/compress --preview`)};for(let e of t.querySelectorAll(`[data-chat-action]`))e.onclick=ee[e.dataset.chatAction];return R().catch(e=>{c.textContent=e.message||`Chat unavailable`}),I(),t}var Q=[{path:`/`,label:`Dashboard`,icon:`dashboard`,view:D},{path:`/chat`,label:`Chat`,icon:`chat`,view:St},{path:`/tasks`,label:`Tasks`,icon:`tasks`,view:te},{path:`/logs`,label:`Logs`,icon:`logs`,view:Ae},{path:`/captures`,label:`Event inspector`,icon:`captures`,view:Ve},{path:`/mappings`,label:`Field mappings`,icon:`mappings`,view:Xe},{path:`/skills`,label:`Skills`,icon:`skills`,view:ne},{path:`/workflows`,label:`Workflows`,icon:`workflows`,view:ae},{path:`/memory`,label:`Memory`,icon:`memory`,view:Ze},{path:`/channels`,label:`Channels`,icon:`channels`,view:oe},{path:`/settings`,label:`Configuration`,icon:`settings`,view:_e}],Ct=`archie.theme`;function wt(e){document.documentElement.dataset.theme=e,localStorage.setItem(Ct,e)}function $(){return localStorage.getItem(Ct)||`dark`}function Tt(t){let r=new Map,i=e(`nav.nav`,...[null].flatMap(()=>[...Q.map(n=>{let i=e(`a.nav-item`,{href:`#${n.path}`,onclick:e=>{n.soon?e.preventDefault():t(n.path)},"aria-disabled":n.soon||void 0,title:n.soon?`Coming soon`:void 0},l(n.icon),e(`span.nav-label`,n.label),n.soon&&e(`span.nav-soon`,`soon`));return r.set(n.path,i),i})])),a=e(`button.icon-btn`,{title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onclick:()=>{wt($()===`dark`?`light`:`dark`),n(a,l($()===`dark`?`moon`:`sun`))}});n(a,l($()===`dark`?`moon`:`sun`));let o,s=()=>{o?.classList.remove(`is-open`),c.setAttribute(`aria-expanded`,`false`)},c=e(`button.icon-btn.mobile-search-toggle`,{type:`button`,"aria-label":`Open Jump to navigation`,"aria-expanded":`false`,onclick:()=>{o.classList.add(`is-open`),c.setAttribute(`aria-expanded`,`true`),u.focus()}},l(`search`,{size:15})),u=e(`input`,{type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onkeydown:e=>{if(e.key===`Escape`){s(),e.target.blur();return}if(e.key!==`Enter`)return;let n=e.target.value.trim().toLowerCase(),r=Q.find(e=>!e.soon&&e.label.toLowerCase().startsWith(n));r&&(t(r.path),e.target.value=``,e.target.blur(),s())}});return o=e(`div.topbar-search`,e(`span.topbar-search-icon`,{"aria-hidden":`true`},l(`search`,{size:15})),c,u),{node:e(`header.topbar`,e(`div.brand`,e(`span.brand-mark`,`A`),`Archie`),i,e(`div.topbar-end`,o,e(`button.icon-btn`,{title:`Documentation`,"aria-label":`Documentation`},l(`help`)),a,e(`div.avatar`,{title:`Signed in locally`},`A`))),highlight(e){for(let[t,n]of r)t===e?n.setAttribute(`aria-current`,`page`):n.removeAttribute(`aria-current`)}}}function Et(){wt($());let t=e(`main.main`),r=Tt(i);n(document.getElementById(`app`),e(`div.shell`,r.node,t));function i(e){location.hash===`#${e}`?a(e):location.hash=e}function a(e){t.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`));let[i,a=``]=e.spli
Line truncated
|
||||
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(S=n.session_id),n.type===`delta`&&(d+=n.text,u=X(u,d)),n.type===`tool`&&xt(l.querySelector(`.chat-bubble`)??l,n),n.type===`done`&&(f=!0,d||(d=n.text,u=X(u,d))),n.type===`error`)throw Error(n.text)}if(n)break}if(!f)throw Error(`chat stream ended before completion`);u.isConnected&&(u=X(u,d)),c.textContent=`Ready`,await R()}catch(e){if(e.name===`AbortError`&&!p)u=X(u,`Turn stopped.`),c.textContent=`Stopped`;else{u=X(u,`Unable to complete that turn: ${e.message||e}`);let t=Tt(n),r=y(`button.btn.chat-retry`,{type:`button`,onclick:()=>H({turn:t,replyBubble:l})},`Retry`);l.append(r),c.textContent=`Error — retry available`}}finally{clearTimeout(m),T=null,w=!1,o.disabled=!1,s.disabled=!0,i.disabled=!1,i.focus()}}o.onclick=()=>H(),s.onclick=()=>{let e=S;c.textContent=`Stopping…`,e&&a.chatCancel(e).catch(()=>{}),T?.abort()},i.oninput=P,i.onkeydown=e=>{if(!g.hidden&&k.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&k.some(e=>e.command===i.value.trim())){e.preventDefault(),N(),H();return}if(e.key===`ArrowDown`){e.preventDefault(),A=(A+1)%k.length,P();return}if(e.key===`ArrowUp`){e.preventDefault(),A=(A+k.length-1)%k.length,P();return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),F(A);return}if(e.key===`Escape`){e.preventDefault(),N();return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),H())},l.onchange=async()=>{!S||!l.value||(await a.chatPersona(S,l.value),D.active_personas={...D.active_personas||{},[S]:l.value},c.textContent=`Personality: ${l.value}`)},u.onchange=async()=>{kt({model:d},D,u.value),u.value&&await U(`/model --provider ${u.value}`)},d.onchange=async()=>{d.value&&await U(`/model ${d.value}`)};async function U(e){try{let t=await a.chatMessage(Z(),e);c.textContent=t.reply||`Model updated`,await R()}catch(e){c.textContent=`Model update failed: ${e.message||e}`}}b.onclick=I;let ee={retry:()=>z(`/retry`),undo:()=>z(`/undo`),title:()=>B(`/title`,`Session title`),branch:()=>B(`/branch`,`Branch name (optional)`),compress:()=>z(`/compress --preview`)};for(let t of e.querySelectorAll(`[data-chat-action]`))t.onclick=ee[t.dataset.chatAction];return R().catch(e=>{c.textContent=e.message||`Chat unavailable`}),I(),e}var Q=[{path:`/`,label:`Dashboard`,icon:`dashboard`,view:L},{path:`/chat`,label:`Chat`,icon:`chat`,view:Pt},{path:`/tasks`,label:`Tasks`,icon:`tasks`,view:ce},{path:`/logs`,label:`Logs`,icon:`logs`,view:He},{path:`/captures`,label:`Event inspector`,icon:`captures`,view:$e},{path:`/mappings`,label:`Field mappings`,icon:`mappings`,view:ct},{path:`/skills`,label:`Skills`,icon:`skills`,view:le},{path:`/workflows`,label:`Workflows`,icon:`workflows`,view:pe},{path:`/memory`,label:`Memory`,icon:`memory`,view:lt},{path:`/channels`,label:`Channels`,icon:`channels`,view:me},{path:`/settings`,label:`Configuration`,icon:`settings`,view:Te}],Ft=`archie.theme`;function It(e){document.documentElement.dataset.theme=e,localStorage.setItem(Ft,e)}function $(){return localStorage.getItem(Ft)||`dark`}function Lt(e){let t=new Map,n=y(`nav.nav`,...[null].flatMap(()=>[...Q.map(n=>{let r=y(`a.nav-item`,{href:`#${n.path}`,onclick:t=>{n.soon?t.preventDefault():e(n.path)},"aria-disabled":n.soon||void 0,title:n.soon?`Coming soon`:void 0},D(n.icon),y(`span.nav-label`,n.label),n.soon&&y(`span.nav-soon`,`soon`));return t.set(n.path,r),r})])),r=y(`button.icon-btn`,{title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onclick:()=>{It($()===`dark`?`light`:`dark`),x(r,D($()===`dark`?`moon`:`sun`))}});x(r,D($()===`dark`?`moon`:`sun`));let i,a=()=>{i?.classList.remove(`is-open`),o.setAttribute(`aria-expanded`,`false`)},o=y(`button.icon-btn.mobile-search-toggle`,{type:`button`,"aria-label":`Open Jump to navigation`,"aria-expanded":`false`,onclick:()=>{i.classList.add(`is-open`),o.setAttribute(`aria-expanded`,`true`),s.focus()}},D(`search`,{size:15})),s=y(`input`,{type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onkeydown:t=>{if(t.key===`Escape`){a(),t.target.blur();return}if(t.key!==`Enter`)return;let n=t.target.value.trim().toLowerCase(),r=Q.find(e=>!e.soon&&e.label.toLowerCase().startsWith(n));r&&(e(r.path),t.target.value=``,t.target.blur(),a())}});return i=y(`div.topbar-search`,y(`span.topbar-search-icon`,{"aria-hidden":`true`},D(`search`,{size:15})),o,s),{node:y(`header.topbar`,y(`div.brand`,y(`span.brand-mark`,`A`),`Archie`),n,y(`div.topbar-end`,i,y(`button.icon-btn`,{title:`Documentation`,"aria-label":`Documentation`},D(`help`)),r,y(`div.avatar`,{title:`Signed in locally`},`A`))),highlight(e){for(let[n,r]of t)n===e?r.setAttribute(`aria-current`,`page`):r.removeAttribute(`aria-current`)}}}function Rt(){It($());let e=y(`main.main`),t=Lt(n);x(document.getElementById(`app`),y(`div.shell`,t.node,e));function n(e){location.hash===`#${e}`?r(e):location.hash=e}function r(n){e.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`));let[r,i=``]=n.spli
Line truncated
|
||||
+4
-21
@@ -52,27 +52,10 @@ export function pill(text, kind = "idle") {
|
||||
return el(`span.pill.pill-${kind}`, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map an archie task status onto a pill kind. Centralised so "merged" is the
|
||||
* same green everywhere it appears.
|
||||
*/
|
||||
export function statusKind(status) {
|
||||
switch (status) {
|
||||
case "running":
|
||||
return "info";
|
||||
case "merged":
|
||||
case "pr_open":
|
||||
return "ok";
|
||||
case "parked":
|
||||
case "waiting_human":
|
||||
return "warn";
|
||||
case "dead":
|
||||
case "rejected":
|
||||
return "danger";
|
||||
default:
|
||||
return "idle";
|
||||
}
|
||||
}
|
||||
// Re-exported from task-meta.js so the pill severity vocabulary has a single
|
||||
// source (the server catalog). Importers that pull statusKind from dom.js --
|
||||
// e.g. dashboard.js -- keep working, and the hardcoded switch is gone.
|
||||
export { statusKind } from "./task-meta.js";
|
||||
|
||||
/** Humanised relative time: "2 min ago". Raw timestamps make people do maths. */
|
||||
export function ago(value) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import "./settings.css";
|
||||
import { api } from "../base/api.js";
|
||||
import { el, empty, mount, pill } from "../base/dom.js";
|
||||
import { statusKind, statusLabel } from "../base/task-meta.js";
|
||||
import { row } from "./config-row.js";
|
||||
import { updateStatusCard } from "./update-status.js";
|
||||
|
||||
@@ -25,10 +26,12 @@ export function settingsPage() {
|
||||
const root = el("div.cfg-page");
|
||||
const body = el("div");
|
||||
const versionSlot = el("div");
|
||||
const lifecycleSlot = el("div");
|
||||
|
||||
render();
|
||||
load();
|
||||
loadVersionStatus();
|
||||
loadLifecycle();
|
||||
|
||||
function render() {
|
||||
mount(
|
||||
@@ -40,9 +43,10 @@ export function settingsPage() {
|
||||
el("h1.page-title", "Configuration"),
|
||||
el("p.page-sub", "What archied is actually running with right now."),
|
||||
),
|
||||
el("div.page-actions", el("button.btn", { onclick: () => { load(); loadVersionStatus(); } }, "Refresh")),
|
||||
el("div.page-actions", el("button.btn", { onclick: () => { load(); loadVersionStatus(); loadLifecycle(); } }, "Refresh")),
|
||||
),
|
||||
versionSlot,
|
||||
lifecycleSlot,
|
||||
body,
|
||||
);
|
||||
}
|
||||
@@ -72,6 +76,24 @@ export function settingsPage() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadLifecycle() {
|
||||
try {
|
||||
const data = await api.taskMeta();
|
||||
mount(lifecycleSlot, lifecycleCard(data));
|
||||
} catch (err) {
|
||||
// The lifecycle vocabulary is optional metadata; if archied does not
|
||||
// answer, show a quiet placeholder rather than a loud failure.
|
||||
mount(
|
||||
lifecycleSlot,
|
||||
section(
|
||||
"Work lifecycle",
|
||||
"The task statuses and operator actions archied ships.",
|
||||
empty("Lifecycle unavailable", String(err.message || err)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function renderBody(cfg, reload) {
|
||||
if (!cfg || Object.keys(cfg).length === 0) {
|
||||
mount(
|
||||
@@ -127,6 +149,54 @@ function section(title, sub, ...children) {
|
||||
);
|
||||
}
|
||||
|
||||
// Work lifecycle: the vocabulary archied ships as a server catalog. Both the
|
||||
// statuses (label + pill severity) and the operator actions (label + button
|
||||
// variant) are rendered from the /api/task-meta payload, so a status or action
|
||||
// added on the backend appears here on the next load with no frontend change.
|
||||
// statusLabel/statusKind are used as fallbacks for an entry that arrives
|
||||
// without its own label/kind so the card degrades gracefully.
|
||||
function lifecycleCard(data) {
|
||||
const statuses = data?.statuses || [];
|
||||
const actions = data?.actions || [];
|
||||
|
||||
const statusList = statuses.length
|
||||
? el("div.kv-list", ...statuses.map((s) => statusLifecycleRow(s)))
|
||||
: empty("No statuses reported", "The server did not return any lifecycle statuses.");
|
||||
|
||||
const actionList = actions.length
|
||||
? el("div.kv-list", ...actions.map((a) => actionLifecycleRow(a)))
|
||||
: empty("No actions reported", "The server did not return any operator actions.");
|
||||
|
||||
return section(
|
||||
"Work lifecycle",
|
||||
"The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.",
|
||||
el("h3.cfg-subhead", "Statuses"),
|
||||
statusList,
|
||||
el("h3.cfg-subhead", "Actions"),
|
||||
actionList,
|
||||
);
|
||||
}
|
||||
|
||||
function statusLifecycleRow(s) {
|
||||
const label = s.label ?? statusLabel(s.id);
|
||||
const kind = s.kind ?? statusKind(s.id);
|
||||
return el("div.kv", el("span.kv-label", s.id), el("span.kv-value", pill(label, kind)));
|
||||
}
|
||||
|
||||
function actionLifecycleRow(a) {
|
||||
const label = a.label ?? a.id;
|
||||
const cls = roleButtonClass(a.kind);
|
||||
const spec = cls ? `button.btn.btn-small.${cls}` : "button.btn.btn-small";
|
||||
return el("div.kv", el("span.kv-label", a.id), el("span.kv-value", el(spec, { type: "button", disabled: true }, label)));
|
||||
}
|
||||
|
||||
// The button variant token for an action kind, matching the tasks board's
|
||||
// mapping: quiet/danger get their own tokens, everything else (primary, link)
|
||||
// falls back to the default .btn styling. A new kind never needs a new case.
|
||||
function roleButtonClass(kind) {
|
||||
return kind === "quiet" ? "btn-quiet" : kind === "danger" ? "btn-danger" : "";
|
||||
}
|
||||
|
||||
function identityCard(identity, ctx) {
|
||||
if (!identity) return section("Identity", "Who Archie is on the forge.", empty("Not available"));
|
||||
return section(
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
const ATTENTION_STATUSES = new Set(["waiting_human", "parked"]);
|
||||
const TASK_STATUSES = new Set([
|
||||
"needs_you",
|
||||
"queued",
|
||||
"running",
|
||||
"waiting_human",
|
||||
"pr_open",
|
||||
"merged",
|
||||
"parked",
|
||||
"dead",
|
||||
"rejected",
|
||||
"closed_wont_do",
|
||||
]);
|
||||
import { attentionStatusIds, statusIds } from "../base/task-meta.js";
|
||||
|
||||
// The vocabulary is the server catalog, not a hand-synced copy: the "needs
|
||||
// you" grouping and the set of known statuses come straight from task-meta so
|
||||
// a status added on the backend shows up here without a frontend change.
|
||||
// "needs_you" is a UI pseudo-status (work waiting on a human), so it is
|
||||
// prepended rather than stored in the catalog.
|
||||
const ATTENTION_STATUSES = attentionStatusIds();
|
||||
const TASK_STATUSES = new Set(["needs_you", ...statusIds()]);
|
||||
|
||||
export function initialTaskFilter(params) {
|
||||
const requested = params?.get?.("status") || "";
|
||||
|
||||
+27
-72
@@ -1,30 +1,11 @@
|
||||
import "./tasks.css";
|
||||
import { api } from "../base/api.js";
|
||||
import { ago, el, empty, mount, pill, statusKind } from "../base/dom.js";
|
||||
import { ago, el, empty, mount, pill } from "../base/dom.js";
|
||||
import { statTile } from "../base/statTile.js";
|
||||
import { taskRowA11y } from "./task-row.js";
|
||||
import { initialTaskFilter, taskMatchesStatus } from "./task-filters.js";
|
||||
import { describeTimelineEvent } from "./timeline-event.js";
|
||||
|
||||
/**
|
||||
* Plain-language status labels. One place, so "waiting_human" only ever
|
||||
* reads as "Waiting for you" wherever a task list is shown.
|
||||
*/
|
||||
const STATUS_LABELS = {
|
||||
queued: "Queued",
|
||||
running: "Working",
|
||||
waiting_human: "Waiting for you",
|
||||
pr_open: "In review",
|
||||
merged: "Merged",
|
||||
parked: "Parked",
|
||||
dead: "Stopped (too many retries)",
|
||||
rejected: "Rejected",
|
||||
closed_wont_do: "Won't do",
|
||||
};
|
||||
|
||||
function statusLabel(status) {
|
||||
return STATUS_LABELS[status] || status || "Unknown";
|
||||
}
|
||||
import { actionFor, statusIds, statusKind, statusLabel } from "../base/task-meta.js";
|
||||
|
||||
/**
|
||||
* The work board: every task archied knows about, filterable by status and
|
||||
@@ -67,8 +48,8 @@ export function tasksPage(params = new URLSearchParams()) {
|
||||
},
|
||||
el("option", { value: "" }, "All statuses"),
|
||||
el("option", { value: "needs_you", selected: filterStatus === "needs_you" }, "Needs you"),
|
||||
...Object.entries(STATUS_LABELS).map(([value, label]) =>
|
||||
el("option", { value, selected: filterStatus === value }, label)),
|
||||
...statusIds().map((value) =>
|
||||
el("option", { value, selected: filterStatus === value }, statusLabel(value))),
|
||||
);
|
||||
|
||||
render();
|
||||
@@ -288,55 +269,29 @@ export function tasksPage(params = new URLSearchParams()) {
|
||||
label,
|
||||
);
|
||||
|
||||
const controls = (t.actions || []).map((action) => {
|
||||
switch (action) {
|
||||
case "cancel":
|
||||
return button(
|
||||
"button.btn.btn-small.btn-quiet",
|
||||
action,
|
||||
"Cancel",
|
||||
`Cancel "${t.title || "this task"}"? This closes the forge issue.`,
|
||||
);
|
||||
case "stop":
|
||||
return button(
|
||||
"button.btn.btn-small",
|
||||
action,
|
||||
"Stop",
|
||||
`Stop "${t.title || "this task"}"? Recoverable work will remain parked.`,
|
||||
);
|
||||
case "approve":
|
||||
return button("button.btn.btn-small", action, "Approve");
|
||||
case "reject":
|
||||
return button(
|
||||
"button.btn.btn-small.btn-quiet",
|
||||
action,
|
||||
"Reject",
|
||||
`Reject "${t.title || "this task"}"? This closes the forge issue.`,
|
||||
);
|
||||
case "retry":
|
||||
return button("button.btn.btn-small", action, "Retry");
|
||||
case "abandon":
|
||||
return button(
|
||||
"button.btn.btn-small.btn-quiet",
|
||||
action,
|
||||
"Abandon",
|
||||
`Abandon "${t.title || "this task"}"? This closes the forge issue.`,
|
||||
);
|
||||
case "archive":
|
||||
return button(
|
||||
"button.btn.btn-small.btn-quiet",
|
||||
action,
|
||||
"Archive",
|
||||
`Archive the local record for "${t.title || "this task"}"?`,
|
||||
);
|
||||
case "open_pr":
|
||||
return taskLink(t, "pull_request", t.pr_number, "Open PR");
|
||||
case "open_issue":
|
||||
return taskLink(t, "issue", t.issue_number, "Open issue");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
});
|
||||
// Everything is derived from the server catalog: an action added on the
|
||||
// backend renders here the moment task-meta ships it, no frontend redeploy
|
||||
// needed. label, variant and confirm text all come from actionFor(action);
|
||||
// a new variant kind just needs a token below, not a new case.
|
||||
const variantToken = (kind) =>
|
||||
kind === "quiet" ? "btn-quiet" : kind === "danger" ? "btn-danger" : "";
|
||||
|
||||
const controls = (t.actions || [])
|
||||
.map((action) => {
|
||||
const meta = actionFor(action);
|
||||
if (!meta) return null; // unknown id -> render nothing for this entry
|
||||
const title = t.title || "this task";
|
||||
const confirmText = meta.confirm ? meta.confirm.replaceAll("{title}", title) : undefined;
|
||||
const cls = ["button", "btn", "btn-small", variantToken(meta.kind)].filter(Boolean).join(".");
|
||||
if (meta.kind === "link") {
|
||||
// Only the forge links have a destination to navigate to; the label
|
||||
// comes from the catalog rather than a hardcoded "Open PR".
|
||||
if (action === "open_pr") return taskLink(t, "pull_request", t.pr_number, meta.label);
|
||||
if (action === "open_issue") return taskLink(t, "issue", t.issue_number, meta.label);
|
||||
}
|
||||
return button(cls, action, meta.label, confirmText);
|
||||
})
|
||||
.filter(Boolean);
|
||||
if (!controls.length && !error) return "—";
|
||||
return el("div.task-actions", error, controls);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { register } from "node:module";
|
||||
import "./shim.js";
|
||||
|
||||
// settings.js imports ./settings.css, which Node's ESM loader cannot parse.
|
||||
// Install a runtime loader hook (inline via a data: URL, as tasks-actions.test.js
|
||||
// does for tasks.css) that stubs .css imports to an empty module, then load
|
||||
// settings.js so the page can be driven under plain node --test.
|
||||
const cssLoad = "data:text/javascript," + encodeURIComponent(`
|
||||
export async function load(url, context, nextLoad) {
|
||||
if (url.endsWith(".css")) {
|
||||
return { format: "module", shortCircuit: true, source: "export default {};" };
|
||||
}
|
||||
return nextLoad(url, context);
|
||||
}
|
||||
`);
|
||||
register(cssLoad, import.meta.url);
|
||||
|
||||
const { api } = await import("../src/base/api.js");
|
||||
const { settingsPage } = await import("../src/settings/settings.js");
|
||||
|
||||
// renderSettings builds the settings page with config/version/taskMeta stubbed
|
||||
// to canned payloads, then returns the root once the background loads settle.
|
||||
// The stubs are restored in a finally so they never leak.
|
||||
async function renderSettings(meta) {
|
||||
const original = { config: api.config, version: api.version, taskMeta: api.taskMeta };
|
||||
api.config = async () => ({});
|
||||
api.version = async () => ({ components: [] });
|
||||
api.taskMeta = async () => meta;
|
||||
try {
|
||||
const root = settingsPage();
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
return root;
|
||||
} finally {
|
||||
api.config = original.config;
|
||||
api.version = original.version;
|
||||
api.taskMeta = original.taskMeta;
|
||||
}
|
||||
}
|
||||
|
||||
test("work lifecycle card renders a status pill and an action button from /api/task-meta", async () => {
|
||||
const root = await renderSettings({
|
||||
statuses: [
|
||||
{ id: "waiting_human", label: "Waiting for you", kind: "warn", needs_you: true },
|
||||
{ id: "queued", label: "Queued", kind: "idle" },
|
||||
],
|
||||
actions: [
|
||||
{ id: "cancel", label: "Cancel", kind: "quiet" },
|
||||
{ id: "approve", label: "Approve", kind: "primary" },
|
||||
],
|
||||
});
|
||||
|
||||
const text = root.textContent;
|
||||
assert.ok(text.includes("Work lifecycle"), "the lifecycle card should be present");
|
||||
|
||||
// Statuses render as pills carrying their severity token.
|
||||
const warnPill = root.querySelector(".pill-warn");
|
||||
assert.ok(warnPill, "a warn-kind status should render a warn pill");
|
||||
assert.equal(warnPill.textContent, "Waiting for you");
|
||||
assert.ok(text.includes("Queued"), "a second status should render its label");
|
||||
|
||||
// Actions render as buttons carrying their variant token.
|
||||
const cancelBtn = root.querySelector(".btn-quiet");
|
||||
assert.ok(cancelBtn, "a quiet action should render a quiet-variant button");
|
||||
assert.equal(cancelBtn.textContent, "Cancel");
|
||||
assert.ok(text.includes("Approve"), "a primary action should render its label");
|
||||
});
|
||||
|
||||
test("work lifecycle card shows a quiet empty state when the catalog fetch fails", async () => {
|
||||
const original = { config: api.config, version: api.version, taskMeta: api.taskMeta };
|
||||
api.config = async () => ({});
|
||||
api.version = async () => ({ components: [] });
|
||||
api.taskMeta = async () => {
|
||||
throw new Error("boom");
|
||||
};
|
||||
try {
|
||||
const root = settingsPage();
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
assert.ok(root.textContent.includes("Work lifecycle"), "the card should still render");
|
||||
assert.ok(root.textContent.includes("Lifecycle unavailable"), "a failure should show the empty/error state");
|
||||
} finally {
|
||||
api.config = original.config;
|
||||
api.version = original.version;
|
||||
api.taskMeta = original.taskMeta;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import "./shim.js";
|
||||
import { initialTaskFilter, taskMatchesStatus } from "../src/tasks/task-filters.js";
|
||||
import { attentionStatusIds, statusIds } from "../src/base/task-meta.js";
|
||||
|
||||
test("the needs_you filter group matches exactly the catalog's attention statuses", () => {
|
||||
const attention = attentionStatusIds();
|
||||
// Every status the catalog marks as needing a human matches "needs_you".
|
||||
for (const id of attention) {
|
||||
assert.equal(taskMatchesStatus({ status: id }, "needs_you"), true, `${id} should match needs_you`);
|
||||
}
|
||||
// No non-attention catalog status does.
|
||||
for (const id of statusIds()) {
|
||||
if (!attention.has(id)) {
|
||||
assert.equal(taskMatchesStatus({ status: id }, "needs_you"), false, `${id} should not match needs_you`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("initialTaskFilter accepts needs_you and every catalog status, and drops unknowns", () => {
|
||||
assert.equal(initialTaskFilter(new URLSearchParams("status=needs_you")), "needs_you");
|
||||
// TASK_STATUSES is derived from the catalog, so every statusId is accepted.
|
||||
for (const id of statusIds()) {
|
||||
assert.equal(initialTaskFilter(new URLSearchParams(`status=${id}`)), id, `${id} should be accepted`);
|
||||
}
|
||||
assert.equal(initialTaskFilter(new URLSearchParams("status=quantum_superposition")), "");
|
||||
assert.equal(initialTaskFilter(new URLSearchParams("status=")), "");
|
||||
});
|
||||
|
||||
test("taskMatchesStatus matches a specific catalog status exactly", () => {
|
||||
assert.equal(taskMatchesStatus({ status: "running" }, "running"), true);
|
||||
assert.equal(taskMatchesStatus({ status: "running" }, "queued"), false);
|
||||
assert.equal(taskMatchesStatus({ status: "running" }, ""), true);
|
||||
});
|
||||
@@ -0,0 +1,86 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { register } from "node:module";
|
||||
import "./shim.js";
|
||||
|
||||
// tasks.js imports "./tasks.css", which Node's ESM loader cannot parse. Install
|
||||
// a runtime loader hook (inline, via a data: URL so nothing extra is written to
|
||||
// disk) that stubs .css imports to an empty module, then load tasks.js.
|
||||
const cssLoad = "data:text/javascript," + encodeURIComponent(`
|
||||
export async function load(url, context, nextLoad) {
|
||||
if (url.endsWith(".css")) {
|
||||
return { format: "module", shortCircuit: true, source: "export default {};" };
|
||||
}
|
||||
return nextLoad(url, context);
|
||||
}
|
||||
`);
|
||||
register(cssLoad, import.meta.url);
|
||||
|
||||
const { api } = await import("../src/base/api.js");
|
||||
const { tasksPage } = await import("../src/tasks/tasks.js");
|
||||
|
||||
// renderTask builds a page with a single task by stubbing api.tasks to a fake
|
||||
// task, then returns the rendered root once tasksPage's background load() has
|
||||
// settled. api.tasks is restored in a finally so the stub never leaks.
|
||||
async function renderTask(task) {
|
||||
const original = api.tasks;
|
||||
api.tasks = async () => [task];
|
||||
try {
|
||||
const root = tasksPage(new URLSearchParams());
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
return root;
|
||||
} finally {
|
||||
api.tasks = original;
|
||||
}
|
||||
}
|
||||
|
||||
test("an action present in the catalog renders a button, not null", async () => {
|
||||
const task = {
|
||||
id: 7,
|
||||
title: "Fix the flaky test",
|
||||
status: "waiting_human",
|
||||
repo: "sam/archie",
|
||||
workflow: "tdd",
|
||||
actions: ["cancel"],
|
||||
};
|
||||
const root = await renderTask(task);
|
||||
const container = root.querySelector(".task-actions");
|
||||
assert.ok(container, "a known action should render a .task-actions container");
|
||||
const btn = container.querySelector("button");
|
||||
assert.ok(btn, "a button should be rendered for a catalog action");
|
||||
assert.ok(btn.className.includes("btn-quiet"), "cancel maps to the quiet variant");
|
||||
assert.equal(btn.textContent, "Cancel");
|
||||
});
|
||||
|
||||
test("an id NOT in the catalog renders nothing", async () => {
|
||||
const task = {
|
||||
id: 8,
|
||||
title: "Poltergeist task",
|
||||
status: "waiting_human",
|
||||
repo: "sam/archie",
|
||||
workflow: "boot",
|
||||
actions: ["teleport"],
|
||||
};
|
||||
const root = await renderTask(task);
|
||||
// Unknown id -> no control renders, so no .task-actions container appears.
|
||||
assert.equal(root.querySelector(".task-actions"), null, "unknown action renders nothing");
|
||||
});
|
||||
|
||||
test("a link-kind action renders an anchor to the forge", async () => {
|
||||
const task = {
|
||||
id: 9,
|
||||
title: "Open the PR",
|
||||
status: "pr_open",
|
||||
repo: "sam/archie",
|
||||
workflow: "tdd",
|
||||
issue_number: 12,
|
||||
pr_number: 42,
|
||||
pr_url: "https://forge.example.internal/sam/archie/pull/42",
|
||||
actions: ["open_pr"],
|
||||
};
|
||||
const root = await renderTask(task);
|
||||
const link = root.querySelector(".task-actions")?.querySelector("a");
|
||||
assert.ok(link, "open_pr should render an <a> not a <button>");
|
||||
assert.equal(link.textContent, "Open PR");
|
||||
assert.equal(link.getAttribute("href"), "https://forge.example.internal/sam/archie/pull/42");
|
||||
});
|
||||
Reference in new issue
Block a user