fix(webui): rebuild the Configuration page layout so values stop colliding

The page had three compounding layout faults, all visible on a wide
screen and all still present after the earlier spacing pass:

  1. .cfg-row used justify-content: space-between on a full-width card,
     so the label sat at the far left and its value at the far right with
     roughly a thousand pixels between them. Reading one pair meant
     tracking across the viewport. The earlier "tighten KV row spacing"
     change reduced vertical padding only, which is why the complaint it
     was meant to answer survived it.
  2. .cfg-value had no min-width: 0, so a long value could not shrink
     inside its flex parent. It overflowed into the Edit button, which is
     why 400 rendered as "40" and 100000000 was clipped mid-number.
  3. The locked-row reason was a flex sibling of that overflowing value,
     so it ran onto the end of the path with no separation, rendering
     ".../archie/work" and "pins the daemon's working layout" as one
     unbroken string.

Replace the flex row with a three-column grid: label, value, actions.
Label and value are adjacent and left-aligned so the eye travels a fixed
short distance at any viewport width; the value column is minmax(0, 1fr)
so it can actually shrink, truncating with an ellipsis and keeping the
full text in a title attribute; actions occupy a reserved column that
nothing can overlap. Secondary text (locked reason, override marker,
validation error) gets its own grid row instead of sharing the value
line. Narrow viewports stack label over value rather than truncating
both to a few characters.

Extract the row renderer into settings/config-row.js. settings.js
imports its own stylesheet, which the node test shim cannot parse, so
the rendering logic was untestable where it sat; this mirrors
tasks/task-row.js. Seven tests now cover the two collision bugs
structurally, asserting on per-child text rather than the row's
flattened string so a future layout change cannot pass by merging the
fields back into one node.

Also stop sharing .cfg-rows with the Workflows "Start work" form. A
class owned by the Configuration page meant restyling Configuration
could silently restyle that form; it is now .wf-form, owned by the
feature that uses it.
This commit is contained in:
sam committed 2026-08-10 03:00:56 +10:00
1 parent 7ee68d080a
commit fb7fba4232
8 files changed
+418 -201

No files matched your search

