fix(webui): make chat a FAB-opened panel and stop the topbar clipping

Four P0 defects from the frontend audit, plus the one-line theme fix that was
making every one of them look worse.

Chat is a floating launcher and the panel it opens, not a route
(archie-core-yuvg, archie-core-hesx). /chat rendered an empty page with a
drawer over it, and that drawer hosted the full-page chat workspace: a page
title, a conversations column, a four-control action row and a command-help
column, all inside 440px. Measured at 1440x900, .chat-workspace was 174px wide
holding 270px of content and the composer ran off the viewport.

  - The Chat nav entry, the /chat route and the topbar chat icon are gone;
    the launcher is the single way in.
  - The panel anchors to the launcher and opens leftward from it, sharing its
    bottom edge, so the button never moves. No scrim and no scroll lock: the
    page stays readable and clickable, which is the point of asking Archie
    about the page you are on.
  - Conversations became a switcher in a compact bar; personality, provider
    and model moved into a disclosure beside it; the empty state and composer
    dropped to panel type scale.
  - The launcher renders outside .shell because .shell's backdrop-filter is a
    containing block for fixed positioning, which otherwise pinned the button
    to the scrolling shell instead of the viewport.
  - Update-check, Dangerous actions and Reload Telegram left the panel; their
    api.* calls are untouched for the rehome to Configuration
    (archie-core-tf20).

The topbar no longer clips its utility cluster (archie-core-mkb3). brand, nav
and topbar-end were all flex:none with no wrap above 1220px, and .app sets
overflow:hidden, so between 1221px and ~1582px the avatar, theme toggle and
documentation button were cut off with no way to reach them. The nav is now
the one region allowed to shrink, the search collapses to its icon below
1500px, and the nav wraps to its own row below 1270px where it stops fitting.

Live activity clamps its detail column (archie-core-qo7f). An agent_finish
payload rendered raw turned one row into six viewports and the dashboard into
7,481px. The cell shows the first meaningful line; the full text stays on the
title.

color-scheme is bound to the active theme (archie-core-nm0y), so scrollbars
and native controls stop rendering light inside the dark UI.
This commit is contained in:
sam committed 2026-09-20 16:00:29 +10:00
1 parent 1fc3d67c15
commit 30a9be4dc5
15 files changed
+729 -465

No files matched your search

