fix(webui): make the chat panel behave like a chat window
Remediation from testing the launcher (archie-core-ifay), plus the morph Sam
asked for.
The panel grows out of the launcher rather than fading in beside it: closed, it
is collapsed to a pill the size of the button and translated over it; open, it
is the full panel. Scale, border-radius and position interpolate together, and
the contents fade in once the shape has mostly arrived, so the button reads as
becoming the panel. The launcher stays visible throughout and is the only
control that opens and closes it, so the panel carries no close button.
- Header shows the open conversation's name; ChatApp owns the header now,
because the title and the actions that change it belong to the same
component.
- New chat became the Lucide message-circle-plus glyph and moved into the
header. Added to the icon set, which is the same 24-grid stroke system.
- The commands accordion is gone. The composer's slash palette was already
the command surface and floats above the input; having both was two
answers to one question.
- Arrow keys scroll the palette so the selection stays visible. The decision
is pure arithmetic in command-scroll.js, including the case of an option
taller than the list, which aligns to its top so the command name is not
the part scrolled out of sight.
- The settings popover closes on any pointerdown or focus outside it.
- Stop renders only while a reply is streaming.
- The composer keeps focus and stays writeable during a send, so the next
message can be typed while one streams. It was `disabled`, which also made
the focus() in the send's finally block a silent no-op. sendMessage already
refuses a second concurrent turn via isSendingRef.
- Composer actions sit at the right of the input row, the resize handle is
gone, and the Enter/Shift+Enter hint is removed.
- Message bubbles dropped their "Archie"/"You" labels; side and colour
already say who spoke.
- Fixed an empty band under the composer: the panel still declared two grid
rows from when the launcher owned the header.
This commit is contained in:
12 files changed
+278
-77
No files matched your search
Vendored
+1
-1
@@ -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]{--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
|
||||
: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
|
||||
Vendored
+9
-9
@@ -1,10 +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,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(`
|
||||
(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&&z(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 Ae=class extends Error{constructor(e,t){super(e),this.status=t}};function je(e){let t=e instanceof Ae?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 Me(e,t){let n=await fetch(e,t);if(!n.ok)throw new Ae(await ke(n),n.status);return n}async function K(e,{method:t=`GET`,body:n,timeoutMs:r=De,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 Me(e,o);return i?s.json():void 0}var q={summary:()=>K(`/api/summary`),tasks:()=>K(`/api/tasks`),taskMeta:()=>K(`/api/task-meta`),task:e=>K(`/api/tasks/${e}`),taskAttempts:e=>K(`/api/tasks/${e}/attempts`),taskChanges:(e,t)=>K(`/api/tasks/${e}/changes`+Oe(t)),taskDebug:(e,t)=>K(`/api/tasks/${e}/debug`+Oe(t)),taskAction:(e,t)=>K(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>K(`/api/setup`),capabilities:()=>K(`/api/capabilities`),workflows:()=>K(`/api/workflows`),workRequest:e=>K(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>K(`/api/skills`),channels:()=>K(`/api/channels`),curators:()=>K(`/api/curators`),channelReload:e=>K(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>K(`/api/config`),version:()=>K(`/api/version`),configUpdate:e=>K(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>K(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>K(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>K(`/api/logs`+Oe(e)),taskLogs:(e,t)=>K(`/api/tasks/${e}/logs`+Oe(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>K(`/api/captures`+Oe({limit:e})),mappings:()=>K(`/api/mappings`),mappingCreate:e=>K(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>K(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>K(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>K(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>K(`/api/bindings`),bindingCreate:e=>K(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>K(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>K(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>K(`/api/bindings/${e}/approve`,{method:`POST`}),chatSessions:()=>K(`/api/chat/sessions`),chatMessages:e=>K(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>K(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>K(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>K(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:Ee(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>K(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>K(`/api/chat/update`),chatUpdateDefer:e=>K(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>K(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>K(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>K(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>K(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>Me(`/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 Ne(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 Pe(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 Fe(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var Ie=[{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`}],Le=[{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 J(`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 J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`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]=U([]),[n,r]=U(`connecting`),[i,a]=U(`idle`),[o,s]=U(new Map),[c,l]=U(null),[u,d]=U(null),[f,p]=U(null),[m,h]=U(null),[g,_]=U(null),[,v]=U(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([q.summary(),q.setup().catch(()=>null),q.workflows().catch(()=>null),q.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))}};W(()=>(y(),Ne(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=J(`button`,{className:`btn btn-primary`,onClick:y,children:[J(Y,{name:`refresh`,size:15}),` Retry`]});else if(m!==null){let e=st(m),t=e.attention.count,n=e.running.count;C=J(S,{children:[t>0&&J(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[J(Y,{name:`tasks`,size:15}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&J(`a`,{className:`btn`,href:e.running.href,children:[J(Y,{name:`workflows`,size:15}),` `,n,` running`]}),J(`a`,{className:`btn`,href:`#/logs`,children:[J(Y,{name:`logs`,size:15}),` Logs`]}),J(`button`,{className:`btn btn-primary`,onClick:y,children:[J(Y,{name:`refresh`,size:15}),` Refresh`]})]})}let w=null;if(g)w=J(`div`,{className:`card`,children:J(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=J(S,{children:[J(Z,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),J(Z,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),J(Z,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),J(Z,{label:`Tokens used`,value:Ze(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=J(`div`,{className:`card setup`,children:[J(`div`,{className:`card-head`,children:[J(`div`,{children:[J(`h2`,{className:`card-title`,children:`Finish setting up`}),J(`p`,{className:`card-sub`,children:`Archie needs these before it can work on its own.`})]}),J(`span`,{className:`setup-pct`,children:[t,`%`]})]}),J(`div`,{className:`setup-bar`,children:J(`div`,{className:`setup-bar-fill`,style:{width:`${t}%`}})}),J(`ul`,{className:`setup-list`,children:u.steps.map((e,t)=>J(`li`,{className:`setup-step ${e.done?`done`:``}`,children:[J(`span`,{className:`setup-check`,children:e.done?J(Y,{name:`check`,size:12}):``}),J(`div`,{children:[J(`div`,{className:`setup-step-title`,children:e.title}),e.detail&&J(`div`,{className:`setup-step-detail`,children:e.detail})]})]},t))})]})}else T=J(`div`,{className:`card setup setup-done`,children:J(`div`,{className:`card-head`,children:[J(`div`,{children:[J(`h2`,{className:`card-title`,children:`Setup complete`}),J(`p`,{className:`card-sub`,children:`Archie is configured and ready to work.`})]}),J(`div`,{className:`setup-complete-actions`,children:[J(`span`,{className:`setup-pct`,children:J(Y,{name:`check`,size:16})}),J(`button`,{className:`icon-btn setup-dismiss`,type:`Line truncated
|
||||
`),children:[J(`td`,{className:`strong`,children:e.label||e.id}),J(`td`,{className:`mono`,children:e.install_type||`—`}),J(`td`,{className:`mono`,children:e.running_version||`—`}),J(`td`,{className:`mono`,children:e.latest_available||`—`}),J(`td`,{children:J(Q,{text:Zn[e.status]||e.status,kind:Qn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function $({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function er({title:e,sub:t,children:n}){return J(`div`,{className:`card cfg-section`,children:[J(`div`,{className:`card-head`,children:J(`div`,{children:[J(`h2`,{className:`card-title`,children:e}),J(`p`,{className:`card-sub`,children:t})]})}),n]})}function tr({origins:e}){return e?.length?J(er,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:J(`div`,{className:`kv-list`,children:e.map((e,t)=>J(qn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):J(er,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:J($,{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 J(er,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:J($,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return J(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:[J(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?J(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??We(e.id),n=e.kind??Ge(e.id);return J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,children:e.id}),J(`span`,{className:`kv-value`,children:J(Q,{text:t,kind:n})})]},e.id)})}):J($,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),J(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?J(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=nr(e.kind);return J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,children:e.id}),J(`span`,{className:`kv-value`,children:J(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):J($,{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]=U(!1),[o,s]=U(null),[c,l]=U(!!e[t]);return r?J(`td`,{children:[J(`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 q.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){l(!i),s(String(e.message||e))}finally{a(!1)}},disabled:i}),o&&J(`span`,{className:`kv-note is-error`,children:o})]}):J(`td`,{children:c?`yes`:`no`})}function ar({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=U(String(e[t]??0)),[o,s]=U(null),[c,l]=U(!1);return r?J(`td`,{children:[J(`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 q.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&&J(`span`,{className:`kv-note is-error`,children:o})]}):J(`td`,{className:`mono`,children:i})}function or({repos:e,onSaved:t,editable:n=!0}){if(!e?.length)return J(er,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:J($,{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 J(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:J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Repository`}),J(`th`,{children:`Base branch`}),J(`th`,{children:`Ecosystem`}),J(`th`,{children:`Quality gate`}),J(`th`,{children:`Protected paths`}),J(`th`,{children:`Concurrent`}),J(`th`,{children:`Max retries`}),J(`th`,{children:`Self-review`})]})}),J(`tbody`,{children:e.map((e,i)=>J(`tr`,{children:[J(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),J(`td`,{className:`mono`,children:e.base}),J(`td`,{children:e.ecosystem||`go`}),J(`td`,{className:`mono`,children:r(e.gate)}),J(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),J(ir,{r:e,field:`alloLine truncated
|
||||
`),i=[],a=null,o=null,s=0,c=()=>{i.length&&(n.push(J(`p`,{children:Hr(i.join(` `))},s++)),i=[])},l=()=>{if(!a)return;let e=a.items.map((e,t)=>J(`li`,{children:Hr(e)},t));n.push(a.tag===`ol`?J(`ol`,{children:e},s++):J(`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(J(`pre`,{children:J(`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(J(`table`,{children:[J(`thead`,{children:J(`tr`,{children:u.map((e,t)=>J(`th`,{children:Hr(e)},t))})}),J(`tbody`,{children:t.map((e,t)=>J(`tr`,{children:e.map((e,t)=>J(`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(J(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(J(`blockquote`,{children:Hr(t.replace(/^>\s?/,``))},s++));continue}i.push(t)}return c(),l(),o&&n.push(J(`pre`,{children:J(`code`,{children:o.join(`
|
||||
`)})},s++)),J(`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=Ee(),localStorage.setItem(Kr,e)),e}function Jr(e){return{text:e,sourceID:Ee()}}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({scrollTop:e,viewportHeight:t,optionTop:n,optionHeight:r}){if(r>=t||n<e)return n;let i=n+r;return i>e+t?i-t:e}function Qr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function $r(e,t){if(!t)return`Archie`;let n=(e||[]).find(e=>e.session_id===t);return n?Qr(n):`Archie`}function ei(){return location.hash.slice(1)||`/`}function ti({open:e=!0}){let[t,n]=U([]),[r,i]=U(``),[a,o]=U([]),[s,c]=U(``),[l,u]=U(`Ready`),[d,f]=U(!1),[p,m]=U({}),[h,g]=U(``),[_,v]=U(``),[y,b]=U(``),[x,C]=U([]),[w,T]=U([]),[E,D]=U(0),[O,k]=U(!1),[A,j]=U(null),M=G(null),N=G(null),P=G(null),F=G(null),I=G(null),L=G(null),ee=G(d);ee.current=d,W(()=>{let e=e=>{let t=L.current;t?.open&&(e.target instanceof Node&&t.contains(e.target)||(t.open=!1))};return document.addEventListener(`pointerdown`,e),document.addEventListener(`focusin`,e),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`focusin`,e)}},[]),W(()=>{e&&N.current?.focus()},[e]),W(()=>{if(!O)return;let e=I.current,t=e?.children?.[E];!e||!t||(e.scrollTop=Zr({scrollTop:e.scrollTop,viewportHeight:e.clientHeight,optionTop:t.offsetTop,optionHeight:t.offsetHeight}))},[E,O]),W(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight)},[a,A]),W(()=>{R().catch(e=>{u(e.message||`Chat unavailable`)});let e=()=>{P.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),P.current?.abort()}},[]);async function R(){let e=await q.chatSessions(),t=e.sessions||[];n(t),m(e),g(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;v(a),b(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);C(o),!r&&t[0]&&await te(t[0].session_id,e,t)}async function te(e,t,n){let r=t||p;i(e),o([]),j(null);let a=r.active_personas?.[e]||r.active_persona||``;g(a);try{await q.chatMessage(qr(),`/resume ${e}`);let[t,n]=await Promise.all([q.chatMessages(e),q.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});o(i)}catch(e){u(e.message||`Could not load session messages`)}}async function z(e){if(r)try{u(`Working…`);let t=await q.chatMessage(qr(),e);t.session_id&&i(t.session_id),u(t.reply||`Session updated`),await R(),(t.session_id||r)&&await te(t.session_id||r),F.current&&(F.current.open=!1)}catch(e){u(e.message||`Session action failed`)}}function ne(e,t){let n=window.prompt(t);n?.trim()&&z(`${e} ${n.trim()}`)}function re(e){let t=e.target.value;g(t),!(!r||!t)&&q.chatPersona(r,t).then(()=>{m(e=>({...e,active_personas:{...e.active_personas||{},[r]:t}})),u(`Personality: ${t}`)}).catch(e=>{u(e.message||`Failed to set personality`)})}async function ie(e){let t=e.target.value;if(v(t),t)try{let e=await q.chatMessage(qr(),`/model --provider ${t}`);u(e.reply||`Provider updated`),await R()}catch(e){u(`Provider update failed: ${e.message||e}`)}}async function B(e){let t=e.target.value;if(b(t),t)try{let e=await q.chatMessage(qr(),`/model ${t}`);u(e.reply||`Model updated`),await R()}catch(e){u(`Model update failed: ${e.message||e}`)}}function V(){c(`/new`),ce({textOverride:`/new`})}function ae(e){let t=e.target.value;c(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=x.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){T(t),D(0),k(!0);return}}k(!1),T([])}function oe(e){let t=w[e];if(!t||!N.current)return;let n=N.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]===` `),s=`${r.slice(0,o)}${t.command} ${i}`;c(s),k(!1);let l=o+t.command.length+1;setTimeout(()=>{n.focus(),n.setSelectionRange(l,l)},0)}function se(e){if(O&&w.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&w.some(e=>e.command===s.trim())){e.preventDefault(),k(!1),ce();return}if(e.key===`ArrowDown`){e.preventDefault(),D(e=>(e+1)%w.length);return}if(e.key===`ArrowUp`){e.preventDefault(),D(e=>(e+w.length-1)%w.length);return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),oe(E);return}if(e.key===`Escape`){e.preventDefault(),k(!1);re
Line truncated
|
||||
|
||||
`);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,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
|
||||
`);a=o.pop()||``;for(let e of o){let t=e.split(`
|
||||
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&i(n.session_id),n.type===`delta`&&(d+=n.text,j(e=>e?{...e,text:d}:null)),n.type===`tool`&&(l=[...l,n],j(e=>e?{...e,tools:l}:null)),n.type===`navigate`&&(l=[...l,n],j(e=>e?{...e,tools:l}:null)),n.type===`done`&&(p=!0,d||=n.text),n.type===`error`)throw Error(n.text)}if(r)break}if(!p)throw Error(`chat stream ended before completion`);o(e=>[...e,{from:`assistant`,text:d,tool_calls:l}]),j(null),u(`Ready`),await R()}catch(e){if(e.name===`AbortError`&&!m)j({text:`Turn stopped.`,tools:l,isError:!1,turn:r,isRetry:a}),u(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;j({text:t,tools:l,isError:!0,turn:Yr(r),isRetry:a}),u(`Error — retry available`)}}finally{clearTimeout(h),P.current=null,f(!1),N.current&&N.current.focus()}}function H(){u(`Stopping…`),r&&q.chatCancel(r).catch(()=>{}),P.current?.abort()}let le=p.models_by_provider||{},ue=_&&le[_]?le[_]:p.models||[];return J(`div`,{className:`chat-panel-content`,children:[J(`div`,{className:`chat-drawer-head`,children:[J(`strong`,{className:`chat-panel-title`,children:$r(t,r)}),J(`div`,{className:`chat-head-actions`,children:J(`button`,{className:`icon-btn chat-new`,type:`button`,title:`New chat`,"aria-label":`New chat`,onClick:V,children:J(Y,{name:`message-circle-plus`})})})]}),J(`div`,{className:`chat-bar`,children:[J(`label`,{className:`chat-session-switch`,children:[J(`span`,{className:`sr-only`,children:`Conversation`}),J(`select`,{value:r,onChange:e=>te(e.target.value),disabled:!t.length,children:t.length?t.map(e=>J(`option`,{value:e.session_id,children:Qr(e)},e.session_id)):J(`option`,{value:``,children:`No conversations yet`})})]}),J(`details`,{className:`chat-settings`,ref:L,children:[J(`summary`,{"aria-label":`Chat settings`,title:`Chat settings`,children:J(`span`,{"aria-hidden":`true`,children:`⚙`})}),J(`div`,{className:`chat-settings-body`,children:[J(`span`,{className:`chat-status`,children:l}),J(`label`,{children:[`Personality`,J(`select`,{className:`chat-select`,"aria-label":`Personality`,value:h,onChange:re,children:[J(`option`,{value:``,children:`Default`}),(p.personas||[]).map(e=>J(`option`,{value:e,children:e},e))]})]}),(p.providers||[]).length>0&&J(`label`,{children:[`Provider`,J(`select`,{className:`chat-select`,"aria-label":`Provider`,value:_,onChange:ie,children:[J(`option`,{value:``,children:`Default`}),(p.providers||[]).map(e=>J(`option`,{value:e,children:e},e))]})]}),J(`label`,{children:[`Model`,J(`select`,{className:`chat-select`,"aria-label":`Model`,value:y,onChange:B,children:[J(`option`,{value:``,children:`Default`}),ue.map(e=>J(`option`,{value:e,children:e},e))]})]})]})]})]}),J(`div`,{className:`chat-layout`,children:J(`section`,{className:`chat-workspace`,children:[J(`div`,{className:`chat-workspace-head`,children:J(`details`,{className:`chat-session-tools`,ref:F,hidden:!r,children:[J(`summary`,{children:`Session actions`}),J(`div`,{className:`chat-session-tool-list`,children:[J(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/retry`),children:`Retry`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/undo`),children:`Undo`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>ne(`/title`,`Session title`),children:`Rename`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>ne(`/branch`,`Branch name (optional)`),children:`Branch`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/compress --preview`),children:`Preview compression`})]})]})}),J(`div`,{className:`chat-transcript`,ref:M,children:!a.length&&!A?J(`div`,{className:`chat-empty-state`,children:[J(`span`,{className:`chat-empty-mark`,children:`A`}),J(`h2`,{children:`What are we working on?`}),J(`p`,{children:`Ask Archie anything, or start with one of these prompts.`}),J(`div`,{className:`chat-prompt-grid`,children:[J(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Summarise active tasks`),N.current?.focus()},children:`Summarise active tasks`}),J(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Show running agents`),N.current?.focus()},children:`Show running agents`}),J(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Check system status`),N.current?.focus()},children:`Check system status`})]})]}):J(S,{children:[a.map((e,t)=>{let n=e.from??e.From??``,r=e.text??e.Text??``,i=n!==`web`,a=e.tool_calls||e.ToolCalls||[];return J(`div`,{className:`chat-bubble-row ${i?`assistant`:`user`}`,children:J(`div`,{className:`chat-bubble`,children:i?J(S,{children:[a.length>0&&J(`div`,{className:`chat-tools`,children:a.map((e,t)=>{if(e.path)return J(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[J(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),J(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.Name||e.tool||`tool`,r=e.parameters||e.Parameters||``,i=e.summary||e.Summary||e.text||e.err||e.Err||`Line truncated
|
||||
@@ -32,6 +32,7 @@ const paths = {
|
||||
trendDown: '<path d="M4 7l6 6 4-4 6 6"/><path d="M14 17h6v-6"/>',
|
||||
check: '<path d="M4.5 12.5l5 5 10-11"/>',
|
||||
close: '<path d="M6 6l12 12M18 6L6 18"/>',
|
||||
"message-circle-plus": '<path d="M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719"/><path d="M8 12h8"/><path d="M12 8v8"/>',
|
||||
help: '<circle cx="12" cy="12" r="9"/><path d="M9.6 9.4a2.5 2.5 0 1 1 3.3 2.4c-.6.2-.9.8-.9 1.4v.4"/><path d="M12 17.2h.01"/>',
|
||||
};
|
||||
|
||||
|
||||
@@ -10,3 +10,14 @@
|
||||
export function sessionTitle(session) {
|
||||
return session.title || session.branch_name || `Conversation ${session.session_id.slice(0, 8)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* panelTitle names the launcher panel's header. The panel is small and the
|
||||
* session switcher sits below it, so the header says which conversation is
|
||||
* open rather than repeating the product name.
|
||||
*/
|
||||
export function panelTitle(sessions, currentSession) {
|
||||
if (!currentSession) return "Archie";
|
||||
const session = (sessions || []).find((item) => item.session_id === currentSession);
|
||||
return session ? sessionTitle(session) : "Archie";
|
||||
}
|
||||
@@ -3,7 +3,10 @@
|
||||
(archie-core-hesx). */
|
||||
.chat-panel-content {
|
||||
display: grid;
|
||||
grid-template-rows: auto minmax(0, 1fr);
|
||||
/* header, bar, then the conversation takes the rest: without the third
|
||||
track the transcript sized to its content and left the composer floating
|
||||
above dead space. */
|
||||
grid-template-rows: auto auto minmax(0, 1fr);
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
@@ -203,18 +206,17 @@
|
||||
.chat-nav-chip-icon { font-size: .8rem; line-height: 1; }
|
||||
|
||||
.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; }
|
||||
/* Text and actions share one row: the buttons sit at the right of the input,
|
||||
not on a line of their own under it. */
|
||||
.chat-composer-shell { position: relative; display: flex; align-items: flex-end; gap: var(--sp-2); padding: .7rem .8rem; background: var(--surface-hover); border: 1px solid var(--border-strong); border-radius: .9rem; }
|
||||
.chat-composer { flex: 1 1 auto; min-width: 0; min-height: 2.6rem; resize: none; box-sizing: border-box; background: transparent; color: var(--fg); border: 0; padding: .25rem 0; font: inherit; }
|
||||
.chat-composer:focus { outline: 0; }
|
||||
.chat-command-menu { position: absolute; z-index: 3; right: .8rem; bottom: calc(100% - .25rem); left: .8rem; display: grid; gap: .15rem; max-height: 18rem; overflow: auto; padding: .35rem; background: var(--surface); border: 1px solid var(--border-strong); border-radius: .7rem; box-shadow: 0 .7rem 2rem color-mix(in srgb, #000 30%, transparent); }
|
||||
.chat-command-menu[hidden] { display: none; }
|
||||
.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); }
|
||||
/* 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-compose-actions { display: flex; align-items: center; flex: none; gap: var(--sp-2); }
|
||||
.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; }
|
||||
|
||||
+56
-34
@@ -1,10 +1,12 @@
|
||||
import { h, Fragment } from "preact";
|
||||
import { useState, useEffect, useRef } from "preact/hooks";
|
||||
import { api } from "../base/api.jsx";
|
||||
import { Icon } from "../base/icons.jsx";
|
||||
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 { commandScrollTop } from "./command-scroll.js";
|
||||
import { panelTitle, sessionTitle } from "./chat-render.jsx";
|
||||
|
||||
import "./chat.css";
|
||||
|
||||
@@ -12,7 +14,7 @@ function currentPage() {
|
||||
return location.hash.slice(1) || "/";
|
||||
}
|
||||
|
||||
export function ChatApp() {
|
||||
export function ChatApp({ open = true }) {
|
||||
const [sessions, setSessions] = useState([]);
|
||||
const [currentSession, setCurrentSession] = useState("");
|
||||
const [messages, setMessages] = useState([]);
|
||||
@@ -38,9 +40,46 @@ export function ChatApp() {
|
||||
const activeControllerRef = useRef(null);
|
||||
const sessionToolsRef = useRef(null);
|
||||
const commandMenuRef = useRef(null);
|
||||
const settingsRef = useRef(null);
|
||||
const isSendingRef = useRef(isSending);
|
||||
isSendingRef.current = isSending;
|
||||
|
||||
useEffect(() => {
|
||||
const closeSettings = (event) => {
|
||||
const details = settingsRef.current;
|
||||
if (!details?.open) return;
|
||||
if (event.target instanceof Node && details.contains(event.target)) return;
|
||||
details.open = false;
|
||||
};
|
||||
document.addEventListener("pointerdown", closeSettings);
|
||||
document.addEventListener("focusin", closeSettings);
|
||||
return () => {
|
||||
document.removeEventListener("pointerdown", closeSettings);
|
||||
document.removeEventListener("focusin", closeSettings);
|
||||
};
|
||||
}, []);
|
||||
|
||||
// The panel stays mounted so the session survives navigation, so opening it
|
||||
// is a prop change rather than a mount: focus the composer on that edge.
|
||||
useEffect(() => {
|
||||
if (open) composerRef.current?.focus();
|
||||
}, [open]);
|
||||
|
||||
// Arrow keys move the palette selection; the list scrolls so the highlight
|
||||
// stays visible once the matches run past the visible rows.
|
||||
useEffect(() => {
|
||||
if (!isCommandMenuOpen) return;
|
||||
const menu = commandMenuRef.current;
|
||||
const option = menu?.children?.[commandSelection];
|
||||
if (!menu || !option) return;
|
||||
menu.scrollTop = commandScrollTop({
|
||||
scrollTop: menu.scrollTop,
|
||||
viewportHeight: menu.clientHeight,
|
||||
optionTop: option.offsetTop,
|
||||
optionHeight: option.offsetHeight,
|
||||
});
|
||||
}, [commandSelection, isCommandMenuOpen]);
|
||||
|
||||
// Auto scroll transcript to bottom on new messages or streaming tokens
|
||||
useEffect(() => {
|
||||
if (transcriptRef.current) {
|
||||
@@ -400,6 +439,15 @@ export function ChatApp() {
|
||||
|
||||
return (
|
||||
<div className="chat-panel-content">
|
||||
<div className="chat-drawer-head">
|
||||
<strong className="chat-panel-title">{panelTitle(sessions, currentSession)}</strong>
|
||||
<div className="chat-head-actions">
|
||||
<button className="icon-btn chat-new" type="button" title="New chat" aria-label="New chat" onClick={handleNewChat}>
|
||||
<Icon name="message-circle-plus" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="chat-bar">
|
||||
<label className="chat-session-switch">
|
||||
<span className="sr-only">Conversation</span>
|
||||
@@ -420,11 +468,7 @@ export function ChatApp() {
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<button className="icon-btn chat-new" type="button" title="New chat" aria-label="New chat" onClick={handleNewChat}>
|
||||
+
|
||||
</button>
|
||||
|
||||
<details className="chat-settings">
|
||||
<details className="chat-settings" ref={settingsRef}>
|
||||
<summary aria-label="Chat settings" title="Chat settings">
|
||||
<span aria-hidden="true">⚙</span>
|
||||
</summary>
|
||||
@@ -487,21 +531,6 @@ export function ChatApp() {
|
||||
<div className="chat-layout">
|
||||
<section className="chat-workspace">
|
||||
<div className="chat-workspace-head">
|
||||
<details className="chat-command-help">
|
||||
<summary>Available commands ({commandSpecs.length})</summary>
|
||||
<div className="chat-command-list">
|
||||
{!commandSpecs.length ? (
|
||||
<span>Send a message to begin.</span>
|
||||
) : (
|
||||
commandSpecs.map((spec) => (
|
||||
<div className="chat-command-item" key={spec.command}>
|
||||
<code>{spec.usage || spec.command}</code>
|
||||
<span>{spec.description || ""}</span>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</details>
|
||||
<details
|
||||
className="chat-session-tools"
|
||||
ref={sessionToolsRef}
|
||||
@@ -602,7 +631,6 @@ export function ChatApp() {
|
||||
className={`chat-bubble-row ${isAssistant ? "assistant" : "user"}`}
|
||||
>
|
||||
<div className="chat-bubble">
|
||||
<div className="chat-bubble-meta">{isAssistant ? "Archie" : "You"}</div>
|
||||
{isAssistant ? (
|
||||
<Fragment>
|
||||
{tools.length > 0 && (
|
||||
@@ -665,7 +693,6 @@ export function ChatApp() {
|
||||
{streamingTurn && (
|
||||
<div className="chat-bubble-row assistant">
|
||||
<div className="chat-bubble">
|
||||
<div className="chat-bubble-meta">Archie</div>
|
||||
{streamingTurn.tools?.length > 0 && (
|
||||
<div className="chat-tools">
|
||||
{streamingTurn.tools.map((tool, tIdx) => {
|
||||
@@ -732,7 +759,6 @@ export function ChatApp() {
|
||||
rows={3}
|
||||
placeholder="Message Archie, or type / for commands"
|
||||
aria-label="Message Archie"
|
||||
disabled={isSending}
|
||||
value={composerText}
|
||||
onInput={handleComposerInput}
|
||||
onKeyDown={handleComposerKeyDown}
|
||||
@@ -761,15 +787,11 @@ export function ChatApp() {
|
||||
</div>
|
||||
)}
|
||||
<div className="chat-compose-actions">
|
||||
<span className="chat-hint">Enter to send · Shift+Enter for a new line</span>
|
||||
<button
|
||||
className="btn"
|
||||
type="button"
|
||||
disabled={!isSending}
|
||||
onClick={handleStop}
|
||||
>
|
||||
Stop
|
||||
</button>
|
||||
{isSending && (
|
||||
<button className="btn" type="button" onClick={handleStop}>
|
||||
Stop
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
type="button"
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// Keeping the arrow-key selection visible in the command palette.
|
||||
//
|
||||
// The palette caps its height and scrolls, so once the matches run past the
|
||||
// visible rows the selection walked off-screen and the highlight was invisible
|
||||
// (archie-core-ifay). Browsers have scrollIntoView, but the decision is pure
|
||||
// arithmetic and worth testing on its own, so the effect only applies what
|
||||
// this returns.
|
||||
|
||||
/**
|
||||
* commandScrollTop returns the scrollTop that brings the selected option fully
|
||||
* into view, or the current scrollTop when it is already visible. Mirrors
|
||||
* `scrollIntoView({ block: "nearest" })`: it moves the minimum distance, and
|
||||
* scrolls up for an option above the viewport, down for one below.
|
||||
*/
|
||||
export function commandScrollTop({ scrollTop, viewportHeight, optionTop, optionHeight }) {
|
||||
// An option taller than the viewport cannot be shown whole. Align its top,
|
||||
// which holds the command itself; aligning the bottom would scroll the name
|
||||
// out of sight and leave only the tail of its description.
|
||||
if (optionHeight >= viewportHeight) return optionTop;
|
||||
|
||||
if (optionTop < scrollTop) return optionTop;
|
||||
|
||||
const optionBottom = optionTop + optionHeight;
|
||||
const viewportBottom = scrollTop + viewportHeight;
|
||||
if (optionBottom > viewportBottom) return optionBottom - viewportHeight;
|
||||
|
||||
return scrollTop;
|
||||
}
|
||||
+51
-18
@@ -281,22 +281,51 @@ body {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* The panel grows out of the launcher. Closed, it is collapsed to a small
|
||||
round shape sitting exactly over the button; open, it is the full panel
|
||||
beside it. Scaling from the bottom-right corner and translating by the
|
||||
launcher's own width is what makes the button appear to become the panel,
|
||||
rather than a panel merely fading in next to it. */
|
||||
.chat-drawer-panel {
|
||||
pointer-events: auto;
|
||||
display: grid;
|
||||
grid-template-rows: auto minmax(0, 1fr);
|
||||
/* One child: ChatApp, which owns its own header row. A second track here
|
||||
left an empty band under the composer. */
|
||||
grid-template-rows: minmax(0, 1fr);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-md);
|
||||
overflow: hidden;
|
||||
|
||||
opacity: 0;
|
||||
/* Grows out of the launcher: the origin is the corner nearest the button. */
|
||||
border-radius: var(--radius-pill);
|
||||
transform-origin: bottom right;
|
||||
transform: scale(0.92) translateX(var(--sp-3));
|
||||
transition: opacity var(--transition), transform var(--transition);
|
||||
transform: translateX(calc(var(--fab-size) + var(--fab-gap))) scale(0.16);
|
||||
transition:
|
||||
opacity 160ms cubic-bezier(0.4, 0, 0.2, 1),
|
||||
transform 260ms cubic-bezier(0.22, 1, 0.36, 1),
|
||||
border-radius 260ms cubic-bezier(0.22, 1, 0.36, 1);
|
||||
}
|
||||
|
||||
.chat-drawer.is-open .chat-drawer-panel {
|
||||
opacity: 1;
|
||||
border-radius: var(--radius-lg);
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* The contents follow the shape rather than stretching with it: they fade in
|
||||
once the panel is most of the way open, so the morph reads as a container
|
||||
opening instead of a page being scaled up. */
|
||||
.chat-drawer-panel > * {
|
||||
opacity: 0;
|
||||
transition: opacity 120ms linear;
|
||||
}
|
||||
|
||||
.chat-drawer.is-open .chat-drawer-panel > * {
|
||||
opacity: 1;
|
||||
transition: opacity 160ms linear 120ms;
|
||||
}
|
||||
|
||||
/* A closed panel is still mounted so the session and its stream survive. It
|
||||
@@ -304,12 +333,11 @@ body {
|
||||
.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;
|
||||
transition:
|
||||
opacity 140ms cubic-bezier(0.4, 0, 0.2, 1),
|
||||
transform 200ms cubic-bezier(0.4, 0, 1, 1),
|
||||
border-radius 200ms cubic-bezier(0.4, 0, 1, 1),
|
||||
visibility 0s linear 200ms;
|
||||
}
|
||||
|
||||
.chat-drawer-head {
|
||||
@@ -333,19 +361,24 @@ body {
|
||||
position: fixed;
|
||||
right: var(--fab-inset);
|
||||
left: var(--fab-inset);
|
||||
bottom: var(--fab-inset);
|
||||
/* Clears the launcher, which stays put as the close control. */
|
||||
bottom: calc(var(--fab-inset) + var(--fab-size) + var(--fab-gap));
|
||||
width: auto;
|
||||
height: min(78vh, calc(100vh - var(--fab-inset) * 2));
|
||||
height: min(72vh, calc(100vh - var(--fab-inset) * 2 - var(--fab-size) - var(--fab-gap)));
|
||||
}
|
||||
|
||||
/* The sheet sits above the launcher rather than beside it, so it grows down
|
||||
toward the button instead of sideways. */
|
||||
.chat-drawer-panel {
|
||||
transform-origin: bottom center;
|
||||
transform: scale(0.98) translateY(var(--sp-3));
|
||||
transform-origin: bottom right;
|
||||
transform: translateY(calc(var(--fab-size) + var(--fab-gap))) scale(0.16);
|
||||
}
|
||||
|
||||
.chat-dock.is-open .chat-fab {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
/* The launcher is the only way to close the panel, so it stays above the
|
||||
sheet rather than hiding under it. */
|
||||
.chat-fab {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-7
@@ -224,13 +224,10 @@ function ChatLauncher() {
|
||||
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 />
|
||||
{/* ChatApp owns the header: the title is the open conversation. It
|
||||
carries no close button -- the launcher stays visible and is the
|
||||
one control that opens and closes the panel. */}
|
||||
<ChatApp open={open} />
|
||||
</div>
|
||||
</aside>
|
||||
<button
|
||||
|
||||
@@ -32,7 +32,6 @@ test("conversations are a switcher in the bar, not a column", () => {
|
||||
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();
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { render } from "@testing-library/preact";
|
||||
import { ChatApp } from "../src/chat/chat.jsx";
|
||||
import { panelTitle } from "../src/chat/chat-render.jsx";
|
||||
|
||||
// Remediation from testing the launcher panel (archie-core-ifay): the panel
|
||||
// should read as a chat window, not as a toolbar with a transcript attached.
|
||||
|
||||
test("the header names the open conversation", () => {
|
||||
const sessions = [
|
||||
{ session_id: "abc12345", title: "Gate failures" },
|
||||
{ session_id: "def67890", branch_name: "spike/retry" },
|
||||
];
|
||||
assert.equal(panelTitle(sessions, "abc12345"), "Gate failures");
|
||||
assert.equal(panelTitle(sessions, "def67890"), "spike/retry");
|
||||
});
|
||||
|
||||
test("with no conversation open the header falls back to the product name", () => {
|
||||
assert.equal(panelTitle([], ""), "Archie");
|
||||
assert.equal(panelTitle(undefined, undefined), "Archie");
|
||||
// A session id with no matching record must not render "undefined".
|
||||
assert.equal(panelTitle([], "missing"), "Archie");
|
||||
});
|
||||
|
||||
test("the commands accordion is gone; the slash palette is the only command surface", () => {
|
||||
const { container, unmount } = render(<ChatApp />);
|
||||
assert.equal(container.querySelector(".chat-command-help"), null);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("the composer carries no keyboard hint text", () => {
|
||||
const { container, unmount } = render(<ChatApp />);
|
||||
assert.ok(
|
||||
!/Enter to send/i.test(container.textContent),
|
||||
"the Enter/Shift+Enter hint should be gone",
|
||||
);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("Stop is absent while nothing is generating", () => {
|
||||
const { container, unmount } = render(<ChatApp />);
|
||||
const labels = [...container.querySelectorAll(".chat-compose button")].map((b) => b.textContent.trim());
|
||||
assert.ok(!labels.includes("Stop"), `Stop should not render when idle: ${labels.join(", ")}`);
|
||||
assert.ok(labels.includes("Send"), "Send should still render");
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("new chat lives in the header, and the panel has no close button", () => {
|
||||
const { container, unmount } = render(<ChatApp />);
|
||||
const head = container.querySelector(".chat-drawer-head");
|
||||
assert.ok(head, "the panel owns its header");
|
||||
assert.ok(head.querySelector(".chat-new"), "new chat should sit in the header");
|
||||
assert.equal(container.querySelector(".chat-bar .chat-new"), null, "and not in the bar");
|
||||
|
||||
// The launcher stays visible and is the only control that closes the panel.
|
||||
const closers = [...container.querySelectorAll("button")].filter(
|
||||
(b) => /close/i.test(b.getAttribute("aria-label") || ""),
|
||||
);
|
||||
assert.deepEqual(closers, [], "the panel should carry no close button");
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("message bubbles carry no speaker label", () => {
|
||||
const { container, unmount } = render(<ChatApp />);
|
||||
assert.equal(container.querySelector(".chat-bubble-meta"), null);
|
||||
unmount();
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { commandScrollTop } from "../src/chat/command-scroll.js";
|
||||
|
||||
const menu = { scrollTop: 0, viewportHeight: 100 };
|
||||
|
||||
test("an option already in view does not move the list", () => {
|
||||
assert.equal(commandScrollTop({ ...menu, optionTop: 20, optionHeight: 30 }), 0);
|
||||
});
|
||||
|
||||
test("an option below the fold scrolls down by the minimum", () => {
|
||||
// Bottom at 150 against a viewport ending at 100: scroll the missing 50.
|
||||
assert.equal(commandScrollTop({ ...menu, optionTop: 120, optionHeight: 30 }), 50);
|
||||
});
|
||||
|
||||
test("an option above the fold scrolls up to its top", () => {
|
||||
assert.equal(
|
||||
commandScrollTop({ scrollTop: 200, viewportHeight: 100, optionTop: 120, optionHeight: 30 }),
|
||||
120,
|
||||
);
|
||||
});
|
||||
|
||||
test("wrapping from the last option back to the first returns to the top", () => {
|
||||
assert.equal(
|
||||
commandScrollTop({ scrollTop: 400, viewportHeight: 100, optionTop: 0, optionHeight: 30 }),
|
||||
0,
|
||||
);
|
||||
});
|
||||
|
||||
test("wrapping from the first option to the last scrolls to the end", () => {
|
||||
assert.equal(
|
||||
commandScrollTop({ scrollTop: 0, viewportHeight: 100, optionTop: 470, optionHeight: 30 }),
|
||||
400,
|
||||
);
|
||||
});
|
||||
|
||||
test("an option taller than the viewport aligns to its top edge", () => {
|
||||
// Scrolling to its bottom would hide the command name; the top is what matters.
|
||||
assert.equal(commandScrollTop({ ...menu, optionTop: 40, optionHeight: 300 }), 40);
|
||||
});
|
||||
Reference in new issue
Block a user