refactor(ui): extract Pill to ui/src/base/, closing archie-core-mlro

Pill was independently duplicated byte-for-byte across 11 files
(tasks, logs, mapping-editor, capture-row, settings, update-status,
skills, dashboard, memory, channels, curators) plus the bindings page
built earlier this session -- a violation of organisation.md's
"extract on the second distinct consumer" rule, predating this
session entirely. Found while building the bindings UI.

Mechanical extraction only, no behavior change: ui/src/base/pill.jsx
is now the single definition; every call site imports from there.
skills.jsx's copy used `class=` instead of `className=` (functionally
identical in Preact) -- normalized to the shared version's className.
captures.jsx's import of Pill (previously re-exported through
capture-row.jsx) now points at the shared module directly.

Verified via task test:ui (120/120 unchanged) and, since this touches
the exact rendering path that had a real app-wide regression earlier
tonight (commit 4fa478a), re-verified in a real browser across all 12
pages: zero "[object Object]" occurrences, and every page's .pill
elements render with real content (settings: 9, bindings: 2, etc.),
not just "the build succeeded."
This commit is contained in:
sam committed 2026-09-03 06:25:21 +10:00
1 parent e8f1c09a5b
commit cc95f854de
15 files changed
+33 -54

No files matched your search

+6 -6
View File
@@ -6,11 +6,11 @@
stroke-width="12" stroke-linecap="round"
stroke-dasharray="${s}"
stroke-dashoffset="${s*(1-r/100)}"
class="gauge-value"/>`,H(`div.gauge-wrap`,l,H(`div.gauge-center`,H(`div.gauge-pct`,`${Math.round(r)}%`),H(`div.gauge-label`,t)))}function Ye(e){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return H(`div`,H(`div.segbar`,...e.filter(e=>e.value>0).map(e=>H(`span`,{class:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`}))),H(`div.segbar-legend`,...e.map(e=>H(`span.segbar-key`,H(`span`,{class:`segbar-dot segbar-${e.kind||`idle`}`}),e.label))))}var Xe=`archie.setup-complete.dismissed.v1`;function Ze(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?.(Xe),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function Qe(e=globalThis.localStorage){e?.setItem?.(Xe,`1`)}var $e=new Set([`waiting_human`,`parked`]);function et(e=[]){let t=e.filter(e=>$e.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`}}}var tt=0;Array.isArray;function Z(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--tt,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}function nt({node:e}){let t=X();return Y(()=>{t.current&&e&&t.current.replaceChildren(e)},[e]),Z(`div`,{ref:t,style:{display:`contents`}})}function rt(e){return Z(nt,{node:Ke(e)})}function it(e){return Z(nt,{node:Je(e)})}function at({segments:e}){return Z(nt,{node:Ye(e)})}function ot({name:e,opts:t}){return Z(nt,{node:G(e,t)})}function st({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function ct({text:e,kind:t=`idle`}){return Z(`span`,{className:`pill pill-${t}`,children:e})}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]=J([]),[n,r]=J(`connecting`),[i,a]=J(`idle`),[o,s]=J(new Map),[c,l]=J(null),[u,d]=J(null),[f,p]=J(null),[m,h]=J(null),[g,_]=J(null),[,v]=J(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([V.summary(),V.setup().catch(()=>null),V.workflows().catch(()=>null),V.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))}};Y(()=>(y(),le(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{Qe(),v(e=>!e)},x=u?.operator?`${ut()}, ${u.operator}`:ut(),C=null;if(g)C=Z(`button`,{className:`btn btn-primary`,onClick:y,children:[Z(ot,{name:`refresh`,opts:{size:15}}),` Retry`]});else if(m!==null){let e=et(m),t=e.attention.count,n=e.running.count;C=Z(S,{children:[t>0&&Z(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[Z(ot,{name:`tasks`,opts:{size:15}}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&Z(`a`,{className:`btn`,href:e.running.href,children:[Z(ot,{name:`workflows`,opts:{size:15}}),` `,n,` running`]}),Z(`a`,{className:`btn`,href:`#/logs`,children:[Z(ot,{name:`logs`,opts:{size:15}}),` Logs`]}),Z(`button`,{className:`btn btn-primary`,onClick:y,children:[Z(ot,{name:`refresh`,opts:{size:15}}),` Refresh`]})]})}let w=null;if(g)w=Z(`div`,{className:`card`,children:Z(st,{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=Z(S,{children:[Z(rt,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),Z(rt,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),Z(rt,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),Z(rt,{label:`Tokens used`,value:Ce(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=Ze(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=Z(`div`,{className:`card setup`,children:[Z(`div`,{className:`card-head`,childre Line truncated
`),children:[Z(`td`,{className:`strong`,children:e.label||e.id}),Z(`td`,{className:`mono`,children:e.install_type||`—`}),Z(`td`,{className:`mono`,children:e.running_version||`—`}),Z(`td`,{className:`mono`,children:e.latest_available||`—`}),Z(`td`,{children:Z(un,{text:pn[e.status]||e.status,kind:mn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function gn({text:e,kind:t=`idle`}){return Z(`span`,{className:`pill pill-${t}`,children:e})}function Q({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function $({title:e,sub:t,children:n}){return Z(`div`,{className:`card cfg-section`,children:[Z(`div`,{className:`card-head`,children:Z(`div`,{children:[Z(`h2`,{className:`card-title`,children:e}),Z(`p`,{className:`card-sub`,children:t})]})}),n]})}function _n({origins:e}){return e?.length?Z($,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:Z(`div`,{className:`kv-list`,children:e.map((e,t)=>Z(cn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):Z($,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:Z(Q,{title:`Source provenance is unavailable.`})})}function vn(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function yn({data:e,error:t}){if(t)return Z($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:Z(Q,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return Z($,{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:[Z(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?Z(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??_e(e.id),n=e.kind??ve(e.id);return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,children:e.id}),Z(`span`,{className:`kv-value`,children:Z(gn,{text:t,kind:n})})]},e.id)})}):Z(Q,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),Z(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?Z(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=vn(e.kind);return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,children:e.id}),Z(`span`,{className:`kv-value`,children:Z(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):Z(Q,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function bn({r:e,field:t,onSaved:n}){let[r,i]=J(!1),[a,o]=J(null),[s,c]=J(!!e[t]);return Z(`td`,{children:[Z(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:s,onChange:async r=>{let a=r.target.checked;c(a),i(!0),o(null);try{await V.configRepoUpdate(e.owner,e.name,t,a),n?.()}catch(e){c(!a),o(String(e.message||e))}finally{i(!1)}},disabled:r}),a&&Z(`span`,{className:`kv-note is-error`,children:a})]})}function xn({r:e,field:t,onSaved:n}){let[r,i]=J(String(e[t]??0)),[a,o]=J(null),[s,c]=J(!1);return Z(`td`,{children:[Z(`input`,{className:`kv-input`,type:`text`,value:r,onChange:e=>i(e.target.value),onBlur:async()=>{let i=parseInt(r,10);if(Number.isNaN(i)){o(`Enter a whole number`);return}c(!0),o(null);try{await V.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){o(String(e.message||e))}finally{c(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:s}),a&&Z(`span`,{className:`kv-note is-error`,children:a})]})}function Sn({repos:e,onSaved:t}){if(!e?.length)return Z($,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:Z(Q,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let n=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return Z($,{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:Z(`div`,{className:`table-scroll`,children:Z(`table`,{className:`table`,children:[Z(`thead`,{children:Z(`tr`,{children:[Z(`th`,{children:`Repository`}),Z(`th`,{children:`Base branch`}),Z(`th`,{children:`Ecosystem`}),Z(`th`,{children:`Quality gate`}),Z(`th`,{children:`Protected paths`}),Z(`th`,{children:`Concurrent`}),Z(`th`,{children:`Max retries`}),Z(`th`,{children:`Self-review`})]})}),Z(`tbody`,{children:e.map((e,r)=>Z(`tr`,{children:[Z(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),Z(`td`,{className:`mono`,children:e.base}),Z(`td`,{children:e.ecosystem||`go`}),Z(`td`,{className:`mono`,children:n(e.gate)}),Z(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),Z(bn,{r:e,field:`allow_concurrent`,onSaved:t}),Z( Line truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.append(H(`p`,vr(r.join(` `)))),r=[])},s=()=>{i&&t.append(i),i=null};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.append(H(`pre`,H(`code`,a.join(`
`)))),a=null):a=[];continue}if(a){a.push(c);continue}let l=br(c),u=e+1<n.length?br(n[e+1]):null;if(l&&u&&xr(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=br(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}let i=H(`tbody`);for(let e of r)i.append(H(`tr`,...e.map(e=>H(`td`,vr(e)))));t.append(H(`table`,H(`thead`,H(`tr`,...l.map(e=>H(`th`,vr(e))))),i));continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.append(H(`h${d[1].length}`,vr(d[2])));continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tagName.toLowerCase()!==e)&&(s(),i=H(e)),i.append(H(`li`,vr((f||p)[1])));continue}if(c.startsWith(`>`)){o(),s(),t.append(H(`blockquote`,vr(c.replace(/^>\s?/,``))));continue}r.push(c)}return o(),s(),a&&t.append(H(`pre`,H(`code`,a.join(`
`)))),t}function br(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 xr(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Sr=`archie.web.chat.channel`;function Cr(){let e=localStorage.getItem(Sr);return e||(e=se(),localStorage.setItem(Sr,e)),e}function wr(e){return{text:e,sourceID:se()}}function Tr(e){return{...e}}function Er(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?Tr(e.turn):wr(r),isRetry:n}}function Dr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function Or(e){return e?.status===501?null:`Could not check for updates.`}function kr(){return location.hash.slice(1)||`/`}function Ar({text:e}){let t=X(null);return Y(()=>{t.current&&t.current.replaceChildren(yr(e||``))},[e]),Z(`div`,{ref:t,style:{display:`contents`}})}function jr(){let[e,t]=J([]),[n,r]=J(``),[i,a]=J([]),[o,s]=J(``),[c,l]=J(`Ready`),[u,d]=J(!1),[f,p]=J({}),[m,h]=J(``),[g,_]=J(``),[v,y]=J(``),[b,x]=J([]),[C,w]=J([]),[T,E]=J(0),[D,O]=J(!1),[k,A]=J(null),[j,ee]=J(null),[M,N]=J(null),[P,te]=J(``),[ne,re]=J(``),[F,I]=J(null),ie=X(null),L=X(null),ae=X(null),oe=X(null),se=X(null),R=X(u);R.current=u,Y(()=>{ie.current&&(ie.current.scrollTop=ie.current.scrollHeight)},[i,F]),Y(()=>{fe().catch(e=>{l(e.message||`Chat unavailable`)}),ce();let e=()=>{ae.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),ae.current?.abort()}},[]);async function ce(){try{let e=await V.chatUpdate();ee(e?.snapshot||null),A(e)}catch(e){let t=Or(e);A(t?{error:t}:null)}}async function z(){if(j)try{await V.chatUpdateDefer(j),A({snapshot:{deferred:!0},available:[]}),l(`Update deferred`)}catch(e){l(e.message||`Could not defer update`)}}async function B(){if(j)try{l(`Installing…`);let e=await V.chatUpdateInstall(j);ee(null),A({snapshot:{},available:[]}),l(e?.result?.restart_requested?`Update installed; restart queued`:`Update complete`)}catch(e){l(e.message||`Update install failed`)}}async function le(){try{let e=await V.chatDangerous();N(e)}catch(e){N({error:e.message||`Dangerous actions unavailable`})}}async function ue(e,t){if(t)try{await V.chatDangerousRequest(e,t),l(`Approval requested`),await le()}catch(e){l(e.message||`Could not request action`)}}async function de(e,t){try{await V.chatDangerousDecision(e,t),l(t===`deny`?`Action denied`:`Action approved`),await le()}catch(e){l(e.message||`Approval failed`)}}async function fe(){let e=await V.chatSessions(),r=e.sessions||[];t(r),p(e),h(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;_(a),y(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);x(o),e.dangerous_available&&await le(),!n&&r[0]&&await pe(r[0].session_id,e,r)}async function pe(e,t,n){let i=t||f;r(e),a([]),I(null);let o=i.active_personas?.[e]||i.active_persona||``;h(o);try{await V.chatMessage(Cr(),`/resume ${e}`);let[t,n]=await Promise.all([V.chatMessages(e),V.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 me(e){if(n)try{l(`Working…`);let t=await V.chatMessage(Cr(),e);t.session_id&&r(t.session_id),l(t.reply||`Session updated`),await fe(),(t.session_id||n)&&await pe(t.session_id||n),oe.current&&(oe.current.open=!1)}catch(e){l(e.message||`Session action failed`)}}function he(e,t){let n=window.prompt(t);n?.trim()&&me(`${e} ${n.trim()}`)}function ge(e){let t=e.target.value;h(t),!(!n||!t)&&V.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 _e(e){let t=e.target.value;if(_(t),t)try{let e=await V.chatMessage(Cr(),`/model --provider ${t}`);l(e.reply||`Provider updated`),await fe()}catch(e){l(`Provider update failed: ${e.message||e}`)}}async function ve(e){let t=e.target.value;if(y(t),t)try{let e=await V.chatMessage(Cr(),`/model ${t}`);l(e.reply||`Model updated`),await fe()}catch(e){l(`Model update failed: ${e.message||e}`)}}function ye(){window.confirm(`Reload the Telegram chat adapter?`)&&(s(`/restart`),U({textOverride:`/restart`}))}function be(){s(`/new`),U({textOverride:`/new`})}function xe(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 H(e){let t=C[e];if(!t||!L.current)return;let n=L.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.s Line truncated
class="gauge-value"/>`,H(`div.gauge-wrap`,l,H(`div.gauge-center`,H(`div.gauge-pct`,`${Math.round(r)}%`),H(`div.gauge-label`,t)))}function Ye(e){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return H(`div`,H(`div.segbar`,...e.filter(e=>e.value>0).map(e=>H(`span`,{class:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`}))),H(`div.segbar-legend`,...e.map(e=>H(`span.segbar-key`,H(`span`,{class:`segbar-dot segbar-${e.kind||`idle`}`}),e.label))))}var Xe=0;Array.isArray;function Z(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Xe,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}function Q({text:e,kind:t=`idle`}){return Z(`span`,{className:`pill pill-${t}`,children:e})}var Ze=`archie.setup-complete.dismissed.v1`;function Qe(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?.(Ze),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function $e(e=globalThis.localStorage){e?.setItem?.(Ze,`1`)}var et=new Set([`waiting_human`,`parked`]);function tt(e=[]){let t=e.filter(e=>et.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 nt({node:e}){let t=X();return Y(()=>{t.current&&e&&t.current.replaceChildren(e)},[e]),Z(`div`,{ref:t,style:{display:`contents`}})}function rt(e){return Z(nt,{node:Ke(e)})}function it(e){return Z(nt,{node:Je(e)})}function at({segments:e}){return Z(nt,{node:Ye(e)})}function ot({name:e,opts:t}){return Z(nt,{node:G(e,t)})}function st({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function ct(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 lt(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function ut(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 dt(){let[e,t]=J([]),[n,r]=J(`connecting`),[i,a]=J(`idle`),[o,s]=J(new Map),[c,l]=J(null),[u,d]=J(null),[f,p]=J(null),[m,h]=J(null),[g,_]=J(null),[,v]=J(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([V.summary(),V.setup().catch(()=>null),V.workflows().catch(()=>null),V.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))}};Y(()=>(y(),le(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{$e(),v(e=>!e)},x=u?.operator?`${lt()}, ${u.operator}`:lt(),C=null;if(g)C=Z(`button`,{className:`btn btn-primary`,onClick:y,children:[Z(ot,{name:`refresh`,opts:{size:15}}),` Retry`]});else if(m!==null){let e=tt(m),t=e.attention.count,n=e.running.count;C=Z(S,{children:[t>0&&Z(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[Z(ot,{name:`tasks`,opts:{size:15}}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&Z(`a`,{className:`btn`,href:e.running.href,children:[Z(ot,{name:`workflows`,opts:{size:15}}),` `,n,` running`]}),Z(`a`,{className:`btn`,href:`#/logs`,children:[Z(ot,{name:`logs`,opts:{size:15}}),` Logs`]}),Z(`button`,{className:`btn btn-primary`,onClick:y,children:[Z(ot,{name:`refresh`,opts:{size:15}}),` Refresh`]})]})}let w=null;if(g)w=Z(`div`,{className:`card`,children:Z(st,{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=Z(S,{children:[Z(rt,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),Z(rt,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),Z(rt,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),Z(rt,{label:`Tokens used`,value:Ce(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:ut(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let T=null,E=Qe(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=Z(`div`,{className:`card setup`,children:[Z(`div`,{className:`card-head`,children Line truncated
`),children:[Z(`td`,{className:`strong`,children:e.label||e.id}),Z(`td`,{className:`mono`,children:e.install_type||`—`}),Z(`td`,{className:`mono`,children:e.running_version||`—`}),Z(`td`,{className:`mono`,children:e.latest_available||`—`}),Z(`td`,{children:Z(Q,{text:sn[e.status]||e.status,kind:cn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function $({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function un({title:e,sub:t,children:n}){return Z(`div`,{className:`card cfg-section`,children:[Z(`div`,{className:`card-head`,children:Z(`div`,{children:[Z(`h2`,{className:`card-title`,children:e}),Z(`p`,{className:`card-sub`,children:t})]})}),n]})}function dn({origins:e}){return e?.length?Z(un,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:Z(`div`,{className:`kv-list`,children:e.map((e,t)=>Z(nn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):Z(un,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:Z($,{title:`Source provenance is unavailable.`})})}function fn(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function pn({data:e,error:t}){if(t)return Z(un,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:Z($,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return Z(un,{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:[Z(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?Z(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??_e(e.id),n=e.kind??ve(e.id);return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,children:e.id}),Z(`span`,{className:`kv-value`,children:Z(Q,{text:t,kind:n})})]},e.id)})}):Z($,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),Z(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?Z(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=fn(e.kind);return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,children:e.id}),Z(`span`,{className:`kv-value`,children:Z(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):Z($,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function mn({r:e,field:t,onSaved:n}){let[r,i]=J(!1),[a,o]=J(null),[s,c]=J(!!e[t]);return Z(`td`,{children:[Z(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:s,onChange:async r=>{let a=r.target.checked;c(a),i(!0),o(null);try{await V.configRepoUpdate(e.owner,e.name,t,a),n?.()}catch(e){c(!a),o(String(e.message||e))}finally{i(!1)}},disabled:r}),a&&Z(`span`,{className:`kv-note is-error`,children:a})]})}function hn({r:e,field:t,onSaved:n}){let[r,i]=J(String(e[t]??0)),[a,o]=J(null),[s,c]=J(!1);return Z(`td`,{children:[Z(`input`,{className:`kv-input`,type:`text`,value:r,onChange:e=>i(e.target.value),onBlur:async()=>{let i=parseInt(r,10);if(Number.isNaN(i)){o(`Enter a whole number`);return}c(!0),o(null);try{await V.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){o(String(e.message||e))}finally{c(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:s}),a&&Z(`span`,{className:`kv-note is-error`,children:a})]})}function gn({repos:e,onSaved:t}){if(!e?.length)return Z(un,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:Z($,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let n=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return Z(un,{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:Z(`div`,{className:`table-scroll`,children:Z(`table`,{className:`table`,children:[Z(`thead`,{children:Z(`tr`,{children:[Z(`th`,{children:`Repository`}),Z(`th`,{children:`Base branch`}),Z(`th`,{children:`Ecosystem`}),Z(`th`,{children:`Quality gate`}),Z(`th`,{children:`Protected paths`}),Z(`th`,{children:`Concurrent`}),Z(`th`,{children:`Max retries`}),Z(`th`,{children:`Self-review`})]})}),Z(`tbody`,{children:e.map((e,r)=>Z(`tr`,{children:[Z(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),Z(`td`,{className:`mono`,children:e.base}),Z(`td`,{children:e.ecosystem||`go`}),Z(`td`,{className:`mono`,children:n(e.gate)}),Z(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),Z(mn,{r:e,field:`allow_concurrent`,onSaved:t}),Z(hn,{r:e,field:`max_retries`,onSaved:t}),Z(mn,{r:e,field:`review_enabled`,onSaved:t})]},r Line truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.append(H(`p`,sr(r.join(` `)))),r=[])},s=()=>{i&&t.append(i),i=null};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.append(H(`pre`,H(`code`,a.join(`
`)))),a=null):a=[];continue}if(a){a.push(c);continue}let l=lr(c),u=e+1<n.length?lr(n[e+1]):null;if(l&&u&&ur(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=lr(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}let i=H(`tbody`);for(let e of r)i.append(H(`tr`,...e.map(e=>H(`td`,sr(e)))));t.append(H(`table`,H(`thead`,H(`tr`,...l.map(e=>H(`th`,sr(e))))),i));continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.append(H(`h${d[1].length}`,sr(d[2])));continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tagName.toLowerCase()!==e)&&(s(),i=H(e)),i.append(H(`li`,sr((f||p)[1])));continue}if(c.startsWith(`>`)){o(),s(),t.append(H(`blockquote`,sr(c.replace(/^>\s?/,``))));continue}r.push(c)}return o(),s(),a&&t.append(H(`pre`,H(`code`,a.join(`
`)))),t}function lr(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function ur(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var dr=`archie.web.chat.channel`;function fr(){let e=localStorage.getItem(dr);return e||(e=se(),localStorage.setItem(dr,e)),e}function pr(e){return{text:e,sourceID:se()}}function mr(e){return{...e}}function hr(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?mr(e.turn):pr(r),isRetry:n}}function gr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function _r(e){return e?.status===501?null:`Could not check for updates.`}function vr(){return location.hash.slice(1)||`/`}function yr({text:e}){let t=X(null);return Y(()=>{t.current&&t.current.replaceChildren(cr(e||``))},[e]),Z(`div`,{ref:t,style:{display:`contents`}})}function br(){let[e,t]=J([]),[n,r]=J(``),[i,a]=J([]),[o,s]=J(``),[c,l]=J(`Ready`),[u,d]=J(!1),[f,p]=J({}),[m,h]=J(``),[g,_]=J(``),[v,y]=J(``),[b,x]=J([]),[C,w]=J([]),[T,E]=J(0),[D,O]=J(!1),[k,A]=J(null),[j,ee]=J(null),[M,N]=J(null),[P,te]=J(``),[ne,re]=J(``),[F,I]=J(null),ie=X(null),L=X(null),ae=X(null),oe=X(null),se=X(null),R=X(u);R.current=u,Y(()=>{ie.current&&(ie.current.scrollTop=ie.current.scrollHeight)},[i,F]),Y(()=>{fe().catch(e=>{l(e.message||`Chat unavailable`)}),ce();let e=()=>{ae.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),ae.current?.abort()}},[]);async function ce(){try{let e=await V.chatUpdate();ee(e?.snapshot||null),A(e)}catch(e){let t=_r(e);A(t?{error:t}:null)}}async function z(){if(j)try{await V.chatUpdateDefer(j),A({snapshot:{deferred:!0},available:[]}),l(`Update deferred`)}catch(e){l(e.message||`Could not defer update`)}}async function B(){if(j)try{l(`Installing…`);let e=await V.chatUpdateInstall(j);ee(null),A({snapshot:{},available:[]}),l(e?.result?.restart_requested?`Update installed; restart queued`:`Update complete`)}catch(e){l(e.message||`Update install failed`)}}async function le(){try{let e=await V.chatDangerous();N(e)}catch(e){N({error:e.message||`Dangerous actions unavailable`})}}async function ue(e,t){if(t)try{await V.chatDangerousRequest(e,t),l(`Approval requested`),await le()}catch(e){l(e.message||`Could not request action`)}}async function de(e,t){try{await V.chatDangerousDecision(e,t),l(t===`deny`?`Action denied`:`Action approved`),await le()}catch(e){l(e.message||`Approval failed`)}}async function fe(){let e=await V.chatSessions(),r=e.sessions||[];t(r),p(e),h(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;_(a),y(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);x(o),e.dangerous_available&&await le(),!n&&r[0]&&await pe(r[0].session_id,e,r)}async function pe(e,t,n){let i=t||f;r(e),a([]),I(null);let o=i.active_personas?.[e]||i.active_persona||``;h(o);try{await V.chatMessage(fr(),`/resume ${e}`);let[t,n]=await Promise.all([V.chatMessages(e),V.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 me(e){if(n)try{l(`Working…`);let t=await V.chatMessage(fr(),e);t.session_id&&r(t.session_id),l(t.reply||`Session updated`),await fe(),(t.session_id||n)&&await pe(t.session_id||n),oe.current&&(oe.current.open=!1)}catch(e){l(e.message||`Session action failed`)}}function he(e,t){let n=window.prompt(t);n?.trim()&&me(`${e} ${n.trim()}`)}function ge(e){let t=e.target.value;h(t),!(!n||!t)&&V.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 _e(e){let t=e.target.value;if(_(t),t)try{let e=await V.chatMessage(fr(),`/model --provider ${t}`);l(e.reply||`Provider updated`),await fe()}catch(e){l(`Provider update failed: ${e.message||e}`)}}async function ve(e){let t=e.target.value;if(y(t),t)try{let e=await V.chatMessage(fr(),`/model ${t}`);l(e.reply||`Model updated`),await fe()}catch(e){l(`Model update failed: ${e.message||e}`)}}function ye(){window.confirm(`Reload the Telegram chat adapter?`)&&(s(`/restart`),U({textOverride:`/restart`}))}function be(){s(`/new`),U({textOverride:`/new`})}function xe(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 H(e){let t=C[e];if(!t||!L.current)return;let n=L.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.s Line truncated
`);s=i.pop()||``;for(let e of i){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,I(e=>e?{...e,text:f}:null)),n.type===`tool`&&(u=[...u,n],I(e=>e?{...e,tools:u}:null)),n.type===`navigate`&&(u=[...u,n],I(e=>e?{...e,tools:u}:null)),n.type===`done`&&(p=!0,f||=n.text),n.type===`error`)throw Error(n.text)}if(t)break}if(!p)throw Error(`chat stream ended before completion`);a(e=>[...e,{from:`assistant`,text:f,tool_calls:u}]),I(null),l(`Ready`),await fe()}catch(e){if(e.name===`AbortError`&&!m)I({text:`Turn stopped.`,tools:u,isError:!1,turn:i,isRetry:c}),l(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;I({text:t,tools:u,isError:!0,turn:Tr(i),isRetry:c}),l(`Error — retry available`)}}finally{clearTimeout(h),ae.current=null,d(!1),L.current&&L.current.focus()}}function W(){l(`Stopping…`),n&&V.chatCancel(n).catch(()=>{}),ae.current?.abort()}let Ce=f.models_by_provider||{},we=g&&Ce[g]?Ce[g]:f.models||[];return Z(`div`,{className:`chat-page-content`,children:[Z(`header`,{className:`chat-topbar`,children:[Z(`div`,{children:[Z(`span`,{className:`chat-kicker`,children:`ARCHIE WORKSPACE`}),Z(`h1`,{className:`page-title`,children:`Chat`})]}),Z(`div`,{className:`chat-topbar-actions`,children:[Z(`span`,{className:`chat-status`,children:c}),f.restart_available&&Z(`button`,{className:`btn`,type:`button`,onClick:ye,children:`Reload Telegram`}),Z(`button`,{className:`btn`,type:`button`,onClick:ce,children:`Check updates`}),Z(`select`,{className:`chat-select`,"aria-label":`Personality`,value:m,onChange:ge,children:[Z(`option`,{value:``,children:`Personality`}),(f.personas||[]).map(e=>Z(`option`,{value:e,children:e},e))]}),(f.providers||[]).length>0&&Z(`select`,{className:`chat-select`,"aria-label":`Provider`,value:g,onChange:_e,children:[Z(`option`,{value:``,children:`Provider`}),(f.providers||[]).map(e=>Z(`option`,{value:e,children:e},e))]}),Z(`select`,{className:`chat-select`,"aria-label":`Model`,value:v,onChange:ve,children:[Z(`option`,{value:``,children:`Model`}),we.map(e=>Z(`option`,{value:e,children:e},e))]})]})]}),k&&Z(`div`,{className:`chat-update-panel`,children:k.error?Z(`span`,{children:k.error}):k.available?.length?Z(S,{children:[Z(`div`,{children:[Z(`strong`,{children:`Update available`}),Z(`span`,{children:k.available.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)})]}),Z(`div`,{className:`chat-update-actions`,children:[Z(`button`,{className:`btn`,type:`button`,onClick:z,children:`Defer`}),k.can_install&&Z(`button`,{className:`btn btn-primary`,type:`button`,onClick:B,children:`Install update`})]})]}):Z(`span`,{children:k.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`})}),f.dangerous_available&&M&&Z(`div`,{className:`chat-dangerous-panel`,children:[Z(`div`,{className:`chat-dangerous-head`,children:[Z(`strong`,{children:`Dangerous actions`}),Z(`span`,{className:`chat-hint`,children:`Every action requires approval.`})]}),Z(`div`,{className:`chat-dangerous-controls`,children:[Z(`div`,{children:[Z(`select`,{className:`chat-select`,"aria-label":`Checkpoint`,value:P,onChange:e=>te(e.target.value),children:[Z(`option`,{value:``,children:`Select checkpoint`}),(M.checkpoints||[]).map(e=>Z(`option`,{value:e.Number??e.number,children:[e.Number??e.number,` — `,e.Label??e.label??`checkpoint`]},e.Number??e.number))]}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>ue(`rollback`,P),children:`Request rollback`})]}),Z(`div`,{children:[Z(`input`,{className:`chat-dangerous-input`,placeholder:`Process name or id`,"aria-label":`Process name or id`,value:ne,onInput:e=>re(e.target.value)}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>ue(`stop`,ne),children:`Request stop`})]})]}),Z(`div`,{className:`chat-dangerous-pending-list`,children:(M.pending||[]).length?M.pending.map(e=>Z(`div`,{className:`chat-dangerous-pending`,children:[Z(`span`,{children:e.description}),Z(`div`,{className:`chat-update-actions`,children:[Z(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`approve`),children:`Approve`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`permanent`),children:`Approve for 24h`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`deny`),children:`Deny`})]})]},e.id)):Z(`span`,{className:`chat-hint`,children:`No pending dangerous actions.`})})]}),Z(`div`,{className:`chat-layout`,children:[Z(`aside`,{className:`chat-sidebar`,children:[Z(`div`,{className:`chat-sidebar-head`,children:[Z(`strong`,{children:`Conversations`}),Z(`button`,{className:`btn btn-primary`,type:`button`,onClick:be,children:`+ New chat`})]}),Z(`div`,{className:`chat-session-list`,children:e.length?e.map(e=>Z(`button`,{className:`chat-session ${n===e.session_id?`active`:``}`,type:`button`,onClick:()=>pe(e.session_id),children:[Z(`strong`,{children:Dr(e)}),Z(`span`,{children:new Date(e.last_active_at).toLocaleString()})]},e.session_id)):Z(`div`,{className:`chat-empty`,children:`Your conversations wiLine truncated
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&r(n.session_id),n.type===`delta`&&(f+=n.text,I(e=>e?{...e,text:f}:null)),n.type===`tool`&&(u=[...u,n],I(e=>e?{...e,tools:u}:null)),n.type===`navigate`&&(u=[...u,n],I(e=>e?{...e,tools:u}:null)),n.type===`done`&&(p=!0,f||=n.text),n.type===`error`)throw Error(n.text)}if(t)break}if(!p)throw Error(`chat stream ended before completion`);a(e=>[...e,{from:`assistant`,text:f,tool_calls:u}]),I(null),l(`Ready`),await fe()}catch(e){if(e.name===`AbortError`&&!m)I({text:`Turn stopped.`,tools:u,isError:!1,turn:i,isRetry:c}),l(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;I({text:t,tools:u,isError:!0,turn:mr(i),isRetry:c}),l(`Error — retry available`)}}finally{clearTimeout(h),ae.current=null,d(!1),L.current&&L.current.focus()}}function W(){l(`Stopping…`),n&&V.chatCancel(n).catch(()=>{}),ae.current?.abort()}let Ce=f.models_by_provider||{},we=g&&Ce[g]?Ce[g]:f.models||[];return Z(`div`,{className:`chat-page-content`,children:[Z(`header`,{className:`chat-topbar`,children:[Z(`div`,{children:[Z(`span`,{className:`chat-kicker`,children:`ARCHIE WORKSPACE`}),Z(`h1`,{className:`page-title`,children:`Chat`})]}),Z(`div`,{className:`chat-topbar-actions`,children:[Z(`span`,{className:`chat-status`,children:c}),f.restart_available&&Z(`button`,{className:`btn`,type:`button`,onClick:ye,children:`Reload Telegram`}),Z(`button`,{className:`btn`,type:`button`,onClick:ce,children:`Check updates`}),Z(`select`,{className:`chat-select`,"aria-label":`Personality`,value:m,onChange:ge,children:[Z(`option`,{value:``,children:`Personality`}),(f.personas||[]).map(e=>Z(`option`,{value:e,children:e},e))]}),(f.providers||[]).length>0&&Z(`select`,{className:`chat-select`,"aria-label":`Provider`,value:g,onChange:_e,children:[Z(`option`,{value:``,children:`Provider`}),(f.providers||[]).map(e=>Z(`option`,{value:e,children:e},e))]}),Z(`select`,{className:`chat-select`,"aria-label":`Model`,value:v,onChange:ve,children:[Z(`option`,{value:``,children:`Model`}),we.map(e=>Z(`option`,{value:e,children:e},e))]})]})]}),k&&Z(`div`,{className:`chat-update-panel`,children:k.error?Z(`span`,{children:k.error}):k.available?.length?Z(S,{children:[Z(`div`,{children:[Z(`strong`,{children:`Update available`}),Z(`span`,{children:k.available.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)})]}),Z(`div`,{className:`chat-update-actions`,children:[Z(`button`,{className:`btn`,type:`button`,onClick:z,children:`Defer`}),k.can_install&&Z(`button`,{className:`btn btn-primary`,type:`button`,onClick:B,children:`Install update`})]})]}):Z(`span`,{children:k.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`})}),f.dangerous_available&&M&&Z(`div`,{className:`chat-dangerous-panel`,children:[Z(`div`,{className:`chat-dangerous-head`,children:[Z(`strong`,{children:`Dangerous actions`}),Z(`span`,{className:`chat-hint`,children:`Every action requires approval.`})]}),Z(`div`,{className:`chat-dangerous-controls`,children:[Z(`div`,{children:[Z(`select`,{className:`chat-select`,"aria-label":`Checkpoint`,value:P,onChange:e=>te(e.target.value),children:[Z(`option`,{value:``,children:`Select checkpoint`}),(M.checkpoints||[]).map(e=>Z(`option`,{value:e.Number??e.number,children:[e.Number??e.number,` — `,e.Label??e.label??`checkpoint`]},e.Number??e.number))]}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>ue(`rollback`,P),children:`Request rollback`})]}),Z(`div`,{children:[Z(`input`,{className:`chat-dangerous-input`,placeholder:`Process name or id`,"aria-label":`Process name or id`,value:ne,onInput:e=>re(e.target.value)}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>ue(`stop`,ne),children:`Request stop`})]})]}),Z(`div`,{className:`chat-dangerous-pending-list`,children:(M.pending||[]).length?M.pending.map(e=>Z(`div`,{className:`chat-dangerous-pending`,children:[Z(`span`,{children:e.description}),Z(`div`,{className:`chat-update-actions`,children:[Z(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`approve`),children:`Approve`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`permanent`),children:`Approve for 24h`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>de(e.id,`deny`),children:`Deny`})]})]},e.id)):Z(`span`,{className:`chat-hint`,children:`No pending dangerous actions.`})})]}),Z(`div`,{className:`chat-layout`,children:[Z(`aside`,{className:`chat-sidebar`,children:[Z(`div`,{className:`chat-sidebar-head`,children:[Z(`strong`,{children:`Conversations`}),Z(`button`,{className:`btn btn-primary`,type:`button`,onClick:be,children:`+ New chat`})]}),Z(`div`,{className:`chat-session-list`,children:e.length?e.map(e=>Z(`button`,{className:`chat-session ${n===e.session_id?`active`:``}`,type:`button`,onClick:()=>pe(e.session_id),children:[Z(`strong`,{children:gr(e)}),Z(`span`,{children:new Date(e.last_active_at).toLocaleString()})]},e.session_id)):Z(`div`,{className:`chat-empty`,children:`Your conversations wiLine truncated
+13
View File
@@ -0,0 +1,13 @@
import { h } from "preact";
/**
* Status pill: a small labeled badge whose color follows a semantic kind
* (ok/warn/danger/info/idle -- see css/pill.css). Extracted from 11
* independent, byte-identical local copies (tasks, logs, mappings,
* captures, settings, update-status, skills, dashboard, memory, channels,
* curators) per organisation.md's "extract on the second distinct
* consumer" rule -- archie-core-mlro.
*/
export function Pill({ text, kind = "idle" }) {
return <span className={`pill pill-${kind}`}>{text}</span>;
}
+1 -4
View File
@@ -1,4 +1,5 @@
import { h } from "preact";
import { Pill } from "../base/pill.jsx";
/**
* Pure rendering logic for the bindings editor, split out from
@@ -6,10 +7,6 @@ import { h } from "preact";
* mirroring mappings/mapping-editor.jsx.
*/
function Pill({ text, kind = "idle" }) {
return <span className={`pill pill-${kind}`}>{text}</span>;
}
const STATUS_LABELS = {
draft: "draft",
pending_approval: "pending approval",
+1 -4
View File
@@ -1,9 +1,6 @@
import { h, Fragment } from "preact";
import { ago } from "../base/dom.jsx";
export function Pill({ text, kind = "idle" }) {
return <span className={`pill pill-${kind}`}>{text}</span>;
}
import { Pill } from "../base/pill.jsx";
/**
* One captured event's summary row, plus its expandable detail row when
+2 -1
View File
@@ -2,7 +2,8 @@ import { h, Fragment } from "preact";
import { useState, useEffect } from "preact/hooks";
import "./captures.css";
import { api, subscribeEvents } from "../base/api.jsx";
import { CaptureRow, Pill } from "./capture-row.jsx";
import { CaptureRow } from "./capture-row.jsx";
import { Pill } from "../base/pill.jsx";
export function Empty({ title, detail }) {
return (
+1 -4
View File
@@ -2,10 +2,7 @@ import { h } from "preact";
import { useState, useEffect } from "preact/hooks";
import "./channels.css";
import { api } from "../base/api.jsx";
export function Pill({ text, kind = "idle" }) {
return <span className={`pill pill-${kind}`}>{text}</span>;
}
import { Pill } from "../base/pill.jsx";
export function Empty({ title, detail }) {
return (
+1 -4
View File
@@ -3,10 +3,7 @@ import { useState, useEffect } from "preact/hooks";
import "./curators.css";
import { api } from "../base/api.jsx";
import { ago } from "../base/dom.jsx";
function Pill({ text, kind = "idle" }) {
return <span className={`pill pill-${kind}`}>{text}</span>;
}
import { Pill } from "../base/pill.jsx";
function Empty({ title, detail }) {
return (
+1 -4
View File
@@ -6,6 +6,7 @@ import { ago, compact, statusKind } from "../base/dom.jsx";
import { statTile } from "../base/statTile.jsx";
import { gauge, segmentBar } from "../base/gauge.jsx";
import { icon } from "../base/icons.jsx";
import { Pill } from "../base/pill.jsx";
import { dismissSetupComplete, setupPanelState } from "./setup-preference.jsx";
import { dashboardTaskTargets } from "./task-targets.jsx";
@@ -45,10 +46,6 @@ function Empty({ title, detail }) {
);
}
function Pill({ text, kind = "idle" }) {
return <span className={`pill pill-${kind}`}>{text}</span>;
}
function taskIDForEvent(event, taskIDsBySource) {
if (Number(event.task_id) > 0) return Number(event.task_id);
if (!event.repo || !event.issue) return 0;
+1 -4
View File
@@ -2,10 +2,7 @@ import { h } from "preact";
import { useState, useEffect, useRef, useMemo } from "preact/hooks";
import "./logs.css";
import { api, subscribeLogs } from "../base/api.jsx";
function Pill({ text, kind = "idle" }) {
return <span className={`pill pill-${kind}`}>{text}</span>;
}
import { Pill } from "../base/pill.jsx";
function Empty({ title, detail }) {
return (
+1 -4
View File
@@ -1,8 +1,5 @@
import { h, Fragment } from "preact";
export function Pill({ text, kind = "idle" }) {
return <span className={`pill pill-${kind}`}>{text}</span>;
}
import { Pill } from "../base/pill.jsx";
/**
* Pure rendering + path/type logic for the mapping editor, split out from
+1 -4
View File
@@ -2,10 +2,7 @@ import { h } from "preact";
import { useState, useEffect } from "preact/hooks";
import "./memory.css";
import { api } from "../base/api.jsx";
function Pill({ text, kind = "idle" }) {
return <span className={`pill pill-${kind}`}>{text}</span>;
}
import { Pill } from "../base/pill.jsx";
function Empty({ title, detail }) {
return (
+1 -4
View File
@@ -3,13 +3,10 @@ import { useState, useEffect } from "preact/hooks";
import "./settings.css";
import { api } from "../base/api.jsx";
import { statusKind, statusLabel } from "../base/task-meta.jsx";
import { Pill } from "../base/pill.jsx";
import { Row } from "./config-row.jsx";
import { UpdateStatusCard } from "./update-status.jsx";
function Pill({ text, kind = "idle" }) {
return <span className={`pill pill-${kind}`}>{text}</span>;
}
function Empty({ title, detail }) {
return (
<div className="empty">
+1 -4
View File
@@ -1,8 +1,5 @@
import { h } from "preact";
function Pill({ text, kind = "idle" }) {
return <span className={`pill pill-${kind}`}>{text}</span>;
}
import { Pill } from "../base/pill.jsx";
function Empty({ title, detail }) {
return (
+1 -4
View File
@@ -2,6 +2,7 @@ import { h, Fragment } from "preact";
import { useState, useEffect, useMemo } from "preact/hooks";
import "./skills.css";
import { api } from "../base/api.jsx";
import { Pill } from "../base/pill.jsx";
function Empty({ title, detail }) {
return (
@@ -12,10 +13,6 @@ function Empty({ title, detail }) {
);
}
function Pill({ text, kind = "idle" }) {
return <span class={`pill pill-${kind}`}>{text}</span>;
}
export function skillsPage(query) {
return <SkillsApp query={query} />;
}
+1 -3
View File
@@ -3,6 +3,7 @@ import { useState, useEffect, useRef } from "preact/hooks";
import "./tasks.css";
import { api } from "../base/api.jsx";
import { ago } from "../base/dom.jsx";
import { Pill } from "../base/pill.jsx";
import { statTile as renderStatTile } from "../base/statTile.jsx";
import { taskRowA11y } from "./task-row.jsx";
import { initialTaskFilter, taskMatchesStatus } from "./task-filters.jsx";
@@ -18,9 +19,6 @@ function StatTileNode(props) {
return <div ref={ref} style={{ display: 'contents' }} />;
}
function Pill({ text, kind = "idle" }) {
return <span className={`pill pill-${kind}`}>{text}</span>;
}
function Empty({ title, detail }) {
return (