+1 -1
View File
@@ -1 +1 @@
:root{--font-sans:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;--font-mono:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;--text-xs:.6875rem;--text-sm:.8125rem;--text-base:.875rem;--text-lg:1.0625rem;--text-xl:1.375rem;--text-2xl:1.875rem;--text-3xl:2.5rem;--sp-1:.25rem;--sp-2:.5rem;--sp-3:.75rem;--sp-4:1rem;--sp-5:1.5rem;--sp-6:2rem;--sp-7:3rem;--radius-sm:6px;--radius-md:10px;--radius-lg:14px;--radius-xl:20px;--radius-pill:999px;--transition:.14s cubic-bezier(.4, 0, .2, 1)}[data-theme=dark]{--bg:#0d1014;--bg-raised:#141920;--surface:#171d25;--surface-hover:#1d242e;--border:#232b36;--border-strong:#303a48;--fg:#e8edf4;--fg-muted:#8b97a8;--fg-subtle:#5d6878;--accent:#4c8dff;--accent-fg:#fff;--accent-soft:#4c8dff24;--ok:#3fbf7f;--ok-soft:#3fbf7f24;--warn:#e8a33d;--warn-soft:#e8a33d24;--danger:#f0616d;--danger-soft:#f0616d24;--info:#4c8dff;--info-soft:#4c8dff24;--idle:#6b7688;--idle-soft:#6b768824;--accent-2:#7b5cff;--bg-blur:#1419208c;--surface-glass:#171d259e;--surface-glass-strong:#141920c7;--workspace:#11151b8c;--hairline:#ffffff0f;--wash-a:#4c8dff1a;--wash-b:#7b5cff1f;--wash-c:#3fbf7f0f;--shadow-workspace:0 24px 70px #00000080;--shadow-sm:0 1px 2px #0006;--shadow-md:0 8px 28px #0000006b}[data-theme=light]{--bg:#f6f8fb;--bg-raised:#fff;--surface:#fff;--surface-hover:#f1f4f9;--border:#e2e8f0;--border-strong:#cbd5e1;--fg:#16202e;--fg-muted:#5a6779;--fg-subtle:#8c99ab;--accent:#2563eb;--accent-fg:#fff;--accent-soft:#2563eb1a;--ok:#10935c;--ok-soft:#10935c1f;--warn:#b87514;--warn-soft:#b875141f;--danger:#d4344a;--danger-soft:#d4344a1f;--info:#2563eb;--info-soft:#2563eb1a;--idle:#64748b;--idle-soft:#64748b1f;--accent-2:#7c3aed;--bg-blur:#fff9;--surface-glass:#ffffffb8;--surface-glass-strong:#ffffffe0;--workspace:#ffffff8c;--hairline:#0f172a0f;--wash-a:#2563eb1a;--wash-b:#7c3aed1f;--wash-c:#10935c12;--shadow-workspace:0 24px 70px #0f172a24;--shadow-sm:0 1px 2px #0f172a0f;--shadow-md:0 8px 28px #0f172a1a}*,:before,:after{box-sizing:border-box}html,body{height:100%;margin:0}body{color:var(--fg);font-family:var(--font-sans);font-size:var(--text-base);-webkit-font-smoothing:antialiased;line-height:1.5}a{color:inherit;text-decoration:none}body{background:radial-gradient(70rem 40rem at 8% -10%, var(--wash-a), transparent 62%), radial-gradient(56rem 34rem at 92% 4%, var(--wash-b), transparent 58%), radial-gradient(48rem 30rem at 50% 108%, var(--wash-c), transparent 60%), var(--bg);padding:var(--sp-4);background-attachment:fixed}.shell{min-height:calc(100vh - var(--sp-4) * 2);border-radius:var(--radius-xl);border:1px solid var(--hairline);background:var(--workspace);-webkit-backdrop-filter:blur(28px)saturate(120%);backdrop-filter:blur(28px)saturate(120%);box-shadow:var(--shadow-workspace);flex-direction:column;display:flex;overflow:hidden}.topbar{align-items:center;gap:var(--sp-4);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--hairline);background:var(--bg-blur);z-index:10;display:flex;position:sticky;top:0}.brand{align-items:center;gap:var(--sp-2);font-weight:600;font-size:var(--text-sm);letter-spacing:-.01em;flex:none;display:flex}.brand-mark{background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;width:26px;height:26px;font-size:var(--text-xs);border-radius:8px;place-items:center;font-weight:700;display:grid}.nav{border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);align-items:center;gap:2px;margin:0 auto;padding:3px;display:flex}.nav-item{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);color:var(--fg-muted);font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:background var(--transition), color var(--transition);display:inline-flex}.nav-item:hover{color:var(--fg);background:var(--surface-hover)}.nav-item[aria-current=page]{background:var(--accent);color:var(--accent-fg);font-weight:500}.nav-item .nav-label{display:inline}.topbar-end{align-items:center;gap:var(--sp-2);flex:none;display:flex}.topbar-search{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);color:var(--fg-subtle);display:flex}.topbar-search input{color:var(--fg);font:inherit;font-size:var(--text-sm);background:0 0;border:0;outline:none;width:8rem}.topbar-search input::placeholder{color:var(--fg-subtle)}.mobile-search-toggle{display:none}.icon-btn{border-radius:var(--radius-pill);border:1px solid var(--hairline);background:var(--surface-glass-strong);width:32px;height:32px;color:var(--fg-muted);cursor:pointer;transition:color var(--transition), background var(--transition);place-items:center;display:grid}.icon-btn:hover{color:var(--fg);background:var(--surface-hover)}.avatar{border-radius:var(--radius-pill);width:32px;height:32px;font-size:var(--text-xs);color:#fff;background:linear-gradient(135deg, var(--accenLine 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]{--bg:#0d1014;--bg-raised:#141920;--surface:#171d25;--surface-hover:#1d242e;--border:#232b36;--border-strong:#303a48;--fg:#e8edf4;--fg-muted:#8b97a8;--fg-subtle:#5d6878;--accent:#4c8dff;--accent-fg:#fff;--accent-soft:#4c8dff24;--ok:#3fbf7f;--ok-soft:#3fbf7f24;--warn:#e8a33d;--warn-soft:#e8a33d24;--danger:#f0616d;--danger-soft:#f0616d24;--info:#4c8dff;--info-soft:#4c8dff24;--idle:#6b7688;--idle-soft:#6b768824;--accent-2:#7b5cff;--bg-blur:#1419208c;--surface-glass:#171d259e;--surface-glass-strong:#141920c7;--workspace:#11151b8c;--hairline:#ffffff0f;--wash-a:#4c8dff1a;--wash-b:#7b5cff1f;--wash-c:#3fbf7f0f;--shadow-workspace:0 24px 70px #00000080;--shadow-sm:0 1px 2px #0006;--shadow-md:0 8px 28px #0000006b}[data-theme=light]{--bg:#f6f8fb;--bg-raised:#fff;--surface:#fff;--surface-hover:#f1f4f9;--border:#e2e8f0;--border-strong:#cbd5e1;--fg:#16202e;--fg-muted:#5a6779;--fg-subtle:#8c99ab;--accent:#2563eb;--accent-fg:#fff;--accent-soft:#2563eb1a;--ok:#10935c;--ok-soft:#10935c1f;--warn:#b87514;--warn-soft:#b875141f;--danger:#d4344a;--danger-soft:#d4344a1f;--info:#2563eb;--info-soft:#2563eb1a;--idle:#64748b;--idle-soft:#64748b1f;--accent-2:#7c3aed;--bg-blur:#fff9;--surface-glass:#ffffffb8;--surface-glass-strong:#ffffffe0;--workspace:#ffffff8c;--hairline:#0f172a0f;--wash-a:#2563eb1a;--wash-b:#7c3aed1f;--wash-c:#10935c12;--shadow-workspace:0 24px 70px #0f172a24;--shadow-sm:0 1px 2px #0f172a0f;--shadow-md:0 8px 28px #0f172a1a}*,:before,:after{box-sizing:border-box}html,body{height:100%;margin:0}body{color:var(--fg);font-family:var(--font-sans);font-size:var(--text-base);-webkit-font-smoothing:antialiased;line-height:1.5}a{color:inherit;text-decoration:none}body{background:radial-gradient(70rem 40rem at 8% -10%, var(--wash-a), transparent 62%), radial-gradient(56rem 34rem at 92% 4%, var(--wash-b), transparent 58%), radial-gradient(48rem 30rem at 50% 108%, var(--wash-c), transparent 60%), var(--bg);padding:var(--sp-4);background-attachment:fixed}.shell{min-height:calc(100vh - var(--sp-4) * 2);border-radius:var(--radius-xl);border:1px solid var(--hairline);background:var(--workspace);-webkit-backdrop-filter:blur(28px)saturate(120%);backdrop-filter:blur(28px)saturate(120%);box-shadow:var(--shadow-workspace);flex-direction:column;display:flex;overflow:hidden}.topbar{align-items:center;gap:var(--sp-4);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--hairline);background:var(--bg-blur);z-index:10;display:flex;position:sticky;top:0}.brand{align-items:center;gap:var(--sp-2);font-weight:600;font-size:var(--text-sm);letter-spacing:-.01em;flex:none;display:flex}.brand-mark{background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;width:26px;height:26px;font-size:var(--text-xs);border-radius:8px;place-items:center;font-weight:700;display:grid}.nav{border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);align-items:center;gap:2px;margin:0 auto;padding:3px;display:flex}.nav-item{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);color:var(--fg-muted);font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:background var(--transition), color var(--transition);display:inline-flex}.nav-item:hover{color:var(--fg);background:var(--surface-hover)}.nav-item[aria-current=page]{background:var(--accent);color:var(--accent-fg);font-weight:500}.nav-item .nav-label{display:inline}.topbar-end{align-items:center;gap:var(--sp-2);flex:none;display:flex}.topbar-search{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);color:var(--fg-subtle);display:flex}.topbar-search input{color:var(--fg);font:inherit;font-size:var(--text-sm);background:0 0;border:0;outline:none;width:8rem}.topbar-search input::placeholder{color:var(--fg-subtle)}.mobile-search-toggle{display:none}.icon-btn{border-radius:var(--radius-pill);border:1px solid var(--hairline);background:var(--surface-glass-strong);width:32px;height:32px;color:var(--fg-muted);cursor:pointer;transition:color var(--transition), background var(--transition);place-items:center;display:grid}.icon-btn:hover{color:var(--fg);background:var(--surface-hover)}.avatar{border-radius:var(--radius-pill);width:32px;height:32px;font-size:var(--text-xs);color:#fff;background:linear-gradient(135deg, var(--accenLine truncated
+5 -5
View File
@@ -6,7 +6,7 @@
stroke-width="12" stroke-linecap="round"
stroke-dasharray="${c}"
stroke-dashoffset="${c*(1-i/100)}"
class="gauge-value"/>`,e(`div.gauge-wrap`,u,e(`div.gauge-center`,e(`div.gauge-pct`,`${Math.round(i)}%`),e(`div.gauge-label`,n)))}function b(t){let n=t.reduce((e,t)=>e+(t.value||0),0)||1;return e(`div`,e(`div.segbar`,...t.filter(e=>e.value>0).map(t=>e(`span`,{class:`segbar-part segbar-${t.kind||`idle`}`,style:`width:${(t.value/n*100).toFixed(1)}%`,title:`${t.label}: ${t.value}`}))),e(`div.segbar-legend`,...t.map(t=>e(`span.segbar-key`,e(`span`,{class:`segbar-dot segbar-${t.kind||`idle`}`}),t.label))))}var x=`archie.setup-complete.dismissed.v1`;function S(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?.(x),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function C(e=globalThis.localStorage){e?.setItem?.(x,`1`)}var w=new Set([`waiting_human`,`parked`]);function T(e=[]){let t=e.filter(e=>w.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 E(){let t=e(`div`),i=e(`tbody`),a=e(`div.grid.grid-4`),c=e(`div`),u=e(`div`),d=e(`div.dash-top`,c,u),f=e(`div`),p=e(`div.hero-actions-inner`),g=e(`h1.hero-title`,k()),v=r(`connecting`,`idle`),y=[],b=new Map;w(),O();let x=h(e=>{y.unshift(e),y.splice(50),E()},e=>{v.className=`pill pill-${e===`live`?`ok`:`warn`}`,v.textContent=e});t.addEventListener(`archie:teardown`,x);function w(){n(t,e(`div.hero`,e(`div`,g,e(`p.hero-sub`,`Your agent's control room — what it is working on, what needs you, and what it is spending.`)),e(`div.hero-actions`,p)),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Health`)),d),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Throughput`),e(`span.dash-section-note`,`Across all repositories`)),a),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Right now`)),e(`div.dash-split`,f,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Live activity`),e(`p.card-sub`,`Last 50, newest first`)),v),e(`div.table-scroll`,e(`table.table`,e(`thead`,e(`tr`,...[`Event`,`Task`,`Detail`,`When`].map(t=>e(`th`,t)))),i)))))),E()}function E(){if(!y.length){n(i,e(`tr`,e(`td`,{colspan:4},s(`Waiting for activity`,`Events appear here as Archie works.`))));return}n(i,...y.map(e=>D(e,b)))}async function O(){try{let[e,t,n,r]=await Promise.all([m.summary(),m.setup().catch(()=>null),m.workflows().catch(()=>null),m.tasks().catch(()=>[])]);b.clear();for(let e of r)e.owner&&e.repo&&e.issue_number&&b.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);E(),N(r),g.textContent=t?.operator?`${k()}, ${t.operator}`:k(),P(e),F(t),I(e,n),L(e)}catch(t){n(a,e(`div.card`,s(`Cannot reach archied`,String(t.message||t)))),n(p,e(`button.btn.btn-primary`,{onclick:O},l(`refresh`,{size:15}),`Retry`))}}function N(t){let r=T(t),i=r.attention.count,a=r.running.count;n(p,i>0&&e(`a.btn.btn-attention`,{href:r.attention.href},l(`tasks`,{size:15}),`${i} need${i===1?`s`:``} you`),a>0&&e(`a.btn`,{href:r.running.href},l(`workflows`,{size:15}),`${a} running`),e(`a.btn`,{href:`#/logs`},l(`logs`,{size:15}),`Logs`),e(`button.btn.btn-primary`,{onclick:O},l(`refresh`,{size:15}),`Refresh`))}function P(e){let t=e?.statuses||{},r=(t.merged||0)+(t.pr_open||0),i=(t.parked||0)+(t.waiting_human||0),s=Object.values(t).reduce((e,t)=>e+t,0),c=e?.tokens_by_day||[];n(a,_({label:`Working now`,value:t.running||0,compare:`${t.queued||0} waiting to start`,series:c.map(e=>e.tokens||0)}),_({label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),_({label:`Delivered`,value:r,compare:s?`${Math.round(r/s*100)}% of all tasks`:`No tasks yet`}),_({label:`Tokens used`,value:o(c.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${c.length||0} days`,trend:M(c.map(e=>e.tokens||0)),goodDirection:`down`,series:c.map(e=>e.tokens||0)}))}function F(t){let r=S(t),i=r.kind===`omit`||r.kind===`dismissed`;if(d.classList.toggle(`dash-top-standalone`,i),i)return n(c);let a=r.remaining;if(a.length){let r=Math.round((t.steps.length-a.length)/t.steps.length*100);n(c,e(`div.card.setup`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Finish setting up`),e(`p.card-sub`,`Archie needs these before it can work on its own.`)),e(`span.setup-pct`,`${r}%`)),e(`div.setup-bar`,e(`div.setup-bar-fill`,{style:`width:${r}%`})),e(`ul.setup-list`,...t.steps.map(R))));return}n(c,e(`div.card.setup.setup-done`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Setup complete`),e(`p.card-sub`,`Archie is configured and ready to work.`)),e(`div.setup-complete-actions`,e(`span.setup-pct`,l(`check`,{size:16})),e(`button.icon-btn.setup-dismiss`,{type:`button`,title:`Dismiss setup complete`,"aria-label":`Dismiss setup complete`,onclick:()=>{C(),F(t)}},`×`)))))}function Line truncated
class="gauge-value"/>`,e(`div.gauge-wrap`,u,e(`div.gauge-center`,e(`div.gauge-pct`,`${Math.round(i)}%`),e(`div.gauge-label`,n)))}function b(t){let n=t.reduce((e,t)=>e+(t.value||0),0)||1;return e(`div`,e(`div.segbar`,...t.filter(e=>e.value>0).map(t=>e(`span`,{class:`segbar-part segbar-${t.kind||`idle`}`,style:`width:${(t.value/n*100).toFixed(1)}%`,title:`${t.label}: ${t.value}`}))),e(`div.segbar-legend`,...t.map(t=>e(`span.segbar-key`,e(`span`,{class:`segbar-dot segbar-${t.kind||`idle`}`}),t.label))))}var x=`archie.setup-complete.dismissed.v1`;function S(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?.(x),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function C(e=globalThis.localStorage){e?.setItem?.(x,`1`)}var w=new Set([`waiting_human`,`parked`]);function T(e=[]){let t=e.filter(e=>w.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 E(){let t=e(`div`),i=e(`tbody`),a=e(`div.grid.grid-4`),c=e(`div`),u=e(`div`),d=e(`div.dash-top`,c,u),f=e(`div`),p=e(`div.hero-actions-inner`),g=e(`h1.hero-title`,k()),v=r(`connecting`,`idle`),y=[],b=new Map;w(),O();let x=h(e=>{y.unshift(e),y.splice(50),E()},e=>{v.className=`pill pill-${e===`live`?`ok`:`warn`}`,v.textContent=e});t.addEventListener(`archie:teardown`,x);function w(){n(t,e(`div.hero`,e(`div`,g,e(`p.hero-sub`,`Your agent's control room — what it is working on, what needs you, and what it is spending.`)),e(`div.hero-actions`,p)),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Health`)),d),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Throughput`),e(`span.dash-section-note`,`Across all repositories`)),a),e(`div.dash-section`,e(`div.dash-section-head`,e(`h2.dash-section-title`,`Right now`)),e(`div.dash-split`,f,e(`div.card`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Live activity`),e(`p.card-sub`,`Last 50, newest first`)),v),e(`div.table-scroll`,e(`table.table`,e(`thead`,e(`tr`,...[`Event`,`Task`,`Detail`,`When`].map(t=>e(`th`,t)))),i)))))),E()}function E(){if(!y.length){n(i,e(`tr`,e(`td`,{colspan:4},s(`Waiting for activity`,`Events appear here as Archie works.`))));return}n(i,...y.map(e=>D(e,b)))}async function O(){try{let[e,t,n,r]=await Promise.all([m.summary(),m.setup().catch(()=>null),m.workflows().catch(()=>null),m.tasks().catch(()=>[])]);b.clear();for(let e of r)e.owner&&e.repo&&e.issue_number&&b.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);E(),N(r),g.textContent=t?.operator?`${k()}, ${t.operator}`:k(),P(e),F(t),I(e,n),L(e)}catch(t){n(a,e(`div.card`,s(`Cannot reach archied`,String(t.message||t)))),n(p,e(`button.btn.btn-primary`,{onclick:O},l(`refresh`,{size:15}),`Retry`))}}function N(t){let r=T(t),i=r.attention.count,a=r.running.count;n(p,i>0&&e(`a.btn.btn-attention`,{href:r.attention.href},l(`tasks`,{size:15}),`${i} need${i===1?`s`:``} you`),a>0&&e(`a.btn`,{href:r.running.href},l(`workflows`,{size:15}),`${a} running`),e(`a.btn`,{href:`#/logs`},l(`logs`,{size:15}),`Logs`),e(`button.btn.btn-primary`,{onclick:O},l(`refresh`,{size:15}),`Refresh`))}function P(e){let t=e?.statuses||{},r=(t.merged||0)+(t.pr_open||0),i=(t.parked||0)+(t.waiting_human||0),s=Object.values(t).reduce((e,t)=>e+t,0),c=e?.tokens_by_day||[];n(a,_({label:`Working now`,value:t.running||0,compare:`${t.queued||0} waiting to start`,series:c.map(e=>e.tokens||0)}),_({label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),_({label:`Delivered`,value:r,compare:s?`${Math.round(r/s*100)}% of all tasks`:`No tasks yet`}),_({label:`Tokens used`,value:o(c.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${c.length||0} days`,trend:M(c.map(e=>e.tokens||0)),goodDirection:`down`,series:c.map(e=>e.tokens||0)}))}function F(t){let r=S(t),i=r.kind===`omit`||r.kind===`dismissed`;if(d.classList.toggle(`dash-top-standalone`,i),i)return n(c);let a=r.remaining;if(a.length){let r=Math.round((t.steps.length-a.length)/t.steps.length*100);n(c,e(`div.card.setup`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Finish setting up`),e(`p.card-sub`,`Archie needs these before it can work on its own.`)),e(`span.setup-pct`,`${r}%`)),e(`div.setup-bar`,e(`div.setup-bar-fill`,{style:`width:${r}%`})),e(`ul.setup-list`,...t.steps.map(R))));return}n(c,e(`div.card.setup.setup-done`,e(`div.card-head`,e(`div`,e(`h2.card-title`,`Setup complete`),e(`p.card-sub`,`Archie is configured and ready to work.`)),e(`div.setup-complete-actions`,e(`span.setup-pct`,l(`check`,{size:16})),e(`button.icon-btn.setup-dismiss`,{type:`button`,title:`Dismiss setup complete`,"aria-label":`Dismiss setup complete`,onclick:()=>{C(),F(t)}},`×`)))))}function Line truncated
<div class="chat-page-content">
<header class="chat-topbar">
<div><span class="chat-kicker">ARCHIE WORKSPACE</span><h1 class="page-title">Chat</h1></div>
@@ -71,10 +71,10 @@
</div>
</div>
</div>
`;function Ne(){let e=document.createElement(`template`);e.innerHTML=Me.trim();let t=e.content.firstElementChild,n={};for(let e of t.querySelectorAll(`[data-chat-ref]`))n[e.dataset.chatRef]=e;return{root:t,refs:n}}function J(t){let n=document.createDocumentFragment(),r=/(~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|`[^`]+`|\[[^\]]+\]\(https?:\/\/[^\s)]+\)|\*[^*]+\*|_[^_]+_)/g,i=0;for(let a of t.matchAll(r)){a.index>i&&n.append(document.createTextNode(t.slice(i,a.index)));let r=a[0];if(r.startsWith(`~~`))n.append(e(`del`,r.slice(2,-2)));else if(r.startsWith(`**`)||r.startsWith(`__`))n.append(e(`strong`,r.slice(2,-2)));else if(r.startsWith("`"))n.append(e(`code`,r.slice(1,-1)));else if(r.startsWith(`[`)){let t=r.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)$/);n.append(e(`a`,{href:t[2],target:`_blank`,rel:`noreferrer`},t[1]))}else n.append(e(`em`,r.slice(1,-1)));i=a.index+r.length}return i<t.length&&n.append(document.createTextNode(t.slice(i))),n}function Pe(t){let n=e(`div.chat-bubble-text`),r=String(t||``).split(`
`;function Fe(){let e=document.createElement(`template`);e.innerHTML=Pe.trim();let t=e.content.firstElementChild,n={};for(let e of t.querySelectorAll(`[data-chat-ref]`))n[e.dataset.chatRef]=e;return{root:t,refs:n}}function J(t){let n=document.createDocumentFragment(),r=/(~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|`[^`]+`|\[[^\]]+\]\(https?:\/\/[^\s)]+\)|\*[^*]+\*|_[^_]+_)/g,i=0;for(let a of t.matchAll(r)){a.index>i&&n.append(document.createTextNode(t.slice(i,a.index)));let r=a[0];if(r.startsWith(`~~`))n.append(e(`del`,r.slice(2,-2)));else if(r.startsWith(`**`)||r.startsWith(`__`))n.append(e(`strong`,r.slice(2,-2)));else if(r.startsWith("`"))n.append(e(`code`,r.slice(1,-1)));else if(r.startsWith(`[`)){let t=r.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)$/);n.append(e(`a`,{href:t[2],target:`_blank`,rel:`noreferrer`},t[1]))}else n.append(e(`em`,r.slice(1,-1)));i=a.index+r.length}return i<t.length&&n.append(document.createTextNode(t.slice(i))),n}function Ie(t){let n=e(`div.chat-bubble-text`),r=String(t||``).split(`
`),i=[],a=null,o=null,s=()=>{i.length&&(n.append(e(`p`,J(i.join(` `)))),i=[])},c=()=>{a&&n.append(a),a=null};for(let t=0;t<r.length;t++){let l=r[t];if(l.startsWith("```")){s(),c(),o?(n.append(e(`pre`,e(`code`,o.join(`
`)))),o=null):o=[];continue}if(o){o.push(l);continue}let u=Y(l),d=t+1<r.length?Y(r[t+1]):null;if(u&&d&&Fe(d)&&u.length===d.length){s(),c();let i=[];for(t+=2;t<r.length;t++){let e=Y(r[t]);if(!e||e.length!==u.length){t--;break}i.push(e)}let a=e(`tbody`);for(let t of i)a.append(e(`tr`,...t.map(t=>e(`td`,J(t)))));n.append(e(`table`,e(`thead`,e(`tr`,...u.map(t=>e(`th`,J(t))))),a));continue}if(!l.trim()){s(),c();continue}let f=l.match(/^(#{1,3})\s+(.+)$/);if(f){s(),c(),n.append(e(`h${f[1].length}`,J(f[2])));continue}let p=l.match(/^\s*[-*]\s+(.+)$/),m=l.match(/^\s*\d+[.)]\s+(.+)$/);if(p||m){s();let t=m?`ol`:`ul`;(!a||a.tagName.toLowerCase()!==t)&&(c(),a=e(t)),a.append(e(`li`,J((p||m)[1])));continue}if(l.startsWith(`>`)){s(),c(),n.append(e(`blockquote`,J(l.replace(/^>\s?/,``))));continue}i.push(l)}return s(),c(),o&&n.append(e(`pre`,e(`code`,o.join(`
`)))),n}function Y(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 Fe(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}function Ie(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function Le(t){let n=t.from??t.From??``,r=t.text??t.Text??``,i=n!==`web`;return e(`div.chat-bubble-row.${i?`assistant`:`user`}`,e(`div.chat-bubble`,e(`div.chat-bubble-meta`,i?`Archie`:`You`),i?Pe(r):e(`div.chat-bubble-text`,r)))}function X(e,t){let n=Pe(t);return typeof e?.replaceWith==`function`?e.replaceWith(n):e?.parentNode&&e.parentNode.replaceChild(n,e),n}var Re=`archie.web.chat.channel`;function Z(){let e=localStorage.getItem(Re);return e||(e=crypto.randomUUID(),localStorage.setItem(Re,e)),e}function ze(e){return{text:e,sourceID:crypto.randomUUID()}}function Be(e){return{...e}}function Ve(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?Be(e.turn):ze(r),isRetry:n}}function He({sessionList:t,sessionTools:n,sessions:r,currentSession:i,onSelect:a}){if(t.replaceChildren(),n.hidden=!i,!r.length){t.append(e(`div.chat-empty`,`Your conversations will appear here.`));return}for(let n of r)t.append(e(`button.chat-session`,{class:i===n.session_id?`active`:``,onclick:()=>a(n.session_id)},e(`strong`,Ie(n)),e(`span`,new Date(n.last_active_at).toLocaleString())))}function Ue(t,n,r){t.persona.replaceChildren(e(`option`,{value:``},`Personality`));for(let r of n.personas||[])t.persona.append(e(`option`,{value:r},r));t.persona.value=n.active_persona||``;let i=n.providers||[];t.provider.hidden=i.length===0,t.provider.replaceChildren(e(`option`,{value:``},`Provider`));for(let n of i)t.provider.append(e(`option`,{value:n},n));t.provider.value=n.active_provider||i[0]||``,We(t,n,t.provider.value),t.restart.hidden=!n.restart_available,t.dangerousPanel.hidden=!n.dangerous_available,n.dangerous_available&&r()}function We(t,n,r){let i=n.models_by_provider||{},a=r&&i[r]?i[r]:n.models||[];t.model.replaceChildren(e(`option`,{value:``},`Model`));for(let n of a)t.model.append(e(`option`,{value:n},n));t.model.value=n.active_model||``}function Ge(t,n){let r=(n||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e),i=e(`div.chat-command-list`);r.length||i.append(e(`span`,`Send a message to begin.`));for(let t of r)i.append(e(`div.chat-command-item`,e(`code`,t.usage||t.command),e(`span`,t.description||``)));return t.replaceChildren(e(`summary`,`Available commands (${r.length})`),i),r}function Ke(t,n,{onDefer:r,onInstall:i}){t.replaceChildren();let a=n?.snapshot||null,o=n?.available||[];if(!o.length){t.append(e(`span`,a?.deferred?`Update deferred.`:`Archie is up to date.`));return}t.append(e(`div`,e(`strong`,`Update available`),e(`span`,o.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `))),e(`div.chat-update-actions`,e(`button.btn`,{onclick:r},`Defer`),n.can_install?e(`button.btn.btn-primary`,{onclick:i},`Install update`):null))}function qe(t,n,{onRequest:r,onDecision:i}){t.replaceChildren();let a=n?.checkpoints||[],o=n?.pending||[],s=e(`select.chat-select`,{"aria-label":`Checkpoint`},e(`option`,{value:``},`Select checkpoint`),...a.map(t=>e(`option`,{value:t.Number??t.number},`${t.Number??t.number} — ${t.Label??t.label??`checkpoint`}`))),c=e(`input.chat-dangerous-input`,{placeholder:`Process name or id`,"aria-label":`Process name or id`}),l=(e,t)=>()=>r(e,String(t.value||t).trim()),u=(t,n,r)=>e(`button.btn`,{onclick:()=>i(t,n)},r),d=o.length?o.map(t=>e(`div.chat-dangerous-pending`,e(`span`,t.description),e(`div.chat-update-actions`,u(t.id,`approve`,`Approve`),u(t.id,`permanent`,`Approve for 24h`),u(t.id,`deny`,`Deny`)))):[e(`span.chat-hint`,`No pending dangerous actions.`)];t.append(e(`div.chat-dangerous-head`,e(`strong`,`Dangerous actions`),e(`span.chat-hint`,`Every action requires approval.`)),e(`div.chat-dangerous-controls`,e(`div`,s,e(`button.btn`,{onclick:l(`rollback`,s)},`Request rollback`)),e(`div`,c,e(`button.btn`,{onclick:l(`stop`,c)},`Request stop`))),e(`div.chat-dangerous-pending-list`,...d))}function Je(e){return e?.status===501?null:`Could not check for updates.`}function Ye(){let{root:t,refs:n}=Ne(),{sessionList:r,transcript:i,composer:a,send:o,stop:s,status:c,persona:l,provider:u,model:d,restart:f,emptyState:p,updatePanel:h,dangerousPanel:g,commandMenu:_,sessionTools:v,commandHelp:y,checkUpdates:b,newChat:x}=n,S=``,C=[],w=!1,T=null,E=null,D={},O=[],k=[],A=0;f.onclick=()=>{window.confirm(`Reload the Telegram chat adapter?`)&&(a.value=`/restart`,H())},x.onclick=()=>{a.value=`/new`,H()};for(let e of t.querySelectorAll(`[data-chat-prompt]`))e.onclick=()=>{a.value=e.dataset.chatPrompt,a.focus()};function j(e){p.remove(),i.append(Le(e)),i.scrollTop=i.scrollHeight}function M(){let e=a.value.slice(0,a.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);return e?e[1].toLowerCase():null}function Line truncated
`)))),o=null):o=[];continue}if(o){o.push(l);continue}let u=Y(l),d=t+1<r.length?Y(r[t+1]):null;if(u&&d&&Le(d)&&u.length===d.length){s(),c();let i=[];for(t+=2;t<r.length;t++){let e=Y(r[t]);if(!e||e.length!==u.length){t--;break}i.push(e)}let a=e(`tbody`);for(let t of i)a.append(e(`tr`,...t.map(t=>e(`td`,J(t)))));n.append(e(`table`,e(`thead`,e(`tr`,...u.map(t=>e(`th`,J(t))))),a));continue}if(!l.trim()){s(),c();continue}let f=l.match(/^(#{1,3})\s+(.+)$/);if(f){s(),c(),n.append(e(`h${f[1].length}`,J(f[2])));continue}let p=l.match(/^\s*[-*]\s+(.+)$/),m=l.match(/^\s*\d+[.)]\s+(.+)$/);if(p||m){s();let t=m?`ol`:`ul`;(!a||a.tagName.toLowerCase()!==t)&&(c(),a=e(t)),a.append(e(`li`,J((p||m)[1])));continue}if(l.startsWith(`>`)){s(),c(),n.append(e(`blockquote`,J(l.replace(/^>\s?/,``))));continue}i.push(l)}return s(),c(),o&&n.append(e(`pre`,e(`code`,o.join(`
`)))),n}function Y(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 Le(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}function Re(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function ze(t){let n=t.from??t.From??``,r=t.text??t.Text??``,i=n!==`web`;return e(`div.chat-bubble-row.${i?`assistant`:`user`}`,e(`div.chat-bubble`,e(`div.chat-bubble-meta`,i?`Archie`:`You`),i?Ie(r):e(`div.chat-bubble-text`,r)))}function X(e,t){let n=Ie(t);return typeof e?.replaceWith==`function`?e.replaceWith(n):e?.parentNode&&e.parentNode.replaceChild(n,e),n}var Be=`archie.web.chat.channel`;function Z(){let e=localStorage.getItem(Be);return e||(e=crypto.randomUUID(),localStorage.setItem(Be,e)),e}function Ve(e){return{text:e,sourceID:crypto.randomUUID()}}function He(e){return{...e}}function Ue(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?He(e.turn):Ve(r),isRetry:n}}function We({sessionList:t,sessionTools:n,sessions:r,currentSession:i,onSelect:a}){if(t.replaceChildren(),n.hidden=!i,!r.length){t.append(e(`div.chat-empty`,`Your conversations will appear here.`));return}for(let n of r)t.append(e(`button.chat-session`,{class:i===n.session_id?`active`:``,onclick:()=>a(n.session_id)},e(`strong`,Re(n)),e(`span`,new Date(n.last_active_at).toLocaleString())))}function Ge(t,n,r){t.persona.replaceChildren(e(`option`,{value:``},`Personality`));for(let r of n.personas||[])t.persona.append(e(`option`,{value:r},r));t.persona.value=n.active_persona||``;let i=n.providers||[];t.provider.hidden=i.length===0,t.provider.replaceChildren(e(`option`,{value:``},`Provider`));for(let n of i)t.provider.append(e(`option`,{value:n},n));t.provider.value=n.active_provider||i[0]||``,Ke(t,n,t.provider.value),t.restart.hidden=!n.restart_available,t.dangerousPanel.hidden=!n.dangerous_available,n.dangerous_available&&r()}function Ke(t,n,r){let i=n.models_by_provider||{},a=r&&i[r]?i[r]:n.models||[];t.model.replaceChildren(e(`option`,{value:``},`Model`));for(let n of a)t.model.append(e(`option`,{value:n},n));t.model.value=n.active_model||``}function qe(t,n){let r=(n||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e),i=e(`div.chat-command-list`);r.length||i.append(e(`span`,`Send a message to begin.`));for(let t of r)i.append(e(`div.chat-command-item`,e(`code`,t.usage||t.command),e(`span`,t.description||``)));return t.replaceChildren(e(`summary`,`Available commands (${r.length})`),i),r}function Je(t,n,{onDefer:r,onInstall:i}){t.replaceChildren();let a=n?.snapshot||null,o=n?.available||[];if(!o.length){t.append(e(`span`,a?.deferred?`Update deferred.`:`Archie is up to date.`));return}t.append(e(`div`,e(`strong`,`Update available`),e(`span`,o.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `))),e(`div.chat-update-actions`,e(`button.btn`,{onclick:r},`Defer`),n.can_install?e(`button.btn.btn-primary`,{onclick:i},`Install update`):null))}function Ye(t,n,{onRequest:r,onDecision:i}){t.replaceChildren();let a=n?.checkpoints||[],o=n?.pending||[],s=e(`select.chat-select`,{"aria-label":`Checkpoint`},e(`option`,{value:``},`Select checkpoint`),...a.map(t=>e(`option`,{value:t.Number??t.number},`${t.Number??t.number} — ${t.Label??t.label??`checkpoint`}`))),c=e(`input.chat-dangerous-input`,{placeholder:`Process name or id`,"aria-label":`Process name or id`}),l=(e,t)=>()=>r(e,String(t.value||t).trim()),u=(t,n,r)=>e(`button.btn`,{onclick:()=>i(t,n)},r),d=o.length?o.map(t=>e(`div.chat-dangerous-pending`,e(`span`,t.description),e(`div.chat-update-actions`,u(t.id,`approve`,`Approve`),u(t.id,`permanent`,`Approve for 24h`),u(t.id,`deny`,`Deny`)))):[e(`span.chat-hint`,`No pending dangerous actions.`)];t.append(e(`div.chat-dangerous-head`,e(`strong`,`Dangerous actions`),e(`span.chat-hint`,`Every action requires approval.`)),e(`div.chat-dangerous-controls`,e(`div`,s,e(`button.btn`,{onclick:l(`rollback`,s)},`Request rollback`)),e(`div`,c,e(`button.btn`,{onclick:l(`stop`,c)},`Request stop`))),e(`div.chat-dangerous-pending-list`,...d))}function Xe(e){return e?.status===501?null:`Could not check for updates.`}function Ze(){let{root:t,refs:n}=Fe(),{sessionList:r,transcript:i,composer:a,send:o,stop:s,status:c,persona:l,provider:u,model:d,restart:f,emptyState:p,updatePanel:h,dangerousPanel:g,commandMenu:_,sessionTools:v,commandHelp:y,checkUpdates:b,newChat:x}=n,S=``,C=[],w=!1,T=null,E=null,D={},O=[],k=[],A=0;f.onclick=()=>{window.confirm(`Reload the Telegram chat adapter?`)&&(a.value=`/restart`,H())},x.onclick=()=>{a.value=`/new`,H()};for(let e of t.querySelectorAll(`[data-chat-prompt]`))e.onclick=()=>{a.value=e.dataset.chatPrompt,a.focus()};function j(e){p.remove(),i.append(ze(e)),i.scrollTop=i.scrollHeight}function M(){let e=a.value.slice(0,a.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);return e?e[1].toLowerCase():null}function Line truncated
`);i=a.pop()||``;for(let e of a){let t=e.split(`
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(S=n.session_id),n.type===`delta`&&(f+=n.text,d=X(d,f)),n.type===`done`&&(p=!0,f||(f=n.text,d=X(d,f))),n.type===`error`)throw Error(n.text)}if(r)break}if(!p)throw Error(`chat stream ended before completion`);d.isConnected&&(d=X(d,f)),c.textContent=`Ready`,await R()}catch(t){if(t.name===`AbortError`&&!m)d=X(d,`Turn stopped.`),c.textContent=`Stopped`;else{d=X(d,`Unable to complete that turn: ${t.message||t}`);let n=Be(r),i=e(`button.btn.chat-retry`,{type:`button`,onclick:()=>H({turn:n,replyBubble:u})},`Retry`);u.append(i),c.textContent=`Error — retry available`}}finally{clearTimeout(h),T=null,w=!1,o.disabled=!1,s.disabled=!0,a.disabled=!1,a.focus()}}o.onclick=()=>H(),s.onclick=()=>{let e=S;c.textContent=`Stopping…`,e&&m.chatCancel(e).catch(()=>{}),T?.abort()},a.oninput=P,a.onkeydown=e=>{if(!_.hidden&&k.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&k.some(e=>e.command===a.value.trim())){e.preventDefault(),N(),H();return}if(e.key===`ArrowDown`){e.preventDefault(),A=(A+1)%k.length,P();return}if(e.key===`ArrowUp`){e.preventDefault(),A=(A+k.length-1)%k.length,P();return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),F(A);return}if(e.key===`Escape`){e.preventDefault(),N();return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),H())},l.onchange=async()=>{!S||!l.value||(await m.chatPersona(S,l.value),D.active_personas={...D.active_personas||{},[S]:l.value},c.textContent=`Personality: ${l.value}`)},u.onchange=async()=>{We({model:d},D,u.value),u.value&&await U(`/model --provider ${u.value}`)},d.onchange=async()=>{d.value&&await U(`/model ${d.value}`)};async function U(e){try{let t=await m.chatMessage(Z(),e);c.textContent=t.reply||`Model updated`,await R()}catch(e){c.textContent=`Model update failed: ${e.message||e}`}}b.onclick=I;let W={retry:()=>z(`/retry`),undo:()=>z(`/undo`),title:()=>B(`/title`,`Session title`),branch:()=>B(`/branch`,`Branch name (optional)`),compress:()=>z(`/compress --preview`)};for(let e of t.querySelectorAll(`[data-chat-action]`))e.onclick=W[e.dataset.chatAction];return R().catch(e=>{c.textContent=e.message||`Chat unavailable`}),I(),t}var Q=[{path:`/`,label:`Dashboard`,icon:`dashboard`,view:E},{path:`/chat`,label:`Chat`,icon:`chat`,view:Ye},{path:`/tasks`,label:`Tasks`,icon:`tasks`,view:B},{path:`/logs`,label:`Logs`,icon:`logs`,view:Se},{path:`/skills`,label:`Skills`,icon:`skills`,view:V},{path:`/workflows`,label:`Workflows`,icon:`workflows`,view:te},{path:`/memory`,label:`Memory`,icon:`memory`,view:ke},{path:`/channels`,label:`Channels`,icon:`channels`,view:ne},{path:`/settings`,label:`Configuration`,icon:`settings`,view:ie}],Xe=`archie.theme`;function Ze(e){document.documentElement.dataset.theme=e,localStorage.setItem(Xe,e)}function $(){return localStorage.getItem(Xe)||`dark`}function Qe(t){let r=new Map,i=e(`nav.nav`,...[null].flatMap(()=>[...Q.map(n=>{let i=e(`a.nav-item`,{href:`#${n.path}`,onclick:e=>{n.soon?e.preventDefault():t(n.path)},"aria-disabled":n.soon||void 0,title:n.soon?`Coming soon`:void 0},l(n.icon),e(`span.nav-label`,n.label),n.soon&&e(`span.nav-soon`,`soon`));return r.set(n.path,i),i})])),a=e(`button.icon-btn`,{title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onclick:()=>{Ze($()===`dark`?`light`:`dark`),n(a,l($()===`dark`?`moon`:`sun`))}});n(a,l($()===`dark`?`moon`:`sun`));let o,s=()=>{o?.classList.remove(`is-open`),c.setAttribute(`aria-expanded`,`false`)},c=e(`button.icon-btn.mobile-search-toggle`,{type:`button`,"aria-label":`Open Jump to navigation`,"aria-expanded":`false`,onclick:()=>{o.classList.add(`is-open`),c.setAttribute(`aria-expanded`,`true`),u.focus()}},l(`search`,{size:15})),u=e(`input`,{type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onkeydown:e=>{if(e.key===`Escape`){s(),e.target.blur();return}if(e.key!==`Enter`)return;let n=e.target.value.trim().toLowerCase(),r=Q.find(e=>!e.soon&&e.label.toLowerCase().startsWith(n));r&&(t(r.path),e.target.value=``,e.target.blur(),s())}});return o=e(`div.topbar-search`,e(`span.topbar-search-icon`,{"aria-hidden":`true`},l(`search`,{size:15})),c,u),{node:e(`header.topbar`,e(`div.brand`,e(`span.brand-mark`,`A`),`Archie`),i,e(`div.topbar-end`,o,e(`button.icon-btn`,{title:`Documentation`,"aria-label":`Documentation`},l(`help`)),a,e(`div.avatar`,{title:`Signed in locally`},`A`))),highlight(e){for(let[t,n]of r)t===e?n.setAttribute(`aria-current`,`page`):n.removeAttribute(`aria-current`)}}}function $e(){Ze($());let t=e(`main.main`),r=Qe(i);n(document.getElementById(`app`),e(`div.shell`,r.node,t));function i(e){location.hash===`#${e}`?a(e):location.hash=e}function a(e){t.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`));let[i,a=``]=e.split(`?`,2),o=Q.find(e=>e.path===i)||Q[0];r.highlight(o.path),n(t,o.view?o.view(new URLSearchParams(a)):et(o))}window.addEventListener(`hashchange`,()=>a(location.hash.slice(1)||`/`)),a(location.has Line truncated
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(S=n.session_id),n.type===`delta`&&(f+=n.text,d=X(d,f)),n.type===`done`&&(p=!0,f||(f=n.text,d=X(d,f))),n.type===`error`)throw Error(n.text)}if(r)break}if(!p)throw Error(`chat stream ended before completion`);d.isConnected&&(d=X(d,f)),c.textContent=`Ready`,await R()}catch(t){if(t.name===`AbortError`&&!m)d=X(d,`Turn stopped.`),c.textContent=`Stopped`;else{d=X(d,`Unable to complete that turn: ${t.message||t}`);let n=He(r),i=e(`button.btn.chat-retry`,{type:`button`,onclick:()=>H({turn:n,replyBubble:u})},`Retry`);u.append(i),c.textContent=`Error — retry available`}}finally{clearTimeout(h),T=null,w=!1,o.disabled=!1,s.disabled=!0,a.disabled=!1,a.focus()}}o.onclick=()=>H(),s.onclick=()=>{let e=S;c.textContent=`Stopping…`,e&&m.chatCancel(e).catch(()=>{}),T?.abort()},a.oninput=P,a.onkeydown=e=>{if(!_.hidden&&k.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&k.some(e=>e.command===a.value.trim())){e.preventDefault(),N(),H();return}if(e.key===`ArrowDown`){e.preventDefault(),A=(A+1)%k.length,P();return}if(e.key===`ArrowUp`){e.preventDefault(),A=(A+k.length-1)%k.length,P();return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),F(A);return}if(e.key===`Escape`){e.preventDefault(),N();return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),H())},l.onchange=async()=>{!S||!l.value||(await m.chatPersona(S,l.value),D.active_personas={...D.active_personas||{},[S]:l.value},c.textContent=`Personality: ${l.value}`)},u.onchange=async()=>{Ke({model:d},D,u.value),u.value&&await U(`/model --provider ${u.value}`)},d.onchange=async()=>{d.value&&await U(`/model ${d.value}`)};async function U(e){try{let t=await m.chatMessage(Z(),e);c.textContent=t.reply||`Model updated`,await R()}catch(e){c.textContent=`Model update failed: ${e.message||e}`}}b.onclick=I;let W={retry:()=>z(`/retry`),undo:()=>z(`/undo`),title:()=>B(`/title`,`Session title`),branch:()=>B(`/branch`,`Branch name (optional)`),compress:()=>z(`/compress --preview`)};for(let e of t.querySelectorAll(`[data-chat-action]`))e.onclick=W[e.dataset.chatAction];return R().catch(e=>{c.textContent=e.message||`Chat unavailable`}),I(),t}var Q=[{path:`/`,label:`Dashboard`,icon:`dashboard`,view:E},{path:`/chat`,label:`Chat`,icon:`chat`,view:Ze},{path:`/tasks`,label:`Tasks`,icon:`tasks`,view:B},{path:`/logs`,label:`Logs`,icon:`logs`,view:we},{path:`/skills`,label:`Skills`,icon:`skills`,view:V},{path:`/workflows`,label:`Workflows`,icon:`workflows`,view:te},{path:`/memory`,label:`Memory`,icon:`memory`,view:je},{path:`/channels`,label:`Channels`,icon:`channels`,view:ne},{path:`/settings`,label:`Configuration`,icon:`settings`,view:le}],Qe=`archie.theme`;function $e(e){document.documentElement.dataset.theme=e,localStorage.setItem(Qe,e)}function $(){return localStorage.getItem(Qe)||`dark`}function et(t){let r=new Map,i=e(`nav.nav`,...[null].flatMap(()=>[...Q.map(n=>{let i=e(`a.nav-item`,{href:`#${n.path}`,onclick:e=>{n.soon?e.preventDefault():t(n.path)},"aria-disabled":n.soon||void 0,title:n.soon?`Coming soon`:void 0},l(n.icon),e(`span.nav-label`,n.label),n.soon&&e(`span.nav-soon`,`soon`));return r.set(n.path,i),i})])),a=e(`button.icon-btn`,{title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onclick:()=>{$e($()===`dark`?`light`:`dark`),n(a,l($()===`dark`?`moon`:`sun`))}});n(a,l($()===`dark`?`moon`:`sun`));let o,s=()=>{o?.classList.remove(`is-open`),c.setAttribute(`aria-expanded`,`false`)},c=e(`button.icon-btn.mobile-search-toggle`,{type:`button`,"aria-label":`Open Jump to navigation`,"aria-expanded":`false`,onclick:()=>{o.classList.add(`is-open`),c.setAttribute(`aria-expanded`,`true`),u.focus()}},l(`search`,{size:15})),u=e(`input`,{type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onkeydown:e=>{if(e.key===`Escape`){s(),e.target.blur();return}if(e.key!==`Enter`)return;let n=e.target.value.trim().toLowerCase(),r=Q.find(e=>!e.soon&&e.label.toLowerCase().startsWith(n));r&&(t(r.path),e.target.value=``,e.target.blur(),s())}});return o=e(`div.topbar-search`,e(`span.topbar-search-icon`,{"aria-hidden":`true`},l(`search`,{size:15})),c,u),{node:e(`header.topbar`,e(`div.brand`,e(`span.brand-mark`,`A`),`Archie`),i,e(`div.topbar-end`,o,e(`button.icon-btn`,{title:`Documentation`,"aria-label":`Documentation`},l(`help`)),a,e(`div.avatar`,{title:`Signed in locally`},`A`))),highlight(e){for(let[t,n]of r)t===e?n.setAttribute(`aria-current`,`page`):n.removeAttribute(`aria-current`)}}}function tt(){$e($());let t=e(`main.main`),r=et(i);n(document.getElementById(`app`),e(`div.shell`,r.node,t));function i(e){location.hash===`#${e}`?a(e):location.hash=e}function a(e){t.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`));let[i,a=``]=e.split(`?`,2),o=Q.find(e=>e.path===i)||Q[0];r.highlight(o.path),n(t,o.view?o.view(new URLSearchParams(a)):nt(o))}window.addEventListener(`hashchange`,()=>a(location.hash.slice(1)||`/`)),a(location.has Line truncated
+165
View File
@@ -0,0 +1,165 @@
import { api } from "../base/api.js";
import { el, mount } from "../base/dom.js";
/**
* One key/value row on the Configuration page, and its inline edit flow.
*
* Split out of settings.js so it can be unit-tested: settings.js imports
* its own stylesheet, which the node test shim cannot parse. Same reason
* tasks/task-row.js exists separately from tasks.js.
*
* A row renders as a three-column grid: label, value, actions. That shape
* is the fix for three faults in the previous flex layout, all of which
* were visible on screen:
*
* - label and value were pushed to opposite ends of a full-width card by
* `justify-content: space-between`, so reading a pair meant tracking
* across the viewport;
* - the value could not shrink (no `min-width: 0`), so long values
* overflowed into the Edit button and appeared truncated ("400" as
* "40");
* - the locked reason sat beside the overflowing value and ran onto the
* end of it, rendering "...archie/work" and "pins the daemon's working
* layout" as one unbroken string.
*/
// valueText normalises a config value for display. 0 and false are real
// values and must not collapse to the em dash the way null or an unset
// string does, so the emptiness test is explicit rather than falsy.
export function valueText(value) {
if (value === null || value === undefined || value === "") return "—";
return String(value);
}
// row renders one label/value pair. opts.key makes it editable via a
// PATCH to /api/config; opts.locked[key] disables it with the server's
// reason; opts.overridden marks a key whose file value is shadowed by the
// runtime overlay and offers a reset; no key means a plain read-only row
// (structured values and provenance).
//
// The value carries a title attribute because the column truncates with
// an ellipsis: a long path or gate command must stay recoverable without
// widening the row back into the action column.
export function row(label, value, opts) {
const text = valueText(value);
const labelEl = el("span.kv-label", label);
const valueEl = el(`span.kv-value.mono${text === "—" ? ".is-empty" : ""}`, { title: text }, text);
if (!opts?.key) return el("div.kv", labelEl, valueEl);
const lockedReason = opts.locked?.[opts.key];
if (lockedReason) {
// The reason gets its own grid line rather than sitting beside the
// value, which is what produced the run-together string above.
return el("div.kv.is-locked", labelEl, valueEl, el("span.kv-note", lockedReason));
}
const overridden = opts.overridden?.includes(opts.key);
const editBtn = el("button.kv-btn", { type: "button", title: `Edit ${label}` }, "Edit");
const resetBtn = overridden
? el("button.kv-btn", { type: "button", title: "Discard the dashboard value and fall back to the config file" }, "Reset")
: null;
const actions = el(
"div.kv-actions",
overridden && el("span.kv-flag", { title: "Set from the dashboard; this shadows the value in the config file" }, "overridden"),
editBtn,
resetBtn,
);
const rowEl = el("div.kv", labelEl, valueEl, actions);
editBtn.addEventListener("click", () => startEdit(rowEl, label, opts, [labelEl, valueEl, actions]));
resetBtn?.addEventListener("click", () => resetOverride(rowEl, resetBtn, opts));
return rowEl;
}
// resetOverride deletes one runtime-overlay row via the reset seam, then
// re-renders so the row returns to its file value. A failure reports on
// the row's own note line; the previous version overwrote the "overridden"
// marker's text with the error, destroying the marker to show it.
function resetOverride(rowEl, btn, opts) {
const { key, onSaved } = opts;
btn.disabled = true;
api
.configReset(key)
.then(() => onSaved?.())
.catch((err) => {
btn.disabled = false;
note(rowEl, String(err.message || err));
});
}
// note puts a message on the row's secondary line, creating the line if
// the row does not already have one.
function note(rowEl, message) {
let target = rowEl.querySelector?.(".kv-note");
if (!target) {
target = el("span.kv-note.is-error");
rowEl.appendChild(target);
}
target.classList.add("is-error");
target.textContent = message;
}
function startEdit(rowEl, label, opts, restore) {
const { key, type, raw, onSaved } = opts;
const input = type === "bool"
? el(
"select.kv-input",
el("option", { value: "true", selected: raw === true }, "true"),
el("option", { value: "false", selected: raw === false }, "false"),
)
: el("input.kv-input", { type: "text", value: String(raw ?? "") });
const save = el("button.kv-save", { type: "button" }, "Save");
const cancel = el("button.kv-cancel", { type: "button" }, "Cancel");
const error = el("span.kv-note.is-error");
mount(rowEl, el("span.kv-label", label), input, el("div.kv-actions", save, cancel), error);
input.focus?.();
input.select?.();
const done = () => mount(rowEl, ...restore);
cancel.addEventListener("click", done);
input.addEventListener("keydown", (e) => {
if (e.key === "Enter") {
e.preventDefault?.();
save.click();
}
if (e.key === "Escape") done();
});
save.addEventListener("click", async () => {
const parsed = parseEdit(type, input.value);
if (parsed.error) {
error.textContent = parsed.error;
return;
}
save.disabled = true;
try {
await api.configUpdate({ [key]: parsed.value });
onSaved?.();
} catch (err) {
// The server's reason (validation failure, denylisted key) is the
// part the operator can act on; show it instead of the status.
error.textContent = String(err.message || err);
save.disabled = false;
}
});
}
// parseEdit converts the input text to the JSON type the config field
// expects. Durations and strings pass through (the server validates
// duration syntax); ints are parsed client-side so a typo fails before a
// round trip.
export function parseEdit(type, text) {
switch (type) {
case "int": {
const n = parseInt(text, 10);
if (Number.isNaN(n)) return { error: "Enter a whole number" };
return { value: n };
}
case "bool":
return { value: text === "true" };
default:
return { value: text };
}
}
+134 -67
View File
@@ -1,4 +1,27 @@
/* Configuration-only styles. */
/* Configuration-only styles.
*
* Rewritten because the previous layout had three compounding faults, all
* visible on a wide screen:
*
* 1. .cfg-row used `justify-content: space-between` on a full-width card,
* so the label sat at the far left and the value at the far right with
* ~1000px of dead space between them. Pairing a label to its value meant
* tracking across the whole viewport. An earlier "tighten spacing" pass
* reduced vertical padding only, which is why it did not help.
* 2. .cfg-value had no `min-width: 0`, so a long value could not shrink
* inside its flex parent and overflowed into the Edit button, visually
* truncating the number ("400" reading as "40") and colliding with it.
* 3. The locked-row reason was a flex sibling of an overflowing value, so
* it ran straight onto the end of the path with no visible separation
* ("...archie/work" + "pins the daemon's working layout").
*
* The replacement is a three-column grid: label, value, actions. Label and
* value are adjacent and left-aligned so the eye travels a fixed short
* distance regardless of viewport width; the value column is `minmax(0, 1fr)`
* so it can actually shrink; actions occupy a reserved column so nothing can
* ever overlap them. Secondary text (locked reason, override note, error)
* gets its own grid row rather than being crammed onto the value line.
*/
.cfg-section {
margin-bottom: var(--sp-4);
@@ -8,107 +31,145 @@
font-size: var(--text-sm);
font-weight: 600;
color: var(--fg-muted);
margin: var(--sp-4) 0 var(--sp-2);
margin: var(--sp-5) 0 var(--sp-2);
}
.cfg-subhead:first-child {
margin-top: 0;
}
/* The .cfg-rows / .cfg-row class pair is shared with the Workflows
"Start work" form (form.cfg-rows, no .cfg-row children). The form
needs the 8px gap and `var(--sp-2) 0` padding for breathing room
between inputs; the Configuration page reads as dense metadata where
the border alone carries the rhythm. Keep the general rules for the
form and override under .cfg-section. */
.cfg-rows {
/* Key/value list. Capped width keeps the label-to-value distance readable
on an ultrawide monitor; without it the grid stretches and reintroduces
the very gap this rewrite exists to remove. */
.kv-list {
display: flex;
flex-direction: column;
gap: var(--sp-2);
max-width: 72rem;
}
.cfg-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: var(--sp-4);
padding: var(--sp-2) 0;
border-bottom: 1px solid var(--border);
.kv {
display: grid;
grid-template-columns: minmax(10rem, 20rem) minmax(0, 1fr) auto;
align-items: center;
column-gap: var(--sp-4);
row-gap: var(--sp-1);
padding: var(--sp-2) var(--sp-2);
border-radius: var(--radius-sm);
}
.cfg-section .cfg-rows {
gap: 0;
.kv + .kv {
border-top: 1px solid var(--border);
}
.cfg-section .cfg-row {
padding: var(--sp-1) 0;
.kv:hover {
background: var(--surface-hover);
}
.cfg-row:last-child {
border-bottom: 0;
}
.cfg-label {
.kv-label {
font-size: var(--text-sm);
color: var(--fg-muted);
}
.cfg-value {
/* min-width: 0 is load-bearing. A grid item defaults to min-width: auto,
which refuses to shrink below its content and is what pushed long paths
into the action column. */
.kv-value {
min-width: 0;
font-size: var(--text-sm);
color: var(--fg);
text-align: right;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* Inline edit affordance: value + Edit on the right, input + Save /
Cancel while editing, and the server's reason for locked rows. */
.cfg-value-cell {
.kv-value.is-empty {
color: var(--fg-subtle);
}
.kv-actions {
display: flex;
align-items: center;
justify-content: flex-end;
gap: var(--sp-2);
min-width: 0;
justify-self: end;
}
.cfg-edit {
/* Secondary line: locked reason, override note, validation error. Starts in
the value column so it aligns under the value it describes. */
.kv-note {
grid-column: 2 / -1;
font-size: var(--text-xs);
color: var(--fg-subtle);
}
.kv-note.is-error {
color: var(--danger);
}
.kv.is-locked .kv-value {
color: var(--fg-muted);
}
/* Actions stay visible rather than appearing on hover: a control that only
exists on hover is invisible to touch and to anyone scanning for what is
editable. Low contrast until the row is hovered or focused instead. */
.kv-btn {
font: inherit;
font-size: var(--text-xs);
color: var(--fg-muted);
background: var(--surface-hover);
border: 1px solid var(--border-strong);
color: var(--fg-subtle);
background: transparent;
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: 2px var(--sp-2);
cursor: pointer;
flex: none;
transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.cfg-edit:hover {
.kv:hover .kv-btn,
.kv:focus-within .kv-btn {
color: var(--fg-muted);
border-color: var(--border-strong);
}
.kv-btn:hover {
color: var(--fg);
border-color: var(--accent);
background: var(--accent-soft);
}
.cfg-editing {
flex-wrap: wrap;
.kv-btn:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 1px;
}
.cfg-input {
font: inherit;
.kv-flag {
font-size: var(--text-xs);
color: var(--warn);
background: var(--warn-soft);
border-radius: var(--radius-pill);
padding: 1px var(--sp-2);
flex: none;
}
.kv-input {
font: inherit;
font-size: var(--text-sm);
color: var(--fg);
background: var(--surface);
background: var(--bg, var(--surface));
border: 1px solid var(--border-strong);
border-radius: var(--radius-sm);
padding: var(--sp-1) var(--sp-2);
min-width: 0;
flex: 1 1 10rem;
width: 100%;
}
.cfg-input:focus {
.kv-input:focus {
outline: 2px solid var(--accent);
outline-offset: -1px;
}
.cfg-save,
.cfg-cancel {
.kv-save,
.kv-cancel {
font: inherit;
font-size: var(--text-xs);
border-radius: var(--radius-sm);
@@ -117,39 +178,28 @@
flex: none;
}
.cfg-save {
.kv-save {
background: var(--accent);
border: 1px solid var(--accent);
color: var(--accent-fg);
font-weight: 500;
}
.cfg-save:disabled {
.kv-save:disabled {
opacity: 0.6;
cursor: default;
}
.cfg-cancel {
.kv-cancel {
background: transparent;
border: 1px solid var(--border-strong);
color: var(--fg-muted);
}
.cfg-cancel:hover {
.kv-cancel:hover {
color: var(--fg);
}
.cfg-locked {
font-size: var(--text-xs);
color: var(--fg-subtle);
font-style: italic;
}
.cfg-overridden {
font-size: var(--text-xs);
color: var(--warn);
}
.cfg-notice {
border-left: 3px solid var(--warn);
}
@@ -160,9 +210,26 @@
color: var(--warn);
}
.cfg-error {
font-size: var(--text-xs);
color: var(--danger);
flex-basis: 100%;
text-align: right;
/* Narrow viewports: stack label over value so neither has to truncate to a
few characters. Actions move onto the label line to keep the row compact. */
@media (max-width: 700px) {
.kv {
grid-template-columns: minmax(0, 1fr) auto;
}
.kv-label {
grid-column: 1;
}
.kv-actions {
grid-column: 2;
grid-row: 1;
}
.kv-value,
.kv-note {
grid-column: 1 / -1;
white-space: normal;
overflow-wrap: anywhere;
}
}
+9 -127
View File
@@ -1,6 +1,7 @@
import "./settings.css";
import { api } from "../base/api.js";
import { el, empty, mount, pill } from "../base/dom.js";
import { row } from "./config-row.js";
/**
* A view of the config archied is actually running with, grouped by
@@ -92,7 +93,7 @@ function provenanceCard(origins) {
return section(
"Configuration sources",
"Applied from top to bottom; later entries take precedence over earlier ones.",
el("div.cfg-rows", ...origins.map((origin) => row(`${origin.layer} ${origin.role}${origin.feature ? ` (${origin.feature})` : ""}`, origin.path))),
el("div.kv-list", ...origins.map((origin) => row(`${origin.layer} ${origin.role}${origin.feature ? ` (${origin.feature})` : ""}`, origin.path))),
);
}
@@ -104,132 +105,13 @@ function section(title, sub, ...children) {
);
}
// row renders one label/value pair. opts.key makes it editable via a
// PATCH to /api/config; opts.locked[key] disables it with the server's
// reason; opts.overridden marks a key whose file value is shadowed by
// the runtime overlay and offers a reset; no key means a plain read-only
// row (structured values and provenance).
function row(label, value, opts) {
const labelEl = el("span.cfg-label", label);
if (!opts?.key) {
return el("div.cfg-row", labelEl, el("span.cfg-value.mono", value ?? "—"));
}
if (opts.locked?.[opts.key]) {
return el(
"div.cfg-row",
labelEl,
el(
"div.cfg-value-cell",
el("span.cfg-value.mono", value ?? "—"),
el("span.cfg-locked", opts.locked[opts.key]),
),
);
}
const display = el("span.cfg-value.mono", value ?? "—");
const editBtn = el("button.cfg-edit", { title: `Edit ${label}` }, "Edit");
const overridden = opts.overridden?.includes(opts.key);
const cell = el(
"div.cfg-value-cell",
display,
overridden && el("span.cfg-overridden", { title: "Set via the dashboard; edit the file, then reset" }, "overridden"),
editBtn,
overridden && el("button.cfg-edit", { title: "Reset to the file value" }, "Reset"),
);
const rowEl = el("div.cfg-row", labelEl, cell);
editBtn.addEventListener("click", () => startEdit(rowEl, cell, label, opts));
if (overridden) {
const resetBtn = cell.lastChild;
resetBtn.addEventListener("click", () => resetOverride(resetBtn, opts));
}
return rowEl;
}
// resetOverride deletes one runtime-overlay row via the reset seam, then
// re-renders so the row returns to its file value. Errors show inline in
// the row's marker slot.
function resetOverride(btn, opts) {
const { key, onSaved } = opts;
const marker = btn.parentElement.querySelector(".cfg-overridden");
btn.disabled = true;
api
.configReset(key)
.then(() => onSaved?.())
.catch((err) => {
btn.disabled = false;
if (marker) {
marker.textContent = String(err.message || err);
marker.classList.add("cfg-error");
}
});
}
function startEdit(rowEl, cell, label, opts) {
const { key, type, raw, onSaved } = opts;
const input = type === "bool"
? el(
"select.cfg-input",
el("option", { value: "true", selected: raw === true }, "true"),
el("option", { value: "false", selected: raw === false }, "false"),
)
: el("input.cfg-input", { type: "text", value: String(raw ?? "") });
const save = el("button.cfg-save", { type: "button" }, "Save");
const cancel = el("button.cfg-cancel", { type: "button" }, "Cancel");
const error = el("span.cfg-error");
const editing = el("div.cfg-value-cell.cfg-editing", input, save, cancel, error);
rowEl.replaceChild(editing, cell);
input.focus();
const done = () => rowEl.replaceChild(cell, editing);
cancel.addEventListener("click", done);
input.addEventListener("keydown", (e) => {
if (e.key === "Enter") save.click();
if (e.key === "Escape") done();
});
save.addEventListener("click", async () => {
const parsed = parseEdit(type, input.value);
if (parsed.error) {
error.textContent = parsed.error;
return;
}
save.disabled = true;
try {
await api.configUpdate({ [key]: parsed.value });
onSaved?.();
} catch (err) {
// The server's reason (validation failure, denylisted key) is the
// part the operator can act on; show it instead of the status.
error.textContent = String(err.message || err);
save.disabled = false;
}
});
}
// parseEdit converts the input text to the JSON type the config field
// expects. Durations and strings pass through (the server validates
// duration syntax); ints are parsed client-side so a typo fails before
// a round trip.
function parseEdit(type, text) {
switch (type) {
case "int": {
const n = parseInt(text, 10);
if (Number.isNaN(n)) return { error: "Enter a whole number" };
return { value: n };
}
case "bool":
return { value: text === "true" };
default:
return { value: text };
}
}
function identityCard(identity, ctx) {
if (!identity) return section("Identity", "Who Archie is on the forge.", empty("Not available"));
return section(
"Identity",
"Who Archie is on the forge, and how it addresses commits and comments.",
el(
"div.cfg-rows",
"div.kv-list",
row("Bot account", identity.bot_user, { key: "bot_user", type: "string", raw: identity.bot_user, ...ctx }),
row("Commit author email", identity.bot_email, { key: "bot_email", type: "string", raw: identity.bot_email, ...ctx }),
row("Pickup label", identity.label, { key: "label", type: "string", raw: identity.label, ...ctx }),
@@ -287,7 +169,7 @@ function modelsAndProvidersCard(models, providers) {
const providerEntries = Object.entries(providers || {});
const modelRows = modelEntries.length
? el("div.cfg-rows", ...modelEntries.map(([role, ref]) => row(roleLabel(role), ref)))
? el("div.kv-list", ...modelEntries.map(([role, ref]) => row(roleLabel(role), ref)))
: empty("No model roles configured", "Assign a model to at least one role (e.g. \"builder\") in [models].");
const providerRows = providerEntries.length
@@ -334,7 +216,7 @@ function budgetsCard(budgets, ctx) {
"Budgets",
"The limits every autonomous stage runs under, so a stuck task cannot run forever.",
el(
"div.cfg-rows",
"div.kv-list",
row("Max steps", budgets.max_steps || "Unlimited", { key: "budgets.max_steps", type: "int", raw: budgets.max_steps, ...ctx }),
row("Max tokens", budgets.max_tokens || "Unlimited", { key: "budgets.max_tokens", type: "int", raw: budgets.max_tokens, ...ctx }),
row("Wall clock", budgets.wall_clock, { key: "budgets.wall_clock", type: "string", raw: budgets.wall_clock, ...ctx }),
@@ -349,7 +231,7 @@ function agentCard(agent, ctx) {
"Agent execution",
"How archied actually runs a stage of work.",
el(
"div.cfg-rows",
"div.kv-list",
row("Execution mode", agentModeLabel(agent.mode), { key: "agent.mode", type: "string", raw: agent.mode, ...ctx }),
row("Worker command", agent.command, { key: "agent.command", type: "string", raw: agent.command, ...ctx }),
row("Extra environment variables passed through", agent.env?.length ? agent.env.join(", ") : "None"),
@@ -376,7 +258,7 @@ function storageCard(storage, containers, ctx) {
children.push(
el("h3.cfg-subhead", "Paths"),
el(
"div.cfg-rows",
"div.kv-list",
row("Work directory", storage.work_dir, { key: "work_dir", type: "string", ...ctx }),
row("State path prefix", storage.db_path, { key: "db_path", type: "string", ...ctx }),
row("Shared skills directory", storage.skills_dir || "None (uses the work directory)", { key: "skills_dir", type: "string", raw: storage.skills_dir, ...ctx }),
@@ -389,7 +271,7 @@ function storageCard(storage, containers, ctx) {
children.push(
el("h3.cfg-subhead", "Sandboxed containers"),
el(
"div.cfg-rows",
"div.kv-list",
row("Sandboxing enabled", containers.enabled ? "Yes" : "No", { key: "containers.enabled", type: "bool", raw: containers.enabled, ...ctx }),
row("Agent image", containers.image || "Not set", { key: "containers.image", type: "string", raw: containers.image, ...ctx }),
row("Max concurrent tasks", containers.max_concurrency || "Unlimited", { key: "containers.max_concurrency", type: "int", raw: containers.max_concurrency, ...ctx }),
@@ -414,6 +296,6 @@ function webCard(web, ctx) {
return section(
"Dashboard",
"This dashboard's own listen address.",
el("div.cfg-rows", row("Listen address", web.listen === "off" ? "Disabled" : web.listen, { key: "web.listen", type: "string", raw: web.listen === "off" ? "" : web.listen, ...ctx })),
el("div.kv-list", row("Listen address", web.listen === "off" ? "Disabled" : web.listen, { key: "web.listen", type: "string", raw: web.listen === "off" ? "" : web.listen, ...ctx })),
);
}
+9
View File
@@ -47,3 +47,12 @@
.wf-bar-info {
background: var(--info);
}
/* Stacked form for "Start work". This was .cfg-rows, a class owned by the
Configuration page, so restyling Configuration could silently restyle
this form. Named for what it is and owned by this feature instead. */
.wf-form {
display: flex;
flex-direction: column;
gap: var(--sp-2);
}
+1 -1
View File
@@ -97,7 +97,7 @@ export function workflowsPage() {
const instructions = el("textarea", { placeholder: "Instructions for the work", required: true, rows: 3 });
const notice = el("p.card-sub");
const submit = el("button.btn", { type: "submit" }, "Start work");
const form = el("form.cfg-rows", {
const form = el("form.wf-form", {
onsubmit: async (event) => {
event.preventDefault();
submit.disabled = true;
+94
View File
@@ -0,0 +1,94 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import "./shim.js";
import { row, valueText, parseEdit } from "../src/settings/config-row.js";
// Walks a rendered row and returns the concatenated text of each direct
// child, so a test can assert on the row's *structure* rather than on a
// flattened string. The bugs this file guards against were all cases of
// two fields rendering as one visual run.
function cells(rowEl) {
return rowEl.childNodes.map((child) => text(child));
}
function text(node) {
return node.textContent ?? "";
}
function classOf(node) {
return node.className || "";
}
test("a locked row keeps its reason in a separate element from the value", () => {
// Regression: the reason used to sit beside an overflowing value and
// render as "/home/sam/.local/share/archie/workpins the daemon's
// working layout". Assert on the cell count and per-cell text, never on
// the row's flattened text, so a future layout change cannot pass by
// merging them back into one node.
const rowEl = row("Work directory", "/home/sam/.local/share/archie/work", {
key: "work_dir",
locked: { work_dir: "pins the daemon's working layout; cannot be changed at runtime" },
});
const parts = cells(rowEl);
assert.equal(parts.length, 3, "expected label, value and note as separate children");
assert.equal(parts[0], "Work directory");
assert.equal(parts[1], "/home/sam/.local/share/archie/work");
assert.equal(parts[2], "pins the daemon's working layout; cannot be changed at runtime");
assert.ok(classOf(rowEl).includes("is-locked"));
});
test("a locked row offers no edit control", () => {
const rowEl = row("State path prefix", "/home/sam/.local/share/archie/archie.db", {
key: "db_path",
locked: { db_path: "required for bootstrap" },
});
assert.equal(rowEl.childNodes.filter((c) => classOf(c).includes("kv-actions")).length, 0);
});
test("an editable row separates value from its actions", () => {
// Regression: the value overflowed into the action column, so "400"
// rendered as "40" with Edit sitting on top of the last digit. Assert
// the value and the actions are distinct children.
const rowEl = row("Max diff size (lines)", 400, { key: "diff_cap_lines", type: "int", raw: 400 });
const parts = cells(rowEl);
assert.equal(parts.length, 3);
assert.equal(parts[1], "400", "the value must not be merged with the action label");
assert.equal(parts[2], "Edit");
});
test("an overridden row shows the marker and a reset alongside edit", () => {
const rowEl = row("Max steps", 90, {
key: "budgets.max_steps",
type: "int",
raw: 90,
overridden: ["budgets.max_steps"],
});
const actions = rowEl.childNodes.find((c) => classOf(c).includes("kv-actions"));
assert.deepEqual(actions.childNodes.map(text), ["overridden", "Edit", "Reset"]);
});
test("the full value is recoverable from the title when the column truncates", () => {
const long = "go vet ./... → go build ./... → go test ./... -count=1";
const rowEl = row("Quality gate", long);
const value = rowEl.childNodes.find((c) => classOf(c).includes("kv-value"));
assert.equal(value.attrs.title, long);
});
test("zero and false are real values, not missing ones", () => {
// `value ?? "—"` handled these, but a `value || "—"` refactor would
// silently turn a configured 0 into "not set". Pin the distinction.
assert.equal(valueText(0), "0");
assert.equal(valueText(false), "false");
assert.equal(valueText(""), "—");
assert.equal(valueText(null), "—");
assert.equal(valueText(undefined), "—");
});
test("int edits reject a non-numeric entry before the round trip", () => {
assert.equal(parseEdit("int", "12").value, 12);
assert.ok(parseEdit("int", "twelve").error);
assert.equal(parseEdit("bool", "true").value, true);
assert.equal(parseEdit("bool", "false").value, false);
assert.equal(parseEdit("string", "1h0m0s").value, "1h0m0s");
});