-1
View File
@@ -28,7 +28,6 @@ type DashboardPage struct {
// never points at a page it was not told about.
var dashboardPages = []DashboardPage{
{Path: "/", Label: "Dashboard", Description: "The control room: what Archie is working on, what needs you, and token spend."},
{Path: "/chat", Label: "Chat", Description: "Conversations with Archie and the web chat session tools."},
{Path: "/tasks", Label: "Tasks", Description: "Issues Archie has picked up and where they stand: the work queue."},
{Path: "/logs", Label: "Logs", Description: "The daemon log stream, filterable by level and component."},
{Path: "/captures", Label: "Event inspector", Description: "Captured inbound events for inspection."},
+1 -1
View File
@@ -1 +1 @@
:root{--font-sans:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;--font-mono:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;--text-xs:.6875rem;--text-sm:.8125rem;--text-base:.875rem;--text-lg:1.0625rem;--text-xl:1.375rem;--text-2xl:1.875rem;--text-3xl:2.5rem;--sp-1:.25rem;--sp-2:.5rem;--sp-3:.75rem;--sp-4:1rem;--sp-5:1.5rem;--sp-6:2rem;--sp-7:3rem;--radius-sm:6px;--radius-md:10px;--radius-lg:14px;--radius-xl:20px;--radius-pill:999px;--transition:.14s cubic-bezier(.4, 0, .2, 1)}[data-theme=dark]{--bg:#0d1014;--bg-raised:#141920;--surface:#171d25;--surface-hover:#1d242e;--border:#232b36;--border-strong:#303a48;--fg:#e8edf4;--fg-muted:#8b97a8;--fg-subtle:#5d6878;--accent:#4c8dff;--accent-fg:#fff;--accent-soft:#4c8dff24;--ok:#3fbf7f;--ok-soft:#3fbf7f24;--warn:#e8a33d;--warn-soft:#e8a33d24;--danger:#f0616d;--danger-soft:#f0616d24;--info:#4c8dff;--info-soft:#4c8dff24;--idle:#6b7688;--idle-soft:#6b768824;--accent-2:#7b5cff;--bg-blur:#1419208c;--surface-glass:#171d259e;--surface-glass-strong:#141920c7;--workspace:#11151b8c;--hairline:#ffffff0f;--wash-a:#4c8dff1a;--wash-b:#7b5cff1f;--wash-c:#3fbf7f0f;--shadow-workspace:0 24px 70px #00000080;--shadow-sm:0 1px 2px #0006;--shadow-md:0 8px 28px #0000006b}[data-theme=light]{--bg:#f6f8fb;--bg-raised:#fff;--surface:#fff;--surface-hover:#f1f4f9;--border:#e2e8f0;--border-strong:#cbd5e1;--fg:#16202e;--fg-muted:#5a6779;--fg-subtle:#8c99ab;--accent:#2563eb;--accent-fg:#fff;--accent-soft:#2563eb1a;--ok:#10935c;--ok-soft:#10935c1f;--warn:#b87514;--warn-soft:#b875141f;--danger:#d4344a;--danger-soft:#d4344a1f;--info:#2563eb;--info-soft:#2563eb1a;--idle:#64748b;--idle-soft:#64748b1f;--accent-2:#7c3aed;--bg-blur:#fff9;--surface-glass:#ffffffb8;--surface-glass-strong:#ffffffe0;--workspace:#ffffff8c;--hairline:#0f172a0f;--wash-a:#2563eb1a;--wash-b:#7c3aed1f;--wash-c:#10935c12;--shadow-workspace:0 24px 70px #0f172a24;--shadow-sm:0 1px 2px #0f172a0f;--shadow-md:0 8px 28px #0f172a1a}*,:before,:after{box-sizing:border-box}html,body{height:100%;margin:0}body{color:var(--fg);font-family:var(--font-sans);font-size:var(--text-base);-webkit-font-smoothing:antialiased;line-height:1.5}a{color:inherit;text-decoration:none}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.visually-hidden{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}body{background:radial-gradient(70rem 40rem at 8% -10%, var(--wash-a), transparent 62%), radial-gradient(56rem 34rem at 92% 4%, var(--wash-b), transparent 58%), radial-gradient(48rem 30rem at 50% 108%, var(--wash-c), transparent 60%), var(--bg);padding:var(--sp-4);background-attachment:fixed}.shell{min-height:calc(100vh - var(--sp-4) * 2);border-radius:var(--radius-xl);border:1px solid var(--hairline);background:var(--workspace);-webkit-backdrop-filter:blur(28px)saturate(120%);backdrop-filter:blur(28px)saturate(120%);box-shadow:var(--shadow-workspace);flex-direction:column;display:flex;overflow:hidden}.topbar{align-items:center;gap:var(--sp-4);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--hairline);background:var(--bg-blur);z-index:10;display:flex;position:sticky;top:0}.brand{align-items:center;gap:var(--sp-2);font-weight:600;font-size:var(--text-sm);letter-spacing:-.01em;flex:none;display:flex}.brand-mark{background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;width:26px;height:26px;font-size:var(--text-xs);border-radius:8px;place-items:center;font-weight:700;display:grid}.nav{border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);align-items:center;gap:2px;margin:0 auto;padding:3px;display:flex}.nav-item{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);color:var(--fg-muted);font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:background var(--transition), color var(--transition);display:inline-flex}.nav-item:hover{color:var(--fg);background:var(--surface-hover)}.nav-item[aria-current=page]{background:var(--accent);color:var(--accent-fg);font-weight:500}.nav-item .nav-label{display:inline}.topbar-end{align-items:center;gap:var(--sp-2);flex:none;display:flex}.topbar-search{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);color:var(--fg-subtle);display:flex}.topbar-search input{color:var(--fg);font:inherit;font-size:var(--text-sm);background:0 0;border:0;outline:none;width:8rem}.topbar-search input::placeholder{color:var(--fg-subtle)}.mobile-search-toggle{display:none}.icon-btn{border-radius:var(--radius-pill);border:1px solid var(--hairline);background:var(--surface-glass-strong);width:32px;height:32px;color:var(--fg-muted);cursor:pointer;transition:color var(--transition), background var(--transition);place-items:center;display:grid}.Line truncated
:root{--font-sans:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;--font-mono:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;--text-xs:.6875rem;--text-sm:.8125rem;--text-base:.875rem;--text-lg:1.0625rem;--text-xl:1.375rem;--text-2xl:1.875rem;--text-3xl:2.5rem;--sp-1:.25rem;--sp-2:.5rem;--sp-3:.75rem;--sp-4:1rem;--sp-5:1.5rem;--sp-6:2rem;--sp-7:3rem;--radius-sm:6px;--radius-md:10px;--radius-lg:14px;--radius-xl:20px;--radius-pill:999px;--transition:.14s cubic-bezier(.4, 0, .2, 1)}[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--bg:#0d1014;--bg-raised:#141920;--surface:#171d25;--surface-hover:#1d242e;--border:#232b36;--border-strong:#303a48;--fg:#e8edf4;--fg-muted:#8b97a8;--fg-subtle:#5d6878;--accent:#4c8dff;--accent-fg:#fff;--accent-soft:#4c8dff24;--ok:#3fbf7f;--ok-soft:#3fbf7f24;--warn:#e8a33d;--warn-soft:#e8a33d24;--danger:#f0616d;--danger-soft:#f0616d24;--info:#4c8dff;--info-soft:#4c8dff24;--idle:#6b7688;--idle-soft:#6b768824;--accent-2:#7b5cff;--bg-blur:#1419208c;--surface-glass:#171d259e;--surface-glass-strong:#141920c7;--workspace:#11151b8c;--hairline:#ffffff0f;--wash-a:#4c8dff1a;--wash-b:#7b5cff1f;--wash-c:#3fbf7f0f;--shadow-workspace:0 24px 70px #00000080;--shadow-sm:0 1px 2px #0006;--shadow-md:0 8px 28px #0000006b}[data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--bg:#f6f8fb;--bg-raised:#fff;--surface:#fff;--surface-hover:#f1f4f9;--border:#e2e8f0;--border-strong:#cbd5e1;--fg:#16202e;--fg-muted:#5a6779;--fg-subtle:#8c99ab;--accent:#2563eb;--accent-fg:#fff;--accent-soft:#2563eb1a;--ok:#10935c;--ok-soft:#10935c1f;--warn:#b87514;--warn-soft:#b875141f;--danger:#d4344a;--danger-soft:#d4344a1f;--info:#2563eb;--info-soft:#2563eb1a;--idle:#64748b;--idle-soft:#64748b1f;--accent-2:#7c3aed;--bg-blur:#fff9;--surface-glass:#ffffffb8;--surface-glass-strong:#ffffffe0;--workspace:#ffffff8c;--hairline:#0f172a0f;--wash-a:#2563eb1a;--wash-b:#7c3aed1f;--wash-c:#10935c12;--shadow-workspace:0 24px 70px #0f172a24;--shadow-sm:0 1px 2px #0f172a0f;--shadow-md:0 8px 28px #0f172a1a}*,:before,:after{box-sizing:border-box}html,body{height:100%;margin:0}body{color:var(--fg);font-family:var(--font-sans);font-size:var(--text-base);-webkit-font-smoothing:antialiased;line-height:1.5}a{color:inherit;text-decoration:none}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.visually-hidden,.sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}body{background:radial-gradient(70rem 40rem at 8% -10%, var(--wash-a), transparent 62%), radial-gradient(56rem 34rem at 92% 4%, var(--wash-b), transparent 58%), radial-gradient(48rem 30rem at 50% 108%, var(--wash-c), transparent 60%), var(--bg);padding:var(--sp-4);background-attachment:fixed}.shell{min-height:calc(100vh - var(--sp-4) * 2);border-radius:var(--radius-xl);border:1px solid var(--hairline);background:var(--workspace);-webkit-backdrop-filter:blur(28px)saturate(120%);backdrop-filter:blur(28px)saturate(120%);box-shadow:var(--shadow-workspace);flex-direction:column;display:flex;overflow:hidden}.topbar{align-items:center;gap:var(--sp-4);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--hairline);background:var(--bg-blur);z-index:10;display:flex;position:sticky;top:0}.brand{align-items:center;gap:var(--sp-2);font-weight:600;font-size:var(--text-sm);letter-spacing:-.01em;flex:none;display:flex}.brand-mark{background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;width:26px;height:26px;font-size:var(--text-xs);border-radius:8px;place-items:center;font-weight:700;display:grid}.nav{scrollbar-width:none;border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);flex:0 auto;align-items:center;gap:2px;min-width:0;margin:0 auto;padding:3px;display:flex;overflow-x:auto}.nav::-webkit-scrollbar{display:none}.nav-item{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);color:var(--fg-muted);font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:background var(--transition), color var(--transition);flex:none;display:inline-flex}.nav-item:hover{color:var(--fg);background:var(--surface-hover)}.nav-item[aria-current=page]{background:var(--accent);color:var(--accent-fg);font-weight:500}.nav-item .nav-label{display:inline}.topbar-end{align-items:center;gap:var(--sp-2);flex:none;display:flex}.topbar-search{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);color:var(--fg-subtle);display:flex}.topbar-search input{color:var(--fg);font:inherit;font-size:var(--text-sm);background:0 0;border:0;outline:none;width:8rem}.topbar-search input::placeholder{color:var(--fg-subtle)}.mobile-search-toggle{display:none}.icon-btn{border-Line truncated
+8 -7
View File
@@ -1,9 +1,10 @@
(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)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?w(e):null}function T(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,i=[],a=[],o=v({},n);o.__v=n.__v+1,t.vnode&&t.vnode(o),I(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??w(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,ee(i,o,a),n.__e=n.__=null,o.__e!=r&&E(o)}}function E(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),E(e)}function D(e){(!e.__d&&(e.__d=!0)&&r.push(e)&&!O.__r++||i!=t.debounceRendering)&&((i=t.debounceRendering)||a)(O)}function O(){try{for(var e,t=1;r.length;)r.length>t&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=O.__r=0}}function k(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y=r&&r.__k||h,b=t.length;for(c=A(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||m,p.__i=d,v=I(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&te(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),4&p.__u?(c=j(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function A(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=M(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),B(s,s));return r}function j(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=j(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=w(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function M(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function N(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function P(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||N(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||N(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function F(e){return function(n){if(this.l){var r=thiLine truncated
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Oe=class extends Error{constructor(e,t){super(e),this.status=t}};function ke(e){let t=e instanceof Oe?e.status:void 0,n=e?.message||`Action failed`;return t===401?{kind:`session-expired`,message:n}:t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Ae(e,t){let n=await fetch(e,t);if(!n.ok)throw new Oe(await De(n),n.status);return n}async function J(e,{method:t=`GET`,body:n,timeoutMs:r=Te,parse:i=!0}={}){let a={Accept:`application/json`},o={method:t,headers:a,signal:AbortSignal.timeout(r)};t!==`GET`&&(a[`Content-Type`]=`application/json`,a[`X-Archie-CSRF`]=`1`),n!==void 0&&(o.body=JSON.stringify(n));let s=await Ae(e,o);return i?s.json():void 0}var Y={summary:()=>J(`/api/summary`),tasks:()=>J(`/api/tasks`),taskMeta:()=>J(`/api/task-meta`),task:e=>J(`/api/tasks/${e}`),taskAttempts:e=>J(`/api/tasks/${e}/attempts`),taskChanges:(e,t)=>J(`/api/tasks/${e}/changes`+Ee(t)),taskDebug:(e,t)=>J(`/api/tasks/${e}/debug`+Ee(t)),taskAction:(e,t)=>J(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>J(`/api/setup`),capabilities:()=>J(`/api/capabilities`),workflows:()=>J(`/api/workflows`),workRequest:e=>J(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>J(`/api/skills`),channels:()=>J(`/api/channels`),curators:()=>J(`/api/curators`),channelReload:e=>J(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>J(`/api/config`),version:()=>J(`/api/version`),configUpdate:e=>J(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>J(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>J(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>J(`/api/logs`+Ee(e)),taskLogs:(e,t)=>J(`/api/tasks/${e}/logs`+Ee(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>J(`/api/captures`+Ee({limit:e})),mappings:()=>J(`/api/mappings`),mappingCreate:e=>J(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>J(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>J(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>J(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>J(`/api/bindings`),bindingCreate:e=>J(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>J(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>J(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>J(`/api/bindings/${e}/approve`,{method:`POST`}),chatSessions:()=>J(`/api/chat/sessions`),chatMessages:e=>J(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>J(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>J(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>J(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:we(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>J(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>J(`/api/chat/update`),chatUpdateDefer:e=>J(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>J(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>J(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>J(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>J(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>Ae(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t})};function je(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Me(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Ne(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var Pe=[{id:`queued`,label:`Queued`,kind:`idle`},{id:`running`,label:`Working`,kind:`info`},{id:`waiting_human`,label:`Waiting for you`,kind:`warn`,needs_you:!0},{id:`pr_open`,label:`In review`,kind:`ok`},{id:`merged`,label:`Merged`,kind:`ok`},{id:`parked`,label:`Parked`,kind:`warn`,needs_you:!0},{id:`dead`,label:`Stopped (too many retries)`,kind:`danger`},{id:`rejected`,label:`Rejected`,kind:`danger`},{id:`closed_wont_do`,label:`Won't do`,kind:`idle`}],Fe=[{id:`cancel`,label:`Cancel`,kind:`quiet`,confirm:`Cancel "{title}"? This closes the forge issue.`},{id:`stop`,label:`Stop`,kind:`primary`,confirm:`Stop "{title}"? Recoverable work will remain parked.`},{id:`approve`,label:`Approve`,kind:`primary`},{id:`reject`,label:`Reject`,kind:`quiet`,confirm:`Reject "{title}"? ThiLine truncated
`),children:[X(`td`,{className:`strong`,children:e.label||e.id}),X(`td`,{className:`mono`,children:e.install_type||`—`}),X(`td`,{className:`mono`,children:e.running_version||`—`}),X(`td`,{className:`mono`,children:e.latest_available||`—`}),X(`td`,{children:X(Q,{text:Yn[e.status]||e.status,kind:Xn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function $({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function Qn({title:e,sub:t,children:n}){return X(`div`,{className:`card cfg-section`,children:[X(`div`,{className:`card-head`,children:X(`div`,{children:[X(`h2`,{className:`card-title`,children:e}),X(`p`,{className:`card-sub`,children:t})]})}),n]})}function $n({origins:e}){return e?.length?X(Qn,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:X(`div`,{className:`kv-list`,children:e.map((e,t)=>X(Gn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):X(Qn,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:X($,{title:`Source provenance is unavailable.`})})}function er(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function tr({data:e,error:t}){if(t)return X(Qn,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:X($,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return X(Qn,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,children:[X(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?X(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??He(e.id),n=e.kind??Ue(e.id);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(Q,{text:t,kind:n})})]},e.id)})}):X($,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),X(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?X(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=er(e.kind);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):X($,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function nr({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=W(!1),[o,s]=W(null),[c,l]=W(!!e[t]);return r?X(`td`,{children:[X(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:c,onChange:async r=>{let i=r.target.checked;l(i),a(!0),s(null);try{await Y.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){l(!i),s(String(e.message||e))}finally{a(!1)}},disabled:i}),o&&X(`span`,{className:`kv-note is-error`,children:o})]}):X(`td`,{children:c?`yes`:`no`})}function rr({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=W(String(e[t]??0)),[o,s]=W(null),[c,l]=W(!1);return r?X(`td`,{children:[X(`input`,{className:`kv-input`,type:`text`,value:i,onChange:e=>a(e.target.value),onBlur:async()=>{let r=parseInt(i,10);if(Number.isNaN(r)){s(`Enter a whole number`);return}l(!0),s(null);try{await Y.configRepoUpdate(e.owner,e.name,t,r),n?.()}catch(e){s(String(e.message||e))}finally{l(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:c}),o&&X(`span`,{className:`kv-note is-error`,children:o})]}):X(`td`,{className:`mono`,children:i})}function ir({repos:e,onSaved:t,editable:n=!0}){if(!e?.length)return X(Qn,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:X($,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let r=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return X(Qn,{title:`Repositories`,sub:`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, not the file config.toml directly.`,children:X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Repository`}),X(`th`,{children:`Base branch`}),X(`th`,{children:`Ecosystem`}),X(`th`,{children:`Quality gate`}),X(`th`,{children:`Protected paths`}),X(`th`,{children:`Concurrent`}),X(`th`,{children:`Max retries`}),X(`th`,{children:`Self-review`})]})}),X(`tbody`,{children:e.map((e,i)=>X(`tr`,{children:[X(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),X(`td`,{className:`mono`,children:e.base}),X(`td`,{children:e.ecosystem||`go`}),X(`td`,{className:`mono`,children:r(e.gate)}),X(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),X(nr,{r:e,field:`alloLine truncated
`),i=[],a=null,o=null,s=0,c=()=>{i.length&&(n.push(X(`p`,{children:Br(i.join(` `))},s++)),i=[])},l=()=>{if(!a)return;let e=a.items.map((e,t)=>X(`li`,{children:Br(e)},t));n.push(a.tag===`ol`?X(`ol`,{children:e},s++):X(`ul`,{children:e},s++)),a=null};for(let e=0;e<r.length;e++){let t=r[e];if(t.startsWith("```")){c(),l(),o?(n.push(X(`pre`,{children:X(`code`,{children:o.join(`
`)})},s++)),o=null):o=[];continue}if(o){o.push(t);continue}let u=Hr(t),d=e+1<r.length?Hr(r[e+1]):null;if(u&&d&&Ur(d)&&u.length===d.length){c(),l();let t=[];for(e+=2;e<r.length;e++){let n=Hr(r[e]);if(!n||n.length!==u.length){e--;break}t.push(n)}n.push(X(`table`,{children:[X(`thead`,{children:X(`tr`,{children:u.map((e,t)=>X(`th`,{children:Br(e)},t))})}),X(`tbody`,{children:t.map((e,t)=>X(`tr`,{children:e.map((e,t)=>X(`td`,{children:Br(e)},t))},t))})]},s++));continue}if(!t.trim()){c(),l();continue}let f=t.match(/^(#{1,3})\s+(.+)$/);if(f){c(),l();let e=`h${f[1].length}`;n.push(X(e,{children:Br(f[2])},s++));continue}let p=t.match(/^\s*[-*]\s+(.+)$/),m=t.match(/^\s*\d+[.)]\s+(.+)$/);if(p||m){c();let e=m?`ol`:`ul`;(!a||a.tag!==e)&&(l(),a={tag:e,items:[]}),a.items.push((p||m)[1]);continue}if(t.startsWith(`>`)){c(),l(),n.push(X(`blockquote`,{children:Br(t.replace(/^>\s?/,``))},s++));continue}i.push(t)}return c(),l(),o&&n.push(X(`pre`,{children:X(`code`,{children:o.join(`
`)})},s++)),X(`div`,{className:t,children:n})}function Hr(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 Ur(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Wr=`archie.web.chat.channel`;function Gr(){let e=localStorage.getItem(Wr);return e||(e=we(),localStorage.setItem(Wr,e)),e}function Kr(e){return{text:e,sourceID:we()}}function qr(e){return{...e}}function Jr(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?qr(e.turn):Kr(r),isRetry:n}}function Yr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function Xr(e){return e?.status===501?null:`Could not check for updates.`}function Zr(){return location.hash.slice(1)||`/`}function Qr(){let[e,t]=W([]),[n,r]=W(``),[i,a]=W([]),[o,s]=W(``),[c,l]=W(`Ready`),[u,d]=W(!1),[f,p]=W({}),[m,h]=W(``),[g,_]=W(``),[v,y]=W(``),[b,x]=W([]),[C,w]=W([]),[T,E]=W(0),[D,O]=W(!1),[k,A]=W(null),[j,M]=W(null),[N,P]=W(null),[F,I]=W(``),[L,ee]=W(``),[R,z]=W(null),te=K(null),B=K(null),V=K(null),ne=K(null),re=K(null),H=K(u);H.current=u,G(()=>{te.current&&(te.current.scrollTop=te.current.scrollHeight)},[i,R]),G(()=>{le().catch(e=>{l(e.message||`Chat unavailable`)}),ie();let e=()=>{V.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),V.current?.abort()}},[]);async function ie(){try{let e=await Y.chatUpdate();M(e?.snapshot||null),A(e)}catch(e){let t=Xr(e);A(t?{error:t}:null)}}async function ae(){if(j)try{await Y.chatUpdateDefer(j),A({snapshot:{deferred:!0},available:[]}),l(`Update deferred`)}catch(e){l(e.message||`Could not defer update`)}}async function oe(){if(j)try{l(`Installing…`);let e=await Y.chatUpdateInstall(j);M(null),A({snapshot:{},available:[]}),l(e?.result?.restart_requested?`Update installed; restart queued`:`Update complete`)}catch(e){l(e.message||`Update install failed`)}}async function se(){try{let e=await Y.chatDangerous();P(e)}catch(e){P({error:e.message||`Dangerous actions unavailable`})}}async function U(e,t){if(t)try{await Y.chatDangerousRequest(e,t),l(`Approval requested`),await se()}catch(e){l(e.message||`Could not request action`)}}async function ce(e,t){try{await Y.chatDangerousDecision(e,t),l(t===`deny`?`Action denied`:`Action approved`),await se()}catch(e){l(e.message||`Approval failed`)}}async function le(){let e=await Y.chatSessions(),r=e.sessions||[];t(r),p(e),h(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;_(a),y(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);x(o),e.dangerous_available&&await se(),!n&&r[0]&&await ue(r[0].session_id,e,r)}async function ue(e,t,n){let i=t||f;r(e),a([]),z(null);let o=i.active_personas?.[e]||i.active_persona||``;h(o);try{await Y.chatMessage(Gr(),`/resume ${e}`);let[t,n]=await Promise.all([Y.chatMessages(e),Y.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});a(i)}catch(e){l(e.message||`Could not load session messages`)}}async function de(e){if(n)try{l(`Working…`);let t=await Y.chatMessage(Gr(),e);t.session_id&&r(t.session_id),l(t.reply||`Session updated`),await le(),(t.session_id||n)&&await ue(t.session_id||n),ne.current&&(ne.current.open=!1)}catch(e){l(e.message||`Session action failed`)}}function fe(e,t){let n=window.prompt(t);n?.trim()&&de(`${e} ${n.trim()}`)}function pe(e){let t=e.target.value;h(t),!(!n||!t)&&Y.chatPersona(n,t).then(()=>{p(e=>({...e,active_personas:{...e.active_personas||{},[n]:t}})),l(`Personality: ${t}`)}).catch(e=>{l(e.message||`Failed to set personality`)})}async function me(e){let t=e.target.value;if(_(t),t)try{let e=await Y.chatMessage(Gr(),`/model --provider ${t}`);l(e.reply||`Provider updated`),await le()}catch(e){l(`Provider update failed: ${e.message||e}`)}}async function he(e){let t=e.target.value;if(y(t),t)try{let e=await Y.chatMessage(Gr(),`/model ${t}`);l(e.reply||`Model updated`),await le()}catch(e){l(`Model update failed: ${e.message||e}`)}}function ge(){window.confirm(`Reload the Telegram chat adapter?`)&&(s(`/restart`),q({textOverride:`/restart`}))}function _e(){s(`/new`),q({textOverride:`/new`})}function ve(e){let t=e.target.value;s(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=b.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){w(t),E(0),O(!0);return}}O(!1),w([])}function ye(e){let t=C[e];if(!t||!B.current)return;let n=B.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.search(/(?:^|\s)\/[^\s]*$/),o=a<0?r.length:a+ +(r[a]===` `),c=`${r.slice(0,o)}${t.command} ${i}`;s(c),O(!1);let l=o+t Line truncated
(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)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?w(e):null}function T(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,i=[],a=[],o=v({},n);o.__v=n.__v+1,t.vnode&&t.vnode(o),I(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??w(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,R(i,o,a),n.__e=n.__=null,o.__e!=r&&E(o)}}function E(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),E(e)}function D(e){(!e.__d&&(e.__d=!0)&&r.push(e)&&!O.__r++||i!=t.debounceRendering)&&((i=t.debounceRendering)||a)(O)}function O(){try{for(var e,t=1;r.length;)r.length>t&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=O.__r=0}}function k(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y=r&&r.__k||h,b=t.length;for(c=A(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||m,p.__i=d,v=I(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&te(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),4&p.__u?(c=j(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function A(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=M(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),ne(s,s));return r}function j(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=j(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=w(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function M(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function N(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function P(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||N(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||N(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function F(e){return function(n){if(this.l){var r=thiLine truncated
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var ke=class extends Error{constructor(e,t){super(e),this.status=t}};function Ae(e){let t=e instanceof ke?e.status:void 0,n=e?.message||`Action failed`;return t===401?{kind:`session-expired`,message:n}:t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function je(e,t){let n=await fetch(e,t);if(!n.ok)throw new ke(await Oe(n),n.status);return n}async function q(e,{method:t=`GET`,body:n,timeoutMs:r=Ee,parse:i=!0}={}){let a={Accept:`application/json`},o={method:t,headers:a,signal:AbortSignal.timeout(r)};t!==`GET`&&(a[`Content-Type`]=`application/json`,a[`X-Archie-CSRF`]=`1`),n!==void 0&&(o.body=JSON.stringify(n));let s=await je(e,o);return i?s.json():void 0}var J={summary:()=>q(`/api/summary`),tasks:()=>q(`/api/tasks`),taskMeta:()=>q(`/api/task-meta`),task:e=>q(`/api/tasks/${e}`),taskAttempts:e=>q(`/api/tasks/${e}/attempts`),taskChanges:(e,t)=>q(`/api/tasks/${e}/changes`+De(t)),taskDebug:(e,t)=>q(`/api/tasks/${e}/debug`+De(t)),taskAction:(e,t)=>q(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>q(`/api/setup`),capabilities:()=>q(`/api/capabilities`),workflows:()=>q(`/api/workflows`),workRequest:e=>q(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>q(`/api/skills`),channels:()=>q(`/api/channels`),curators:()=>q(`/api/curators`),channelReload:e=>q(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>q(`/api/config`),version:()=>q(`/api/version`),configUpdate:e=>q(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>q(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>q(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>q(`/api/logs`+De(e)),taskLogs:(e,t)=>q(`/api/tasks/${e}/logs`+De(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>q(`/api/captures`+De({limit:e})),mappings:()=>q(`/api/mappings`),mappingCreate:e=>q(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>q(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>q(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>q(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>q(`/api/bindings`),bindingCreate:e=>q(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>q(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>q(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>q(`/api/bindings/${e}/approve`,{method:`POST`}),chatSessions:()=>q(`/api/chat/sessions`),chatMessages:e=>q(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>q(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>q(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>q(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:Te(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>q(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>q(`/api/chat/update`),chatUpdateDefer:e=>q(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>q(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>q(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>q(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>q(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>je(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t})};function Me(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Ne(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Pe(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var Fe=[{id:`queued`,label:`Queued`,kind:`idle`},{id:`running`,label:`Working`,kind:`info`},{id:`waiting_human`,label:`Waiting for you`,kind:`warn`,needs_you:!0},{id:`pr_open`,label:`In review`,kind:`ok`},{id:`merged`,label:`Merged`,kind:`ok`},{id:`parked`,label:`Parked`,kind:`warn`,needs_you:!0},{id:`dead`,label:`Stopped (too many retries)`,kind:`danger`},{id:`rejected`,label:`Rejected`,kind:`danger`},{id:`closed_wont_do`,label:`Won't do`,kind:`idle`}],Ie=[{id:`cancel`,label:`Cancel`,kind:`quiet`,confirm:`Cancel "{title}"? This closes the forge issue.`},{id:`stop`,label:`Stop`,kind:`primary`,confirm:`Stop "{title}"? Recoverable work will remain parked.`},{id:`approve`,label:`Approve`,kind:`primary`},{id:`reject`,label:`Reject`,kind:`quiet`,confirm:`Reject "{title}"? ThiLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>tt?`${n.slice(0,tt).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}function Q({text:e,kind:t=`idle`}){return Y(`span`,{className:`pill pill-${t}`,children:e})}var rt=`archie.setup-complete.dismissed.v1`;function it(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?.(rt),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function at(e=globalThis.localStorage){e?.setItem?.(rt,`1`)}var ot=new Set([`waiting_human`,`parked`]);function st(e=[]){let t=e.filter(e=>ot.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 ct({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function lt(e,t){return Number(e.task_id)>0?Number(e.task_id):!e.repo||!e.issue?0:Number(t.get(`${e.repo}#${e.issue}`))||0}function ut(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function dt(e){if(e.length<4)return null;let t=Math.floor(e.length/2),n=e.slice(0,t).reduce((e,t)=>e+t,0),r=e.slice(t).reduce((e,t)=>e+t,0);return n?(r-n)/n*100:null}function ft(){let[e,t]=W([]),[n,r]=W(`connecting`),[i,a]=W(`idle`),[o,s]=W(new Map),[c,l]=W(null),[u,d]=W(null),[f,p]=W(null),[m,h]=W(null),[g,_]=W(null),[,v]=W(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([J.summary(),J.setup().catch(()=>null),J.workflows().catch(()=>null),J.tasks().catch(()=>[])]),i=new Map;for(let e of r)e.owner&&e.repo&&e.issue_number&&i.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);s(i),l(e),d(t),p(n),h(r)}catch(e){_(String(e.message||e))}};G(()=>(y(),Me(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{at(),v(e=>!e)},x=u?.operator?`${ut()}, ${u.operator}`:ut(),C=null;if(g)C=Y(`button`,{className:`btn btn-primary`,onClick:y,children:[Y(X,{name:`refresh`,size:15}),` Retry`]});else if(m!==null){let e=st(m),t=e.attention.count,n=e.running.count;C=Y(S,{children:[t>0&&Y(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[Y(X,{name:`tasks`,size:15}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&Y(`a`,{className:`btn`,href:e.running.href,children:[Y(X,{name:`workflows`,size:15}),` `,n,` running`]}),Y(`a`,{className:`btn`,href:`#/logs`,children:[Y(X,{name:`logs`,size:15}),` Logs`]}),Y(`button`,{className:`btn btn-primary`,onClick:y,children:[Y(X,{name:`refresh`,size:15}),` Refresh`]})]})}let w=null;if(g)w=Y(`div`,{className:`card`,children:Y(ct,{title:`Cannot reach archied`,detail:g})});else if(c){let e=c?.statuses||{},t=(e.merged||0)+(e.pr_open||0),n=(e.parked||0)+(e.waiting_human||0),r=Object.values(e).reduce((e,t)=>e+t,0),i=c?.tokens_by_day||[];w=Y(S,{children:[Y(Ze,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),Y(Ze,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),Y(Ze,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),Y(Ze,{label:`Tokens used`,value:Xe(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:dt(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let T=null,E=it(u),D=E.kind===`omit`||E.kind===`dismissed`;if(!D){let e=E.remaining;if(e.length){let t=Math.round((u.steps.length-e.length)/u.steps.length*100);T=Y(`div`,{className:`card setup`,children:[Y(`div`,{className:`card-head`,children:[Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:`Finish setting up`}),Y(`p`,{className:`card-sub`,children:`Archie needs these before it can work on its own.`})]}),Y(`span`,{className:`setup-pct`,children:[t,`%`]})]}),Y(`div`,{className:`setup-bar`,children:Y(`div`,{className:`setup-bar-fill`,style:{width:`${t}%`}})}),Y(`ul`,{className:`setup-list`,children:u.steps.map((e,t)=>Y(`li`,{className:`setup-step ${e.done?`done`:``}`,children:[Y(`span`,{className:`setup-check`,children:e.done?Y(X,{name:`check`,size:12}):``}),Y(`div`,{children:[Y(`div`,{className:`setup-step-title`,children:e.title}),e.detail&&Y(`div`,{className:`setup-step-detail`,children:e.detail})]})]},t))})]})}else T=Y(`div`,{className:`card setup setup-done`,children:Y(`div`,{className:`card-head`,children:[Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:`Setup complete`}),Y(`p`,{className:`card-sub`,children:`Archie is configured and ready to work.`})]}),Y(`div`,{className:`setup-complete-actions`,children:[Y(`span`,{className:`setup-pct`,children:Y(X,{name:`check`,size:16})}),Y(`button`,{className:`icon-btn setup-dismiss`,ty Line truncated
`),children:[Y(`td`,{className:`strong`,children:e.label||e.id}),Y(`td`,{className:`mono`,children:e.install_type||`—`}),Y(`td`,{className:`mono`,children:e.running_version||`—`}),Y(`td`,{className:`mono`,children:e.latest_available||`—`}),Y(`td`,{children:Y(Q,{text:Zn[e.status]||e.status,kind:Qn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function $({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function er({title:e,sub:t,children:n}){return Y(`div`,{className:`card cfg-section`,children:[Y(`div`,{className:`card-head`,children:Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:e}),Y(`p`,{className:`card-sub`,children:t})]})}),n]})}function tr({origins:e}){return e?.length?Y(er,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:Y(`div`,{className:`kv-list`,children:e.map((e,t)=>Y(qn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):Y(er,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:Y($,{title:`Source provenance is unavailable.`})})}function nr(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function rr({data:e,error:t}){if(t)return Y(er,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:Y($,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return Y(er,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,children:[Y(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?Y(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??Ue(e.id),n=e.kind??We(e.id);return Y(`div`,{className:`kv`,children:[Y(`span`,{className:`kv-label`,children:e.id}),Y(`span`,{className:`kv-value`,children:Y(Q,{text:t,kind:n})})]},e.id)})}):Y($,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),Y(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?Y(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=nr(e.kind);return Y(`div`,{className:`kv`,children:[Y(`span`,{className:`kv-label`,children:e.id}),Y(`span`,{className:`kv-value`,children:Y(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):Y($,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function ir({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=W(!1),[o,s]=W(null),[c,l]=W(!!e[t]);return r?Y(`td`,{children:[Y(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:c,onChange:async r=>{let i=r.target.checked;l(i),a(!0),s(null);try{await J.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){l(!i),s(String(e.message||e))}finally{a(!1)}},disabled:i}),o&&Y(`span`,{className:`kv-note is-error`,children:o})]}):Y(`td`,{children:c?`yes`:`no`})}function ar({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=W(String(e[t]??0)),[o,s]=W(null),[c,l]=W(!1);return r?Y(`td`,{children:[Y(`input`,{className:`kv-input`,type:`text`,value:i,onChange:e=>a(e.target.value),onBlur:async()=>{let r=parseInt(i,10);if(Number.isNaN(r)){s(`Enter a whole number`);return}l(!0),s(null);try{await J.configRepoUpdate(e.owner,e.name,t,r),n?.()}catch(e){s(String(e.message||e))}finally{l(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:c}),o&&Y(`span`,{className:`kv-note is-error`,children:o})]}):Y(`td`,{className:`mono`,children:i})}function or({repos:e,onSaved:t,editable:n=!0}){if(!e?.length)return Y(er,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:Y($,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let r=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return Y(er,{title:`Repositories`,sub:`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, not the file config.toml directly.`,children:Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Repository`}),Y(`th`,{children:`Base branch`}),Y(`th`,{children:`Ecosystem`}),Y(`th`,{children:`Quality gate`}),Y(`th`,{children:`Protected paths`}),Y(`th`,{children:`Concurrent`}),Y(`th`,{children:`Max retries`}),Y(`th`,{children:`Self-review`})]})}),Y(`tbody`,{children:e.map((e,i)=>Y(`tr`,{children:[Y(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),Y(`td`,{className:`mono`,children:e.base}),Y(`td`,{children:e.ecosystem||`go`}),Y(`td`,{className:`mono`,children:r(e.gate)}),Y(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),Y(ir,{r:e,field:`alloLine truncated
`),i=[],a=null,o=null,s=0,c=()=>{i.length&&(n.push(Y(`p`,{children:Hr(i.join(` `))},s++)),i=[])},l=()=>{if(!a)return;let e=a.items.map((e,t)=>Y(`li`,{children:Hr(e)},t));n.push(a.tag===`ol`?Y(`ol`,{children:e},s++):Y(`ul`,{children:e},s++)),a=null};for(let e=0;e<r.length;e++){let t=r[e];if(t.startsWith("```")){c(),l(),o?(n.push(Y(`pre`,{children:Y(`code`,{children:o.join(`
`)})},s++)),o=null):o=[];continue}if(o){o.push(t);continue}let u=Wr(t),d=e+1<r.length?Wr(r[e+1]):null;if(u&&d&&Gr(d)&&u.length===d.length){c(),l();let t=[];for(e+=2;e<r.length;e++){let n=Wr(r[e]);if(!n||n.length!==u.length){e--;break}t.push(n)}n.push(Y(`table`,{children:[Y(`thead`,{children:Y(`tr`,{children:u.map((e,t)=>Y(`th`,{children:Hr(e)},t))})}),Y(`tbody`,{children:t.map((e,t)=>Y(`tr`,{children:e.map((e,t)=>Y(`td`,{children:Hr(e)},t))},t))})]},s++));continue}if(!t.trim()){c(),l();continue}let f=t.match(/^(#{1,3})\s+(.+)$/);if(f){c(),l();let e=`h${f[1].length}`;n.push(Y(e,{children:Hr(f[2])},s++));continue}let p=t.match(/^\s*[-*]\s+(.+)$/),m=t.match(/^\s*\d+[.)]\s+(.+)$/);if(p||m){c();let e=m?`ol`:`ul`;(!a||a.tag!==e)&&(l(),a={tag:e,items:[]}),a.items.push((p||m)[1]);continue}if(t.startsWith(`>`)){c(),l(),n.push(Y(`blockquote`,{children:Hr(t.replace(/^>\s?/,``))},s++));continue}i.push(t)}return c(),l(),o&&n.push(Y(`pre`,{children:Y(`code`,{children:o.join(`
`)})},s++)),Y(`div`,{className:t,children:n})}function Wr(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 Gr(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Kr=`archie.web.chat.channel`;function qr(){let e=localStorage.getItem(Kr);return e||(e=Te(),localStorage.setItem(Kr,e)),e}function Jr(e){return{text:e,sourceID:Te()}}function Yr(e){return{...e}}function Xr(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?Yr(e.turn):Jr(r),isRetry:n}}function Zr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function Qr(){return location.hash.slice(1)||`/`}function $r(){let[e,t]=W([]),[n,r]=W(``),[i,a]=W([]),[o,s]=W(``),[c,l]=W(`Ready`),[u,d]=W(!1),[f,p]=W({}),[m,h]=W(``),[g,_]=W(``),[v,y]=W(``),[b,x]=W([]),[C,w]=W([]),[T,E]=W(0),[D,O]=W(!1),[k,A]=W(null),j=K(null),M=K(null),N=K(null),P=K(null),F=K(null),I=K(u);I.current=u,G(()=>{j.current&&(j.current.scrollTop=j.current.scrollHeight)},[i,k]),G(()=>{L().catch(e=>{l(e.message||`Chat unavailable`)});let e=()=>{N.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),N.current?.abort()}},[]);async function L(){let e=await J.chatSessions(),r=e.sessions||[];t(r),p(e),h(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;_(a),y(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);x(o),!n&&r[0]&&await R(r[0].session_id,e,r)}async function R(e,t,n){let i=t||f;r(e),a([]),A(null);let o=i.active_personas?.[e]||i.active_persona||``;h(o);try{await J.chatMessage(qr(),`/resume ${e}`);let[t,n]=await Promise.all([J.chatMessages(e),J.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});a(i)}catch(e){l(e.message||`Could not load session messages`)}}async function z(e){if(n)try{l(`Working…`);let t=await J.chatMessage(qr(),e);t.session_id&&r(t.session_id),l(t.reply||`Session updated`),await L(),(t.session_id||n)&&await R(t.session_id||n),P.current&&(P.current.open=!1)}catch(e){l(e.message||`Session action failed`)}}function ee(e,t){let n=window.prompt(t);n?.trim()&&z(`${e} ${n.trim()}`)}function te(e){let t=e.target.value;h(t),!(!n||!t)&&J.chatPersona(n,t).then(()=>{p(e=>({...e,active_personas:{...e.active_personas||{},[n]:t}})),l(`Personality: ${t}`)}).catch(e=>{l(e.message||`Failed to set personality`)})}async function ne(e){let t=e.target.value;if(_(t),t)try{let e=await J.chatMessage(qr(),`/model --provider ${t}`);l(e.reply||`Provider updated`),await L()}catch(e){l(`Provider update failed: ${e.message||e}`)}}async function re(e){let t=e.target.value;if(y(t),t)try{let e=await J.chatMessage(qr(),`/model ${t}`);l(e.reply||`Model updated`),await L()}catch(e){l(`Model update failed: ${e.message||e}`)}}function ie(){s(`/new`),H({textOverride:`/new`})}function B(e){let t=e.target.value;s(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=b.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){w(t),E(0),O(!0);return}}O(!1),w([])}function V(e){let t=C[e];if(!t||!M.current)return;let n=M.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.search(/(?:^|\s)\/[^\s]*$/),o=a<0?r.length:a+ +(r[a]===` `),c=`${r.slice(0,o)}${t.command} ${i}`;s(c),O(!1);let l=o+t.command.length+1;setTimeout(()=>{n.focus(),n.setSelectionRange(l,l)},0)}function ae(e){if(D&&C.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&C.some(e=>e.command===o.trim())){e.preventDefault(),O(!1),H();return}if(e.key===`ArrowDown`){e.preventDefault(),E(e=>(e+1)%C.length);return}if(e.key===`ArrowUp`){e.preventDefault(),E(e=>(e+C.length-1)%C.length);return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),V(T);return}if(e.key===`Escape`){e.preventDefault(),O(!1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),H())}async function H(e=null){let t=e?.textOverride,{text:n,turn:i,isRetry:c}=Xr(e,t===void 0?o:t);if(!n||I.current)return;O(!1),d(!0),l(c?`Retrying…`:`Thinking…`),c||(a(e=>[...e,{from:`web`,text:n}]),s(``));let u=[];A({text:``,tools:[],isError:!1,turn:i,isRetry:c});let f=``,p=!1,m=!1,h=null;try{let e=new AbortController;N.current=e,h=setTimeout(()=>{m=!0,e.abort()},12e4);let t=(await J.chatStream({channel_id:qr(),source_id:i.sourceID,text:i.text,page:Qr()},{signal:e.signal})).body.getReader(),n=new TextDecoder,o=``;for(;;){let{value:e,done:i}=await t.read();o+=n.decode(e||new Uint8Array,{stream:!i});let a=o.split(`
`);o=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&&r(n.session_id),n.type===`delta`&&(f+=n.text,z(e=>e?{...e,text:f}:null)),n.type===`tool`&&(u=[...u,n],z(e=>e?{...e,tools:u}:null)),n.type===`navigate`&&(u=[...u,n],z(e=>e?{...e,tools:u}:null)),n.type===`done`&&(p=!0,f||=n.text),n.type===`error`)throw Error(n.text)}if(i)break}if(!p)throw Error(`chat stream ended before completion`);a(e=>[...e,{from:`assistant`,text:f,tool_calls:u}]),z(null),l(`Ready`),await le()}catch(e){if(e.name===`AbortError`&&!m)z({text:`Turn stopped.`,tools:u,isError:!1,turn:i,isRetry:c}),l(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;z({text:t,tools:u,isError:!0,turn:qr(i),isRetry:c}),l(`Error — retry available`)}}finally{clearTimeout(h),V.current=null,d(!1),B.current&&B.current.focus()}}function xe(){l(`Stopping…`),n&&Y.chatCancel(n).catch(()=>{}),V.current?.abort()}let Se=f.models_by_provider||{},Ce=g&&Se[g]?Se[g]:f.models||[];return X(`div`,{className:`chat-page-content`,children:[X(`header`,{className:`chat-topbar`,children:[X(`div`,{children:[X(`span`,{className:`chat-kicker`,children:`ARCHIE WORKSPACE`}),X(`h1`,{className:`page-title`,children:`Chat`})]}),X(`div`,{className:`chat-topbar-actions`,children:[X(`span`,{className:`chat-status`,children:c}),f.restart_available&&X(`button`,{className:`btn`,type:`button`,onClick:ge,children:`Reload Telegram`}),X(`button`,{className:`btn`,type:`button`,onClick:ie,children:`Check updates`}),X(`select`,{className:`chat-select`,"aria-label":`Personality`,value:m,onChange:pe,children:[X(`option`,{value:``,children:`Personality`}),(f.personas||[]).map(e=>X(`option`,{value:e,children:e},e))]}),(f.providers||[]).length>0&&X(`select`,{className:`chat-select`,"aria-label":`Provider`,value:g,onChange:me,children:[X(`option`,{value:``,children:`Provider`}),(f.providers||[]).map(e=>X(`option`,{value:e,children:e},e))]}),X(`select`,{className:`chat-select`,"aria-label":`Model`,value:v,onChange:he,children:[X(`option`,{value:``,children:`Model`}),Ce.map(e=>X(`option`,{value:e,children:e},e))]})]})]}),k&&X(`div`,{className:`chat-update-panel`,children:k.error?X(`span`,{children:k.error}):k.available?.length?X(S,{children:[X(`div`,{children:[X(`strong`,{children:`Update available`}),X(`span`,{children:k.available.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)})]}),X(`div`,{className:`chat-update-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:ae,children:`Defer`}),k.can_install&&X(`button`,{className:`btn btn-primary`,type:`button`,onClick:oe,children:`Install update`})]})]}):X(`span`,{children:k.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`})}),f.dangerous_available&&N&&X(`div`,{className:`chat-dangerous-panel`,children:[X(`div`,{className:`chat-dangerous-head`,children:[X(`strong`,{children:`Dangerous actions`}),X(`span`,{className:`chat-hint`,children:`Every action requires approval.`})]}),X(`div`,{className:`chat-dangerous-controls`,children:[X(`div`,{children:[X(`select`,{className:`chat-select`,"aria-label":`Checkpoint`,value:F,onChange:e=>I(e.target.value),children:[X(`option`,{value:``,children:`Select checkpoint`}),(N.checkpoints||[]).map(e=>X(`option`,{value:e.Number??e.number,children:[e.Number??e.number,` — `,e.Label??e.label??`checkpoint`]},e.Number??e.number))]}),X(`button`,{className:`btn`,type:`button`,onClick:()=>U(`rollback`,F),children:`Request rollback`})]}),X(`div`,{children:[X(`input`,{className:`chat-dangerous-input`,placeholder:`Process name or id`,"aria-label":`Process name or id`,value:L,onInput:e=>ee(e.target.value)}),X(`button`,{className:`btn`,type:`button`,onClick:()=>U(`stop`,L),children:`Request stop`})]})]}),X(`div`,{className:`chat-dangerous-pending-list`,children:(N.pending||[]).length?N.pending.map(e=>X(`div`,{className:`chat-dangerous-pending`,children:[X(`span`,{children:e.description}),X(`div`,{className:`chat-update-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:()=>ce(e.id,`approve`),children:`Approve`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>ce(e.id,`permanent`),children:`Approve for 24h`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>ce(e.id,`deny`),children:`Deny`})]})]},e.id)):X(`span`,{className:`chat-hint`,children:`No pending dangerous actions.`})})]}),X(`div`,{className:`chat-layout`,children:[X(`aside`,{className:`chat-sidebar`,children:[X(`div`,{className:`chat-sidebar-head`,children:[X(`strong`,{children:`Conversations`}),X(`button`,{className:`btn btn-primary`,type:`button`,onClick:_e,children:`+ New chat`})]}),X(`div`,{className:`chat-session-list`,children:e.length?e.map(e=>X(`button`,{className:`chat-session ${n===e.session_id?`active`:``}`,type:`button`,onClick:()=>ue(e.session_id),children:[X(`strong`,{children:Yr(e)}),X(`span`,{children:new Date(e.last_active_at).toLocaleString()})]},e.session_id)):X(`div`,{className:`chat-empty`,children:`Your conversations will aLine truncated
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&r(n.session_id),n.type===`delta`&&(f+=n.text,A(e=>e?{...e,text:f}:null)),n.type===`tool`&&(u=[...u,n],A(e=>e?{...e,tools:u}:null)),n.type===`navigate`&&(u=[...u,n],A(e=>e?{...e,tools:u}:null)),n.type===`done`&&(p=!0,f||=n.text),n.type===`error`)throw Error(n.text)}if(i)break}if(!p)throw Error(`chat stream ended before completion`);a(e=>[...e,{from:`assistant`,text:f,tool_calls:u}]),A(null),l(`Ready`),await L()}catch(e){if(e.name===`AbortError`&&!m)A({text:`Turn stopped.`,tools:u,isError:!1,turn:i,isRetry:c}),l(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;A({text:t,tools:u,isError:!0,turn:Yr(i),isRetry:c}),l(`Error — retry available`)}}finally{clearTimeout(h),N.current=null,d(!1),M.current&&M.current.focus()}}function oe(){l(`Stopping…`),n&&J.chatCancel(n).catch(()=>{}),N.current?.abort()}let se=f.models_by_provider||{},U=g&&se[g]?se[g]:f.models||[];return Y(`div`,{className:`chat-panel-content`,children:[Y(`div`,{className:`chat-bar`,children:[Y(`label`,{className:`chat-session-switch`,children:[Y(`span`,{className:`sr-only`,children:`Conversation`}),Y(`select`,{value:n,onChange:e=>R(e.target.value),disabled:!e.length,children:e.length?e.map(e=>Y(`option`,{value:e.session_id,children:Zr(e)},e.session_id)):Y(`option`,{value:``,children:`No conversations yet`})})]}),Y(`button`,{className:`icon-btn chat-new`,type:`button`,title:`New chat`,"aria-label":`New chat`,onClick:ie,children:`+`}),Y(`details`,{className:`chat-settings`,children:[Y(`summary`,{"aria-label":`Chat settings`,title:`Chat settings`,children:Y(`span`,{"aria-hidden":`true`,children:`⚙`})}),Y(`div`,{className:`chat-settings-body`,children:[Y(`span`,{className:`chat-status`,children:c}),Y(`label`,{children:[`Personality`,Y(`select`,{className:`chat-select`,"aria-label":`Personality`,value:m,onChange:te,children:[Y(`option`,{value:``,children:`Default`}),(f.personas||[]).map(e=>Y(`option`,{value:e,children:e},e))]})]}),(f.providers||[]).length>0&&Y(`label`,{children:[`Provider`,Y(`select`,{className:`chat-select`,"aria-label":`Provider`,value:g,onChange:ne,children:[Y(`option`,{value:``,children:`Default`}),(f.providers||[]).map(e=>Y(`option`,{value:e,children:e},e))]})]}),Y(`label`,{children:[`Model`,Y(`select`,{className:`chat-select`,"aria-label":`Model`,value:v,onChange:re,children:[Y(`option`,{value:``,children:`Default`}),U.map(e=>Y(`option`,{value:e,children:e},e))]})]})]})]})]}),Y(`div`,{className:`chat-layout`,children:Y(`section`,{className:`chat-workspace`,children:[Y(`div`,{className:`chat-workspace-head`,children:[Y(`details`,{className:`chat-command-help`,children:[Y(`summary`,{children:[`Available commands (`,b.length,`)`]}),Y(`div`,{className:`chat-command-list`,children:b.length?b.map(e=>Y(`div`,{className:`chat-command-item`,children:[Y(`code`,{children:e.usage||e.command}),Y(`span`,{children:e.description||``})]},e.command)):Y(`span`,{children:`Send a message to begin.`})})]}),Y(`details`,{className:`chat-session-tools`,ref:P,hidden:!n,children:[Y(`summary`,{children:`Session actions`}),Y(`div`,{className:`chat-session-tool-list`,children:[Y(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/retry`),children:`Retry`}),Y(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/undo`),children:`Undo`}),Y(`button`,{className:`btn`,type:`button`,onClick:()=>ee(`/title`,`Session title`),children:`Rename`}),Y(`button`,{className:`btn`,type:`button`,onClick:()=>ee(`/branch`,`Branch name (optional)`),children:`Branch`}),Y(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/compress --preview`),children:`Preview compression`})]})]})]}),Y(`div`,{className:`chat-transcript`,ref:j,children:!i.length&&!k?Y(`div`,{className:`chat-empty-state`,children:[Y(`span`,{className:`chat-empty-mark`,children:`A`}),Y(`h2`,{children:`What are we working on?`}),Y(`p`,{children:`Ask Archie anything, or start with one of these prompts.`}),Y(`div`,{className:`chat-prompt-grid`,children:[Y(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{s(`Summarise active tasks`),M.current?.focus()},children:`Summarise active tasks`}),Y(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{s(`Show running agents`),M.current?.focus()},children:`Show running agents`}),Y(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{s(`Check system status`),M.current?.focus()},children:`Check system status`})]})]}):Y(S,{children:[i.map((e,t)=>{let n=e.from??e.From??``,r=e.text??e.Text??``,i=n!==`web`,a=e.tool_calls||e.ToolCalls||[];return Y(`div`,{className:`chat-bubble-row ${i?`assistant`:`user`}`,children:Y(`div`,{className:`chat-bubble`,children:[Y(`div`,{className:`chat-bubble-meta`,children:i?`Archie`:`You`}),i?Y(S,{children:[a.length>0&&Y(`div`,{className:`chat-tools`,children:a.map((e,t)=>{if(e.path)return Y(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[Y(`span`,{className:`cLine truncated
+129 -21
View File
@@ -1,8 +1,120 @@
.chat-page-content { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.chat-topbar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.chat-kicker, .chat-workspace-label { color: var(--fg-muted); font-size: .68rem; font-weight: 700; letter-spacing: .12em; }
.chat-topbar-actions { display: flex; align-items: center; gap: .55rem; }
.chat-topbar-actions .chat-select { max-width: 14rem; min-width: 0; }
/* The panel's own column. ChatApp is mounted in a ~440px launcher panel, never
on a page, so there is one column and every row earns its height
(archie-core-hesx). */
.chat-panel-content {
display: grid;
grid-template-rows: auto minmax(0, 1fr);
flex: 1 1 auto;
min-height: 0;
overflow: hidden;
}
/* One row for everything that is not the conversation: which conversation,
a new one, and the model controls folded away behind a disclosure. */
.chat-bar {
display: flex;
align-items: center;
gap: var(--sp-2);
padding: var(--sp-2) var(--sp-3);
border-bottom: 1px solid var(--border);
}
.chat-session-switch {
flex: 1 1 auto;
min-width: 0;
}
.chat-session-switch select {
width: 100%;
background: var(--surface-hover);
color: var(--fg);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: var(--sp-2);
font: inherit;
font-size: var(--text-sm);
}
.chat-new,
.chat-settings > summary {
flex: none;
}
.chat-settings {
position: relative;
flex: none;
}
.chat-settings > summary {
display: grid;
place-items: center;
width: 32px;
height: 32px;
border-radius: var(--radius-sm);
color: var(--fg-muted);
cursor: pointer;
list-style: none;
}
.chat-settings > summary::-webkit-details-marker {
display: none;
}
.chat-settings > summary:hover {
background: var(--surface-hover);
color: var(--fg);
}
/* Opens over the transcript rather than pushing it down: the panel is short
and the conversation should not jump when the controls are consulted. */
.chat-settings-body {
position: absolute;
top: calc(100% + var(--sp-2));
right: 0;
z-index: 2;
display: grid;
gap: var(--sp-3);
width: 15rem;
padding: var(--sp-3);
background: var(--bg-raised);
border: 1px solid var(--border);
border-radius: var(--radius-md);
box-shadow: var(--shadow-md);
}
.chat-settings-body label {
display: grid;
gap: var(--sp-1);
font-size: var(--text-xs);
color: var(--fg-muted);
}
.chat-settings-body .chat-select {
width: 100%;
}
.chat-layout {
display: grid;
min-height: 0;
overflow: hidden;
}
.chat-workspace {
display: grid;
grid-template-rows: auto minmax(0, 1fr) auto;
min-width: 0;
overflow: hidden;
}
.chat-workspace-head {
display: flex;
align-items: center;
gap: var(--sp-2);
padding: var(--sp-2) var(--sp-3);
border-bottom: 1px solid var(--border);
font-size: var(--text-xs);
}
.chat-update-panel { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 .75rem; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: .75rem; color: var(--fg-muted); font-size: .8rem; }
.chat-update-panel > div:first-child { display: grid; gap: .2rem; }
.chat-update-panel strong { color: var(--fg); }
@@ -15,27 +127,21 @@
.chat-dangerous-input { min-width: 0; flex: 1; padding: .5rem .65rem; background: var(--surface-hover); color: var(--fg); border: 1px solid var(--border-strong); border-radius: .5rem; font: inherit; }
.chat-dangerous-pending-list { display: grid; gap: .45rem; margin-top: .75rem; }
.chat-dangerous-pending { padding-top: .55rem; border-top: 1px solid var(--border); color: var(--fg-muted); font-size: .8rem; }
.chat-layout { display: grid; grid-template-columns: 242px minmax(0, 1fr); gap: .75rem; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.chat-sidebar, .chat-workspace { background: var(--surface); border: 1px solid var(--border); border-radius: 1rem; }
.chat-sidebar { padding: .8rem; overflow-y: auto; }
.chat-sidebar-head, .chat-toolbar, .chat-compose-actions { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.chat-session-list { display: grid; gap: .35rem; margin-top: 1rem; }
.chat-session { display: grid; gap: .25rem; text-align: left; background: transparent; color: var(--fg-muted); border: 1px solid transparent; border-radius: .65rem; padding: .7rem; cursor: pointer; }
.chat-session:hover, .chat-session.active { background: var(--surface-hover); color: var(--fg); border-color: var(--border-strong); }
.chat-session span { font-size: .72rem; }
.chat-workspace { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; min-width: 0; }
.chat-workspace-head { display: flex; align-items: center; justify-content: space-between; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); }
.chat-session-tools { position: relative; margin-left: .6rem; color: var(--fg-muted); font-size: .78rem; }
.chat-session-tools summary { cursor: pointer; }
.chat-session-tool-list { position: absolute; z-index: 2; right: 0; top: calc(100% + .45rem); display: flex; flex-wrap: wrap; gap: .35rem; width: min(22rem, 72vw); padding: .55rem; background: var(--surface); border: 1px solid var(--border-strong); border-radius: .65rem; box-shadow: 0 .7rem 2rem color-mix(in srgb, #000 30%, transparent); }
.chat-select { background: var(--surface-hover); color: var(--fg); border: 1px solid var(--border-strong); border-radius: .5rem; padding: .5rem .65rem; }
.chat-transcript { overflow: auto; padding: 1.25rem; display: grid; align-content: start; gap: 1rem; }
.chat-empty-state { align-self: center; justify-self: center; width: min(100%, 40rem); padding: 3rem 1rem; text-align: center; }
.chat-empty-mark { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; margin: 0 auto 1rem; border: 1px solid var(--border-strong); border-radius: .8rem; color: var(--accent); font-weight: 700; }
.chat-empty-state h2 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.25rem); letter-spacing: -.04em; }
.chat-empty-state p { margin: .6rem 0 1.4rem; color: var(--fg-muted); }
.chat-prompt-grid { display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; }
.chat-prompt { padding: .55rem .75rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-hover); color: var(--fg-muted); cursor: pointer; }
.chat-transcript { overflow: auto; padding: var(--sp-4); display: grid; align-content: start; gap: var(--sp-4); }
.chat-empty-state { align-self: center; justify-self: center; width: 100%; padding: var(--sp-5) 0; text-align: center; }
.chat-empty-mark { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; margin: 0 auto var(--sp-3); border: 1px solid var(--border-strong); border-radius: .8rem; color: var(--accent); font-weight: 700; }
.chat-empty-state h2 { margin: 0; font-size: var(--text-lg); letter-spacing: -.02em; }
.chat-empty-state p { margin: var(--sp-2) 0 var(--sp-4); color: var(--fg-muted); font-size: var(--text-sm); }
.chat-prompt-grid { display: grid; gap: var(--sp-2); }
.chat-prompt { padding: var(--sp-2) var(--sp-3); font-size: var(--text-sm); text-align: left; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-hover); color: var(--fg-muted); cursor: pointer; }
.chat-prompt:hover { color: var(--fg); border-color: var(--border-strong); }
.chat-bubble-row { display: flex; }
.chat-bubble-row.user { justify-content: flex-end; }
@@ -96,7 +202,7 @@
}
.chat-nav-chip-icon { font-size: .8rem; line-height: 1; }
.chat-compose { padding: .85rem 1rem 1rem; border-top: 1px solid var(--border); }
.chat-compose { padding: var(--sp-3); border-top: 1px solid var(--border); }
.chat-composer-shell { position: relative; padding: .7rem .8rem .55rem; background: var(--surface-hover); border: 1px solid var(--border-strong); border-radius: .9rem; }
.chat-composer { width: 100%; min-height: 3.3rem; resize: vertical; box-sizing: border-box; background: transparent; color: var(--fg); border: 0; padding: .25rem 0; font: inherit; }
.chat-composer:focus { outline: 0; }
@@ -105,12 +211,14 @@
.chat-command-option { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr; gap: .65rem; align-items: center; padding: .5rem .6rem; text-align: left; color: var(--fg-muted); background: transparent; border: 1px solid transparent; border-radius: .45rem; cursor: pointer; }
.chat-command-option:hover, .chat-command-option[aria-selected="true"] { color: var(--fg); background: var(--surface-hover); border-color: var(--border); }
.chat-command-option code { color: var(--fg); }
.chat-compose-actions { margin-top: .55rem; }
/* The hint takes the whole first row so Stop and Send always sit together on
the second, rather than the hint pushing Send onto a line of its own. */
.chat-compose-actions { margin-top: var(--sp-2); flex-wrap: wrap; row-gap: var(--sp-2); justify-content: flex-end; }
.chat-compose-actions .chat-hint { flex: 1 0 100%; font-size: var(--text-xs); color: var(--fg-muted); }
.chat-hint, .chat-empty { color: var(--fg-muted); font-size: .78rem; }
.chat-command-help { color: var(--fg-muted); font-size: .78rem; margin-right: auto; }
.chat-command-help summary { cursor: pointer; }
.chat-command-list { min-width: min(34rem, 70vw); max-width: 40rem; padding-top: .4rem; line-height: 1.45; }
.chat-command-item { display: grid; grid-template-columns: minmax(10rem, 16rem) 1fr; gap: .7rem; padding: .3rem 0; }
.chat-command-item code { color: var(--fg); }
@media (max-width: 760px) { .chat-topbar, .chat-topbar-actions { align-items: flex-start; flex-direction: column; } .chat-layout { grid-template-columns: 1fr; } .chat-sidebar { max-height: 14rem; overflow: auto; } }
@media (max-width: 520px) { .chat-update-panel { align-items: flex-start; flex-direction: column; } }
+71 -282
View File
@@ -5,7 +5,6 @@ import { ChatMarkdown } from "./markdown.jsx";
import { channelID } from "./chat-state.jsx";
import { newChatTurn, retryChatTurn, resolveTurn } from "./chat-retry.jsx";
import { sessionTitle } from "./chat-render.jsx";
import { updateUnavailableMessage } from "./chat-update-status.jsx";
import "./chat.css";
@@ -31,13 +30,6 @@ export function ChatApp() {
const [commandSelection, setCommandSelection] = useState(0);
const [isCommandMenuOpen, setIsCommandMenuOpen] = useState(false);
const [updateData, setUpdateData] = useState(null);
const [updateSnapshot, setUpdateSnapshot] = useState(null);
const [dangerousData, setDangerousData] = useState(null);
const [dangerousCheckpoint, setDangerousCheckpoint] = useState("");
const [dangerousStopSpec, setDangerousStopSpec] = useState("");
const [streamingTurn, setStreamingTurn] = useState(null);
// streamingTurn: { text: string, tools: [], isError: bool, turn: object, isRetry: bool }
@@ -60,7 +52,6 @@ export function ChatApp() {
refreshSessions().catch((err) => {
setStatusText(err.message || "Chat unavailable");
});
refreshUpdate();
const onTeardown = () => {
activeControllerRef.current?.abort();
@@ -72,75 +63,6 @@ export function ChatApp() {
};
}, []);
async function refreshUpdate() {
try {
const data = await api.chatUpdate();
setUpdateSnapshot(data?.snapshot || null);
setUpdateData(data);
} catch (err) {
const message = updateUnavailableMessage(err);
if (message) {
setUpdateData({ error: message });
} else {
setUpdateData(null);
}
}
}
async function deferUpdate() {
if (!updateSnapshot) return;
try {
await api.chatUpdateDefer(updateSnapshot);
setUpdateData({ snapshot: { deferred: true }, available: [] });
setStatusText("Update deferred");
} catch (err) {
setStatusText(err.message || "Could not defer update");
}
}
async function installUpdate() {
if (!updateSnapshot) return;
try {
setStatusText("Installing…");
const result = await api.chatUpdateInstall(updateSnapshot);
setUpdateSnapshot(null);
setUpdateData({ snapshot: {}, available: [] });
setStatusText(result?.result?.restart_requested ? "Update installed; restart queued" : "Update complete");
} catch (err) {
setStatusText(err.message || "Update install failed");
}
}
async function refreshDangerous() {
try {
const data = await api.chatDangerous();
setDangerousData(data);
} catch (err) {
setDangerousData({ error: err.message || "Dangerous actions unavailable" });
}
}
async function requestDangerousAction(kind, spec) {
if (!spec) return;
try {
await api.chatDangerousRequest(kind, spec);
setStatusText("Approval requested");
await refreshDangerous();
} catch (err) {
setStatusText(err.message || "Could not request action");
}
}
async function decideDangerousAction(id, decision) {
try {
await api.chatDangerousDecision(id, decision);
setStatusText(decision === "deny" ? "Action denied" : "Action approved");
await refreshDangerous();
} catch (err) {
setStatusText(err.message || "Approval failed");
}
}
async function refreshSessions() {
const data = await api.chatSessions();
const sessionList = data.sessions || [];
@@ -158,10 +80,6 @@ export function ChatApp() {
);
setCommandSpecs(specs);
if (data.dangerous_available) {
await refreshDangerous();
}
if (!currentSession && sessionList[0]) {
await selectSession(sessionList[0].session_id, data, sessionList);
}
@@ -258,12 +176,6 @@ export function ChatApp() {
}
}
function handleRestartTelegram() {
if (!window.confirm("Reload the Telegram chat adapter?")) return;
setComposerText("/restart");
sendMessage({ textOverride: "/restart" });
}
function handleNewChat() {
setComposerText("/new");
sendMessage({ textOverride: "/new" });
@@ -487,213 +399,94 @@ export function ChatApp() {
: selectorData.models || [];
return (
<div className="chat-page-content">
<header className="chat-topbar">
<div>
<span className="chat-kicker">ARCHIE WORKSPACE</span>
<h1 className="page-title">Chat</h1>
</div>
<div className="chat-topbar-actions">
<span className="chat-status">{statusText}</span>
{selectorData.restart_available && (
<button className="btn" type="button" onClick={handleRestartTelegram}>
Reload Telegram
</button>
)}
<button className="btn" type="button" onClick={refreshUpdate}>
Check updates
</button>
<div className="chat-panel-content">
<div className="chat-bar">
<label className="chat-session-switch">
<span className="sr-only">Conversation</span>
<select
className="chat-select"
aria-label="Personality"
value={selectedPersona}
onChange={handlePersonaChange}
value={currentSession}
onChange={(e) => selectSession(e.target.value)}
disabled={!sessions.length}
>
<option value="">Personality</option>
{(selectorData.personas || []).map((name) => (
<option key={name} value={name}>
{name}
</option>
))}
</select>
{(selectorData.providers || []).length > 0 && (
<select
className="chat-select"
aria-label="Provider"
value={selectedProvider}
onChange={handleProviderChange}
>
<option value="">Provider</option>
{(selectorData.providers || []).map((p) => (
<option key={p} value={p}>
{p}
{!sessions.length ? (
<option value="">No conversations yet</option>
) : (
sessions.map((session) => (
<option key={session.session_id} value={session.session_id}>
{sessionTitle(session)}
</option>
))}
</select>
)}
<select
className="chat-select"
aria-label="Model"
value={selectedModel}
onChange={handleModelChange}
>
<option value="">Model</option>
{currentModels.map((m) => (
<option key={m} value={m}>
{m}
</option>
))}
))
)}
</select>
</div>
</header>
</label>
{/* Update Panel */}
{updateData && (
<div className="chat-update-panel">
{updateData.error ? (
<span>{updateData.error}</span>
) : updateData.available?.length ? (
<Fragment>
<div>
<strong>Update available</strong>
<span>
{updateData.available
.map((c) => `${c.Label || c.label}: ${c.Available || c.available}`)
.join(" · ")}
</span>
</div>
<div className="chat-update-actions">
<button className="btn" type="button" onClick={deferUpdate}>
Defer
</button>
{updateData.can_install && (
<button className="btn btn-primary" type="button" onClick={installUpdate}>
Install update
</button>
)}
</div>
</Fragment>
) : (
<span>{updateData.snapshot?.deferred ? "Update deferred." : "Archie is up to date."}</span>
)}
</div>
)}
<button className="icon-btn chat-new" type="button" title="New chat" aria-label="New chat" onClick={handleNewChat}>
+
</button>
{/* Dangerous Panel */}
{selectorData.dangerous_available && dangerousData && (
<div className="chat-dangerous-panel">
<div className="chat-dangerous-head">
<strong>Dangerous actions</strong>
<span className="chat-hint">Every action requires approval.</span>
</div>
<div className="chat-dangerous-controls">
<div>
<details className="chat-settings">
<summary aria-label="Chat settings" title="Chat settings">
<span aria-hidden="true">⚙</span>
</summary>
<div className="chat-settings-body">
<span className="chat-status">{statusText}</span>
<label>
Personality
<select
className="chat-select"
aria-label="Checkpoint"
value={dangerousCheckpoint}
onChange={(e) => setDangerousCheckpoint(e.target.value)}
aria-label="Personality"
value={selectedPersona}
onChange={handlePersonaChange}
>
<option value="">Select checkpoint</option>
{(dangerousData.checkpoints || []).map((cp) => (
<option key={cp.Number ?? cp.number} value={cp.Number ?? cp.number}>
{cp.Number ?? cp.number} — {cp.Label ?? cp.label ?? "checkpoint"}
<option value="">Default</option>
{(selectorData.personas || []).map((name) => (
<option key={name} value={name}>
{name}
</option>
))}
</select>
<button
className="btn"
type="button"
onClick={() => requestDangerousAction("rollback", dangerousCheckpoint)}
>
Request rollback
</button>
</div>
<div>
<input
className="chat-dangerous-input"
placeholder="Process name or id"
aria-label="Process name or id"
value={dangerousStopSpec}
onInput={(e) => setDangerousStopSpec(e.target.value)}
/>
<button
className="btn"
type="button"
onClick={() => requestDangerousAction("stop", dangerousStopSpec)}
>
Request stop
</button>
</div>
</div>
<div className="chat-dangerous-pending-list">
{(dangerousData.pending || []).length ? (
dangerousData.pending.map((action) => (
<div className="chat-dangerous-pending" key={action.id}>
<span>{action.description}</span>
<div className="chat-update-actions">
<button
className="btn"
type="button"
onClick={() => decideDangerousAction(action.id, "approve")}
>
Approve
</button>
<button
className="btn"
type="button"
onClick={() => decideDangerousAction(action.id, "permanent")}
>
Approve for 24h
</button>
<button
className="btn"
type="button"
onClick={() => decideDangerousAction(action.id, "deny")}
>
Deny
</button>
</div>
</div>
))
) : (
<span className="chat-hint">No pending dangerous actions.</span>
)}
</div>
</div>
)}
{/* Main Layout */}
<div className="chat-layout">
<aside className="chat-sidebar">
<div className="chat-sidebar-head">
<strong>Conversations</strong>
<button className="btn btn-primary" type="button" onClick={handleNewChat}>
+ New chat
</button>
</div>
<div className="chat-session-list">
{!sessions.length ? (
<div className="chat-empty">Your conversations will appear here.</div>
) : (
sessions.map((session) => (
<button
key={session.session_id}
className={`chat-session ${currentSession === session.session_id ? "active" : ""}`}
type="button"
onClick={() => selectSession(session.session_id)}
</label>
{(selectorData.providers || []).length > 0 && (
<label>
Provider
<select
className="chat-select"
aria-label="Provider"
value={selectedProvider}
onChange={handleProviderChange}
>
<strong>{sessionTitle(session)}</strong>
<span>{new Date(session.last_active_at).toLocaleString()}</span>
</button>
))
<option value="">Default</option>
{(selectorData.providers || []).map((provider) => (
<option key={provider} value={provider}>
{provider}
</option>
))}
</select>
</label>
)}
<label>
Model
<select
className="chat-select"
aria-label="Model"
value={selectedModel}
onChange={handleModelChange}
>
<option value="">Default</option>
{currentModels.map((model) => (
<option key={model} value={model}>
{model}
</option>
))}
</select>
</label>
</div>
</aside>
</details>
</div>
<div className="chat-layout">
<section className="chat-workspace">
<div className="chat-workspace-head">
<span className="chat-workspace-label">PERSONAL ASSISTANT</span>
<details className="chat-command-help">
<summary>Available commands ({commandSpecs.length})</summary>
<div className="chat-command-list">
@@ -937,7 +730,7 @@ export function ChatApp() {
ref={composerRef}
className="chat-composer"
rows={3}
placeholder="Message Archie… (commands like /status and /new work here)"
placeholder="Message Archie, or type / for commands"
aria-label="Message Archie"
disabled={isSending}
value={composerText}
@@ -993,7 +786,3 @@ export function ChatApp() {
</div>
);
}
export function ChatPage() {
return <ChatApp />;
}
+14
View File
@@ -54,3 +54,17 @@ a {
clip-path: inset(50%);
white-space: nowrap;
}
/* Visible to assistive technology only. For a control whose purpose is clear
from its position but which still needs a name in the accessibility tree. */
.sr-only {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
border: 0;
}
+175 -73
View File
@@ -74,14 +74,28 @@ body {
align-items: center;
gap: 2px;
margin: 0 auto;
/* The nav is the only region that can afford to lose width, so it is the
only one allowed to shrink. min-width:0 lets it actually do so inside a
flex row, and the scroll is the last resort before anything clips --
.app sets overflow:hidden, so an unshrinkable row loses the utility
cluster off the right edge with no way to reach it. */
flex: 0 1 auto;
min-width: 0;
overflow-x: auto;
scrollbar-width: none;
padding: 3px;
border-radius: var(--radius-pill);
background: var(--surface-glass-strong);
border: 1px solid var(--hairline);
}
.nav::-webkit-scrollbar {
display: none;
}
.nav-item {
display: inline-flex;
flex: none;
align-items: center;
gap: var(--sp-2);
padding: var(--sp-2) var(--sp-3);
@@ -192,28 +206,86 @@ body {
overflow-x: hidden;
}
/* ── Chat drawer ─────────────────────────────────────────────────────── */
/* The chat is a persistent slide-over, not a route: it is mounted once and
opened from the topbar, so the operator can talk to Archie from any page
without leaving the work that prompted the question. It overlays the
layout rather than replacing it, and the navigation/outlet stay interactive
behind the scrim. */
.chat-drawer {
/* ── Chat launcher and panel ─────────────────────────────────────────── */
/* A floating launcher, bottom-right, and the panel it opens immediately to
its left. The two share a bottom edge and the panel grows out of the button,
so the launcher never moves and always reads as the thing that produced the
panel.
Deliberately not a modal: no scrim, no body scroll lock, no focus trap. The
operator asks Archie about the page they are on, so that page has to stay
readable, scrollable and clickable while the panel is open. */
.chat-dock {
--fab-size: 56px;
--fab-inset: var(--sp-5);
--fab-gap: var(--sp-3);
position: fixed;
inset: var(--sp-4);
display: flex;
align-items: stretch;
justify-content: flex-end;
pointer-events: none;
right: var(--fab-inset);
bottom: var(--fab-inset);
z-index: 40;
}
.chat-fab {
position: relative;
display: grid;
place-items: center;
width: var(--fab-size);
height: var(--fab-size);
border: 0;
border-radius: var(--radius-pill);
background: linear-gradient(135deg, var(--accent), var(--accent-2));
color: #fff;
cursor: pointer;
box-shadow: var(--shadow-md);
transition: transform var(--transition), box-shadow var(--transition);
}
.chat-fab:hover {
transform: translateY(-1px);
box-shadow: 0 12px 34px color-mix(in srgb, var(--accent) 38%, transparent);
}
.chat-fab:active {
transform: translateY(0);
}
/* Both glyphs are stacked and cross-faded, so the button keeps one size and
the swap cannot reflow the dock. */
.chat-fab-icon {
grid-area: 1 / 1;
display: grid;
place-items: center;
transition: opacity var(--transition), transform var(--transition);
}
.chat-fab-icon-close,
.chat-dock.is-open .chat-fab-icon-open {
opacity: 0;
transform: scale(0.7) rotate(-45deg);
}
.chat-fab-icon-open,
.chat-dock.is-open .chat-fab-icon-close {
opacity: 1;
transform: none;
}
/* The panel is positioned off the dock, not the viewport: it sits one gap to
the left of the launcher and rises from the shared bottom edge. */
.chat-drawer {
position: absolute;
right: calc(var(--fab-size) + var(--fab-gap));
bottom: 0;
width: min(440px, calc(100vw - var(--fab-size) - var(--fab-gap) - var(--fab-inset) * 2));
height: min(640px, calc(100vh - var(--fab-inset) * 2));
pointer-events: none;
}
.chat-drawer-panel {
pointer-events: auto;
position: relative;
z-index: 1;
display: grid;
grid-template-rows: auto minmax(0, 1fr);
width: min(430px, 100%);
width: 100%;
height: 100%;
background: var(--surface);
border: 1px solid var(--border);
@@ -221,19 +293,25 @@ body {
box-shadow: var(--shadow-md);
overflow: hidden;
opacity: 0;
transform: translateX(1.2rem);
/* Grows out of the launcher: the origin is the corner nearest the button. */
transform-origin: bottom right;
transform: scale(0.92) translateX(var(--sp-3));
transition: opacity var(--transition), transform var(--transition);
}
/* A closed (opacity-0, still mounted) panel must not block the page behind
it: opacity does not disable hit-testing, so without this the invisible
430px panel would make the whole right column unclickable at z-index 40. */
/* A closed panel is still mounted so the session and its stream survive. It
must not take hits or reach the tab order while invisible. */
.chat-drawer:not(.is-open) .chat-drawer-panel {
pointer-events: none;
visibility: hidden;
}
.chat-drawer.is-open .chat-drawer-panel {
opacity: 1;
transform: none;
visibility: visible;
}
.chat-drawer-head {
display: flex;
align-items: center;
@@ -242,28 +320,89 @@ body {
padding: var(--sp-3) var(--sp-4);
border-bottom: 1px solid var(--border);
}
.chat-scrim {
position: fixed;
inset: 0;
background: color-mix(in srgb, var(--bg) 40%, transparent);
opacity: 0;
pointer-events: none;
transition: opacity var(--transition);
/* Below this there is no room beside the launcher, so the panel stops being
anchored to it and becomes a sheet on the viewport. The launcher hides while
the sheet is up: its own close button is the way out. */
@media (max-width: 720px) {
.chat-dock {
--fab-inset: var(--sp-4);
}
.chat-drawer {
position: fixed;
right: var(--fab-inset);
left: var(--fab-inset);
bottom: var(--fab-inset);
width: auto;
height: min(78vh, calc(100vh - var(--fab-inset) * 2));
}
.chat-drawer-panel {
transform-origin: bottom center;
transform: scale(0.98) translateY(var(--sp-3));
}
.chat-dock.is-open .chat-fab {
opacity: 0;
pointer-events: none;
}
}
/* The scrim shows and closes from outside clicks only when the drawer is
open; it is driven by the drawer's own state so it can never be on top of
a closed drawer. */
.chat-drawer.is-open .chat-scrim {
opacity: 1;
pointer-events: auto;
}
body.chat-open {
overflow: hidden;
/* ── Collapsed search ───────────────────────────────────────────────────── */
/* The always-open "Jump to" field is the widest thing in the utility cluster
and the least often used. Past this width it collapses to its icon and
expands on demand, which is what keeps the nav from having to scroll at
ordinary laptop sizes. Measured: the labelled nav needs 917px and the
collapsed cluster 160px, so an expanded field does not fit beside them until
about 1430px -- collapsing to 1500 keeps 1440 comfortable rather than
marginal. */
@media (max-width: 1500px) {
.topbar-search {
padding: 0;
border: 0;
background: transparent;
overflow: hidden;
}
.topbar-search-icon {
display: none;
}
.mobile-search-toggle {
display: grid;
}
.topbar-search input {
width: 0;
padding: 0;
opacity: 0;
pointer-events: none;
transition: width var(--transition), opacity var(--transition);
}
.topbar-search.is-open,
.topbar-search:focus-within {
padding-right: var(--sp-2);
border: 1px solid var(--hairline);
background: var(--surface-glass-strong);
}
.topbar-search.is-open input,
.topbar-search:focus-within input {
width: min(9rem, 34vw);
opacity: 1;
pointer-events: auto;
}
}
/* ── Constrained desktop ────────────────────────────────────────────────── */
@media (max-width: 1220px) and (min-width: 901px) {
/* The nav needs 917px on one line. Below the width where it still fits beside
the brand and the collapsed cluster it takes a row of its own, which reads
better than the scroll that would otherwise kick in. */
@media (max-width: 1270px) and (min-width: 901px) {
.topbar {
flex-wrap: wrap;
}
@@ -320,43 +459,6 @@ body.chat-open {
}
.topbar-search {
padding: 0;
border: 0;
background: transparent;
overflow: hidden;
}
.topbar-search-icon {
display: none;
}
.mobile-search-toggle {
display: grid;
}
.topbar-search input {
width: 0;
padding: 0;
opacity: 0;
pointer-events: none;
transition: width var(--transition), opacity var(--transition);
}
.topbar-search.is-open,
.topbar-search:focus-within {
padding-right: var(--sp-2);
border: 1px solid var(--hairline);
background: var(--surface-glass-strong);
}
.topbar-search.is-open input,
.topbar-search:focus-within input {
width: min(9rem, 34vw);
opacity: 1;
pointer-events: auto;
}
.main {
padding: var(--sp-4);
}
+4
View File
@@ -41,6 +41,8 @@
/* ── Dark (default) ─────────────────────────────────────────────────────── */
[data-theme="dark"] {
color-scheme: dark;
--bg: #0d1014;
--bg-raised: #141920;
--surface: #171d25;
@@ -88,6 +90,8 @@
/* ── Light ──────────────────────────────────────────────────────────────── */
[data-theme="light"] {
color-scheme: light;
--bg: #f6f8fb;
--bg-raised: #ffffff;
--surface: #ffffff;
+30
View File
@@ -0,0 +1,30 @@
// Live activity's detail column.
//
// The daemon puts whatever a stage produced into an event's detail, so the
// column holds anything from "session-memory" to a few thousand characters of
// agent transcript. Printed raw, one agent_finish row was taller than six
// viewports and the table stopped being scannable (archie-core-qo7f).
//
// The rule is one line in the cell, the whole payload still available. The cut
// happens here rather than in CSS because the row also needs to know whether
// there is more to show.
// Long enough for a useful parked reason, short enough that every row is the
// same height at the widths the table is used at.
const CELL_LIMIT = 160;
/**
* activityDetail returns `{ text, full, truncated }` for one event:
* `text` is the single line the cell renders, `full` the untouched payload,
* and `truncated` whether the two differ.
*/
export function activityDetail(event) {
const full = String(event?.detail || event?.message || "");
if (!full) return { text: "", full: "", truncated: false };
// The first line that says something: agent output often opens with blanks.
const firstLine = full.split("\n").map((line) => line.trim()).find(Boolean) || "";
const clipped = firstLine.length > CELL_LIMIT ? `${firstLine.slice(0, CELL_LIMIT).trimEnd()}…` : firstLine;
return { text: clipped, full, truncated: clipped !== full };
}
+15
View File
@@ -411,3 +411,18 @@
background: var(--warn-soft);
filter: brightness(1.1);
}
/* Live activity's detail column. activity-detail.js already cuts the payload
to one line; this stops a long unbroken token (a path, a URL, a hash) from
widening the column past the table and keeps every row the same height. */
.activity-detail {
max-width: 0;
width: 55%;
}
.activity-detail span {
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
+5 -1
View File
@@ -6,6 +6,7 @@ import { ago, compact } from "../base/format.jsx";
import { statusKind } from "../base/task-meta.jsx";
import { StatTile } from "../base/statTile.jsx";
import { Gauge, SegmentBar } from "../base/gauge.jsx";
import { activityDetail } from "./activity-detail.js";
import { Icon } from "../base/icons.jsx";
import { Pill } from "../base/pill.jsx";
import { dismissSetupComplete, setupPanelState } from "./setup-preference.jsx";
@@ -401,6 +402,7 @@ function DashboardApp() {
activity.map((event, i) => {
const taskID = taskIDForEvent(event, taskIDsBySource);
const hasTask = taskID > 0;
const detail = activityDetail(event);
const openTask = () => {
if (hasTask) location.hash = `#/tasks?task=${encodeURIComponent(taskID)}`;
};
@@ -423,7 +425,9 @@ function DashboardApp() {
<span>{event.kind || event.type || "event"}</span>
</td>
<td className="mono">{hasTask ? `#${taskID}` : "—"}</td>
<td>{event.detail || event.message || ""}</td>
<td className="activity-detail">
<span title={detail.truncated ? detail.full : undefined}>{detail.text}</span>
</td>
<td>{ago(event.at || Date.now())}</td>
</tr>
);
+92 -68
View File
@@ -1,5 +1,5 @@
import "./css/_main.css";
import { h, render } from "preact";
import { Fragment, h, render } from "preact";
import { useCallback, useEffect, useRef, useState } from "preact/hooks";
import { api } from "./base/api.jsx";
import { hiddenRoutes } from "./capabilities.jsx";
@@ -17,7 +17,7 @@ import { logsPage } from "./logs/logs.jsx";
import { capturesPage } from "./captures/captures.jsx";
import { mappingsPage } from "./mappings/mappings.jsx";
import { bindingsPage } from "./bindings/bindings.jsx";
import { ChatPage } from "./chat/chat.jsx";
import { ChatApp } from "./chat/chat.jsx";
import { matchRoute, navPath } from "./routing.jsx";
/**
@@ -44,7 +44,6 @@ import { matchRoute, navPath } from "./routing.jsx";
// :name -- one captured path segment, e.g. /tasks/:id
const routes = [
{ path: "/", label: "Dashboard", icon: "dashboard", view: dashboardPage },
{ path: "/chat", label: "Chat", icon: "chat", view: ChatPage, section: "chat" },
{ path: "/tasks", label: "Tasks", icon: "tasks", view: tasksPage },
{ path: "/tasks/:id", label: "Task run", view: taskDetailPage, nav: false, navPath: "/tasks" },
{ path: "/logs", label: "Logs", icon: "logs", view: logsPage, section: "logs" },
@@ -75,7 +74,7 @@ function navEntries(hidden) {
return routes.filter((route) => route.nav !== false && !hidden.includes(route.path));
}
function Topbar({ activePath, hidden, onNavigate, chatOpen, onToggleChat, theme, onToggleTheme }) {
function Topbar({ activePath, hidden, onNavigate, theme, onToggleTheme }) {
const [searchOpen, setSearchOpen] = useState(false);
const searchRef = useRef(null);
@@ -159,15 +158,6 @@ function Topbar({ activePath, hidden, onNavigate, chatOpen, onToggleChat, theme,
onKeyDown={onSearchKeyDown}
/>
</div>
<button
className="icon-btn icon-btn-chat"
aria-label="Open chat"
title="Chat with Archie"
aria-expanded={chatOpen ? "true" : "false"}
onClick={() => onToggleChat()}
>
<Icon name="chat" />
</button>
<button className="icon-btn" title="Documentation" aria-label="Documentation">
<Icon name="help" />
</button>
@@ -187,26 +177,80 @@ function Topbar({ activePath, hidden, onNavigate, chatOpen, onToggleChat, theme,
);
}
// The chat drawer lives beside the outlet, mounted once. It is closed by
// default and opened from the topbar launcher; because it is a slide-over
// rather than a route, the operator can talk to Archie from any page without
// leaving the work that prompted the question. It hosts a single ChatPage
// instance, so session state and the stream survive navigation and are not
// duplicated per page.
function ChatDrawer({ open, onClose }) {
// Chat is a floating launcher and the panel it opens, mounted once beside the
// outlet. It is not a route: the operator asks Archie about the page they are
// already on, so navigating must not close it and opening must not replace the
// work that prompted the question.
//
// The panel anchors to the launcher and opens leftward from it, sharing its
// bottom edge, so the button stays put and reads as the thing the panel came
// out of. Nothing is dimmed and the page keeps scrolling: this is a companion
// to the work, not a modal over it.
//
// It hosts a single ChatApp instance, so session state and the stream survive
// navigation rather than being rebuilt per page.
const CHAT_PANEL_ID = "chat-panel";
function ChatLauncher() {
const [open, setOpen] = useState(false);
const fabRef = useRef(null);
const close = useCallback(() => {
setOpen(false);
// Focus goes back to the control that opened the panel; otherwise a
// keyboard user who dismisses it lands at the top of the document.
fabRef.current?.focus();
}, []);
useEffect(() => {
if (!open) return undefined;
const onKeyDown = (event) => {
// A focused control (the composer dismissing its command menu, or the
// topbar search) already handled Escape via preventDefault; closing the
// panel too would make that menu impossible to dismiss on its own.
if (event.defaultPrevented || event.key !== "Escape") return;
close();
};
document.addEventListener("keydown", onKeyDown);
return () => document.removeEventListener("keydown", onKeyDown);
}, [open, close]);
return (
<aside className={`chat-drawer${open ? " is-open" : ""}`} aria-label="Chat with Archie">
<div className="chat-drawer-panel">
<div className="chat-drawer-head">
<strong>Archie</strong>
<button className="icon-btn chat-drawer-close" aria-label="Close chat" title="Close chat" onClick={onClose}>
<Icon name="close" />
</button>
<div className={`chat-dock${open ? " is-open" : ""}`}>
<aside
className={`chat-drawer${open ? " is-open" : ""}`}
id={CHAT_PANEL_ID}
aria-label="Chat with Archie"
aria-hidden={open ? undefined : "true"}
>
<div className="chat-drawer-panel">
<div className="chat-drawer-head">
<strong>Archie</strong>
<button className="icon-btn chat-drawer-close" aria-label="Close chat" title="Close chat" onClick={close}>
<Icon name="close" />
</button>
</div>
<ChatApp />
</div>
<ChatPage />
</div>
<div className="chat-scrim" onClick={onClose} />
</aside>
</aside>
<button
ref={fabRef}
type="button"
className="chat-fab"
aria-label={open ? "Close chat" : "Chat with Archie"}
title={open ? "Close chat" : "Chat with Archie"}
aria-expanded={open ? "true" : "false"}
aria-controls={CHAT_PANEL_ID}
onClick={() => (open ? close() : setOpen(true))}
>
<span className="chat-fab-icon chat-fab-icon-open" aria-hidden="true">
<Icon name="chat" size={22} />
</span>
<span className="chat-fab-icon chat-fab-icon-close" aria-hidden="true">
<Icon name="close" size={22} />
</span>
</button>
</div>
);
}
@@ -264,13 +308,6 @@ function renderRoute(rawPath) {
const route = match?.route || routes[0];
const params = match?.params || {};
// The chat is a drawer, not a page: /chat opens it rather than mounting a
// second ChatPage (which would duplicate session state and the stream).
if (route.path === "/chat") {
render(null, outlet);
return;
}
// The key covers the path and its parameters, but NOT the query: the query
// string is an entry state, so a navigation that only changes the query of
// the page already mounted keeps the operator's own filter selection.
@@ -302,9 +339,6 @@ function show(rawPath) {
// Tasks stays current on #/tasks/42 instead of every item losing it.
chrome?.setActive(navPath(route));
// The chat is a drawer, not a page: /chat opens it rather than mounting a
// second ChatPage (which would duplicate session state and the stream).
chrome?.setChatOpen(route.path === "/chat");
renderRoute(rawPath);
}
@@ -314,35 +348,22 @@ function navigate(next) {
}
window.addEventListener("hashchange", () => show(location.hash.slice(1) || "/"));
window.addEventListener("keydown", (event) => {
// A focused control (the composer dismissing its command menu, or the topbar
// search) already handled Escape via preventDefault; closing the drawer too
// would make the menu impossible to dismiss alone.
if (event.defaultPrevented) return;
if (event.key === "Escape") chrome?.setChatOpen(false);
});
function App() {
const [active, setActive] = useState("/");
const [theme, setTheme] = useState(currentTheme);
const [chatOpen, setChatOpen] = useState(false);
const [hidden, setHidden] = useState([]);
// Publishes the router's handles. A callback ref runs at commit time, so a
// hashchange that lands right after the first paint already finds them.
const publish = useCallback((element) => {
outlet = element;
chrome = { setActive, setChatOpen };
chrome = { setActive };
}, []);
useEffect(() => {
applyTheme(theme);
}, [theme]);
useEffect(() => {
document.body.classList.toggle("chat-open", chatOpen);
}, [chatOpen]);
// Asked for once, after the shell is up: the nav renders immediately and
// loses the entries this process cannot back a moment later, rather than
// holding the whole page behind one request.
@@ -368,19 +389,22 @@ function App() {
}, []);
return (
<div className="shell">
<Topbar
activePath={active}
hidden={hidden}
onNavigate={navigate}
chatOpen={chatOpen}
onToggleChat={() => setChatOpen((open) => !open)}
theme={theme}
onToggleTheme={() => setTheme((current) => (current === "dark" ? "light" : "dark"))}
/>
<main className="main" ref={publish} />
<ChatDrawer open={chatOpen} onClose={() => setChatOpen(false)} />
</div>
<Fragment>
<div className="shell">
<Topbar
activePath={active}
hidden={hidden}
onNavigate={navigate}
theme={theme}
onToggleTheme={() => setTheme((current) => (current === "dark" ? "light" : "dark"))}
/>
<main className="main" ref={publish} />
</div>
{/* Outside .shell on purpose: its backdrop-filter is a containing block
for fixed positioning, so a launcher nested inside would anchor to the
scrolling shell and ride off the bottom of a long page. */}
<ChatLauncher />
</Fragment>
);
}
+43
View File
@@ -0,0 +1,43 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { activityDetail } from "../src/dashboard/activity-detail.js";
// Live activity renders whatever the daemon put in an event's detail. An
// agent_finish payload is a few thousand characters of transcript, and printed
// raw it turned one table row into six viewports (archie-core-qo7f). The cell
// shows a single scannable line; the full text stays reachable, never silently
// dropped.
test("a short detail is shown as-is and needs no expansion", () => {
assert.deepEqual(activityDetail({ detail: "session-memory" }), {
text: "session-memory",
full: "session-memory",
truncated: false,
});
});
test("a long detail is cut to one line and keeps the full text", () => {
const long = "x".repeat(5000);
const result = activityDetail({ detail: long });
assert.equal(result.truncated, true);
assert.ok(result.text.length < 200, `cell text is still ${result.text.length} chars`);
assert.equal(result.full, long, "full payload was dropped rather than kept");
});
test("a multi-line detail collapses to its first meaningful line", () => {
const result = activityDetail({
detail: "stage fix: agent parked (gate_parked):\n[golangci-lint] run ./...\nlevel=warning msg=deprecated",
});
assert.equal(result.text, "stage fix: agent parked (gate_parked):");
assert.equal(result.truncated, true);
});
test("leading blank lines do not produce an empty cell", () => {
assert.equal(activityDetail({ detail: "\n\n real content\nmore" }).text, "real content");
});
test("message is used when detail is absent, and absence is not an error", () => {
assert.equal(activityDetail({ message: "fallback" }).text, "fallback");
assert.deepEqual(activityDetail({}), { text: "", full: "", truncated: false });
assert.deepEqual(activityDetail(undefined), { text: "", full: "", truncated: false });
});
+53 -11
View File
@@ -1,25 +1,67 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { render, cleanup } from "@testing-library/preact";
import { render } from "@testing-library/preact";
import { ChatApp } from "../src/chat/chat.jsx";
test("ChatApp renders structure with topbar, sidebar, transcript and composer", () => {
// ChatApp lives in a ~440px panel hung off the launcher, never on a page of its
// own. These tests hold that shape: one column, no page furniture, and the
// controls that are not conversation kept out of the reading area
// (archie-core-hesx).
test("the panel is a single column: no page title, no persistent sidebar", () => {
const { container, unmount } = render(<ChatApp />);
assert.equal(container.querySelector(".chat-topbar"), null, "page topbar should be gone");
assert.equal(container.querySelector(".chat-kicker"), null, "ARCHIE WORKSPACE kicker should be gone");
assert.equal(container.querySelector(".page-title"), null, "the panel header already names Archie");
assert.equal(container.querySelector(".chat-sidebar"), null, "conversations should not hold a column");
unmount();
});
test("the transcript and composer are the panel's own rows", () => {
const { container, unmount } = render(<ChatApp />);
assert.ok(container.querySelector(".chat-topbar"), "topbar should render");
assert.ok(container.querySelector(".chat-sidebar"), "sidebar should render");
assert.ok(container.querySelector(".chat-transcript"), "transcript should render");
assert.ok(container.querySelector(".chat-composer"), "composer textarea should render");
assert.ok(container.querySelector(".chat-sidebar button"), "+ New chat button should exist");
assert.ok(container.querySelector(".chat-composer"), "composer should render");
unmount();
});
test("ChatApp renders empty state with prompt chips when messages are empty", () => {
test("conversations are a switcher in the bar, not a column", () => {
const { container, unmount } = render(<ChatApp />);
const emptyState = container.querySelector(".chat-empty-state");
assert.ok(emptyState, "empty state should be present");
const prompts = container.querySelectorAll(".chat-prompt");
assert.ok(prompts.length >= 3, "should have prompt buttons");
const bar = container.querySelector(".chat-bar");
assert.ok(bar, "compact bar should render");
assert.ok(bar.querySelector(".chat-session-switch"), "session switcher should live in the bar");
assert.ok(bar.querySelector(".chat-new"), "new chat should live in the bar");
unmount();
});
test("model controls are behind one settings affordance, not laid out inline", () => {
const { container, unmount } = render(<ChatApp />);
const settings = container.querySelector(".chat-settings");
assert.ok(settings, "settings popover should render");
assert.ok(settings.querySelector('[aria-label="Personality"]'), "personality lives in the popover");
assert.ok(settings.querySelector('[aria-label="Model"]'), "model lives in the popover");
// Closed by default: a 440px panel cannot spend its width on three selects.
assert.equal(settings.tagName, "DETAILS");
assert.equal(settings.hasAttribute("open"), false);
unmount();
});
test("operator panels are not rendered in the chat panel", () => {
const { container, unmount } = render(<ChatApp />);
assert.equal(container.querySelector(".chat-update-panel"), null, "update panel belongs to Configuration");
assert.equal(container.querySelector(".chat-dangerous-panel"), null, "dangerous actions belong to Configuration");
unmount();
});
test("the empty state still offers its prompts", () => {
const { container, unmount } = render(<ChatApp />);
assert.ok(container.querySelector(".chat-empty-state"), "empty state should be present");
assert.ok(container.querySelectorAll(".chat-prompt").length >= 3, "should have prompt buttons");
unmount();
});
+89
View File
@@ -0,0 +1,89 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { waitFor } from "@testing-library/preact";
// The chat is a FAB-opened panel, not a route. These tests hold that shape:
// there is exactly one way in (the floating button), the panel anchors beside
// it rather than filling the right edge, and `#/chat` is not a destination.
//
// main.jsx starts on import and cannot be imported twice, so this file drives
// the same live app the routing test does.
globalThis.fetch = async () => {
throw new Error("no daemon in this test");
};
class InertEventSource {
close() {}
}
globalThis.EventSource = InertEventSource;
const fab = () => document.querySelector(".chat-fab");
const drawer = () => document.querySelector(".chat-drawer");
async function settle() {
await new Promise((resolve) => setTimeout(resolve, 0));
}
test("chat is reachable only from the floating button", async (t) => {
document.body.innerHTML = '<div id="app"></div>';
location.hash = "#/";
await import("../src/main.jsx");
await waitFor(() => assert.ok(document.querySelector(".topbar")));
await t.test("the nav has no Chat entry", () => {
const labels = [...document.querySelectorAll("a.nav-item .nav-label")].map((el) => el.textContent);
assert.ok(!labels.includes("Chat"), `nav still offers Chat: ${labels.join(", ")}`);
assert.equal(document.querySelector('a.nav-item[href="#/chat"]'), null);
});
await t.test("the topbar has no chat icon button", () => {
assert.equal(document.querySelector(".topbar .icon-btn-chat"), null);
});
await t.test("the floating button is present and announces its state", () => {
assert.ok(fab(), "no .chat-fab rendered");
assert.equal(fab().getAttribute("aria-expanded"), "false");
assert.ok(fab().getAttribute("aria-controls"), "FAB does not point at the panel it opens");
});
});
test("the floating button opens and closes the panel", async () => {
assert.ok(fab(), "no .chat-fab rendered");
assert.ok(!drawer().classList.contains("is-open"));
fab().click();
await waitFor(() => assert.ok(drawer().classList.contains("is-open")));
assert.equal(fab().getAttribute("aria-expanded"), "true");
// The panel it controls is the one that actually opened.
assert.equal(document.getElementById(fab().getAttribute("aria-controls")), drawer());
fab().click();
await waitFor(() => assert.ok(!drawer().classList.contains("is-open")));
assert.equal(fab().getAttribute("aria-expanded"), "false");
});
test("Escape closes the panel and returns focus to the button", async () => {
fab().click();
await waitFor(() => assert.ok(drawer().classList.contains("is-open")));
// The class lands with the render, but the effect that binds Escape runs
// after paint. Pressing the key on each retry means the test waits for the
// binding rather than for a guessed number of milliseconds.
await waitFor(() => {
document.dispatchEvent(new window.KeyboardEvent("keydown", { key: "Escape", bubbles: true }));
assert.ok(!drawer().classList.contains("is-open"));
});
assert.equal(document.activeElement, fab(), "focus was not returned to the launcher");
});
test("#/chat is not a route and does not blank the page", async () => {
location.hash = "#/chat";
await settle();
await waitFor(() => {
const main = document.querySelector(".main");
assert.ok(main && main.textContent.trim().length > 0, "#/chat rendered an empty page");
});
// It resolves to the dashboard rather than to a chat page.
assert.equal(document.querySelector('a.nav-item[href="#/"]')?.getAttribute("aria-current"), "page");
});