From 1d2e58ebaa9fa28301762e5e558012aec9e4cb2f Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 20 Sep 2026 16:30:01 +1000 Subject: [PATCH] fix(webui): make the chat panel behave like a chat window Remediation from testing the launcher (archie-core-ifay), plus the morph Sam asked for. The panel grows out of the launcher rather than fading in beside it: closed, it is collapsed to a pill the size of the button and translated over it; open, it is the full panel. Scale, border-radius and position interpolate together, and the contents fade in once the shape has mostly arrived, so the button reads as becoming the panel. The launcher stays visible throughout and is the only control that opens and closes it, so the panel carries no close button. - Header shows the open conversation's name; ChatApp owns the header now, because the title and the actions that change it belong to the same component. - New chat became the Lucide message-circle-plus glyph and moved into the header. Added to the icon set, which is the same 24-grid stroke system. - The commands accordion is gone. The composer's slash palette was already the command surface and floats above the input; having both was two answers to one question. - Arrow keys scroll the palette so the selection stays visible. The decision is pure arithmetic in command-scroll.js, including the case of an option taller than the list, which aligns to its top so the command name is not the part scrolled out of sight. - The settings popover closes on any pointerdown or focus outside it. - Stop renders only while a reply is streaming. - The composer keeps focus and stays writeable during a send, so the next message can be typed while one streams. It was `disabled`, which also made the focus() in the send's finally block a silent no-op. sendMessage already refuses a second concurrent turn via isSendingRef. - Composer actions sit at the right of the input row, the resize handle is gone, and the Enter/Shift+Enter hint is removed. - Message bubbles dropped their "Archie"/"You" labels; side and colour already say who spoke. - Fixed an empty band under the composer: the panel still declared two grid rows from when the launcher owned the header. --- ui/dist/assets/index.css | 2 +- ui/dist/assets/index.js | 18 +++---- ui/src/base/icons.jsx | 1 + ui/src/chat/chat-render.jsx | 11 +++++ ui/src/chat/chat.css | 16 +++--- ui/src/chat/chat.jsx | 90 +++++++++++++++++++++------------- ui/src/chat/command-scroll.js | 28 +++++++++++ ui/src/css/layout.css | 69 +++++++++++++++++++------- ui/src/main.jsx | 11 ++--- ui/test/chat-app.test.js | 1 - ui/test/chat-panel.test.js | 68 +++++++++++++++++++++++++ ui/test/command-scroll.test.js | 40 +++++++++++++++ 12 files changed, 278 insertions(+), 77 deletions(-) create mode 100644 ui/src/chat/command-scroll.js create mode 100644 ui/test/chat-panel.test.js create mode 100644 ui/test/command-scroll.test.js diff --git a/ui/dist/assets/index.css b/ui/dist/assets/index.css index 9349df1bc..1d79730c7 100644 --- a/ui/dist/assets/index.css +++ b/ui/dist/assets/index.css @@ -1 +1 @@ -:root{--font-sans:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;--font-mono:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;--text-xs:.6875rem;--text-sm:.8125rem;--text-base:.875rem;--text-lg:1.0625rem;--text-xl:1.375rem;--text-2xl:1.875rem;--text-3xl:2.5rem;--sp-1:.25rem;--sp-2:.5rem;--sp-3:.75rem;--sp-4:1rem;--sp-5:1.5rem;--sp-6:2rem;--sp-7:3rem;--radius-sm:6px;--radius-md:10px;--radius-lg:14px;--radius-xl:20px;--radius-pill:999px;--transition:.14s cubic-bezier(.4, 0, .2, 1)}[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--bg:#0d1014;--bg-raised:#141920;--surface:#171d25;--surface-hover:#1d242e;--border:#232b36;--border-strong:#303a48;--fg:#e8edf4;--fg-muted:#8b97a8;--fg-subtle:#5d6878;--accent:#4c8dff;--accent-fg:#fff;--accent-soft:#4c8dff24;--ok:#3fbf7f;--ok-soft:#3fbf7f24;--warn:#e8a33d;--warn-soft:#e8a33d24;--danger:#f0616d;--danger-soft:#f0616d24;--info:#4c8dff;--info-soft:#4c8dff24;--idle:#6b7688;--idle-soft:#6b768824;--accent-2:#7b5cff;--bg-blur:#1419208c;--surface-glass:#171d259e;--surface-glass-strong:#141920c7;--workspace:#11151b8c;--hairline:#ffffff0f;--wash-a:#4c8dff1a;--wash-b:#7b5cff1f;--wash-c:#3fbf7f0f;--shadow-workspace:0 24px 70px #00000080;--shadow-sm:0 1px 2px #0006;--shadow-md:0 8px 28px #0000006b}[data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--bg:#f6f8fb;--bg-raised:#fff;--surface:#fff;--surface-hover:#f1f4f9;--border:#e2e8f0;--border-strong:#cbd5e1;--fg:#16202e;--fg-muted:#5a6779;--fg-subtle:#8c99ab;--accent:#2563eb;--accent-fg:#fff;--accent-soft:#2563eb1a;--ok:#10935c;--ok-soft:#10935c1f;--warn:#b87514;--warn-soft:#b875141f;--danger:#d4344a;--danger-soft:#d4344a1f;--info:#2563eb;--info-soft:#2563eb1a;--idle:#64748b;--idle-soft:#64748b1f;--accent-2:#7c3aed;--bg-blur:#fff9;--surface-glass:#ffffffb8;--surface-glass-strong:#ffffffe0;--workspace:#ffffff8c;--hairline:#0f172a0f;--wash-a:#2563eb1a;--wash-b:#7c3aed1f;--wash-c:#10935c12;--shadow-workspace:0 24px 70px #0f172a24;--shadow-sm:0 1px 2px #0f172a0f;--shadow-md:0 8px 28px #0f172a1a}*,:before,:after{box-sizing:border-box}html,body{height:100%;margin:0}body{color:var(--fg);font-family:var(--font-sans);font-size:var(--text-base);-webkit-font-smoothing:antialiased;line-height:1.5}a{color:inherit;text-decoration:none}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.visually-hidden,.sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}body{background:radial-gradient(70rem 40rem at 8% -10%, var(--wash-a), transparent 62%), radial-gradient(56rem 34rem at 92% 4%, var(--wash-b), transparent 58%), radial-gradient(48rem 30rem at 50% 108%, var(--wash-c), transparent 60%), var(--bg);padding:var(--sp-4);background-attachment:fixed}.shell{min-height:calc(100vh - var(--sp-4) * 2);border-radius:var(--radius-xl);border:1px solid var(--hairline);background:var(--workspace);-webkit-backdrop-filter:blur(28px)saturate(120%);backdrop-filter:blur(28px)saturate(120%);box-shadow:var(--shadow-workspace);flex-direction:column;display:flex;overflow:hidden}.topbar{align-items:center;gap:var(--sp-4);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--hairline);background:var(--bg-blur);z-index:10;display:flex;position:sticky;top:0}.brand{align-items:center;gap:var(--sp-2);font-weight:600;font-size:var(--text-sm);letter-spacing:-.01em;flex:none;display:flex}.brand-mark{background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;width:26px;height:26px;font-size:var(--text-xs);border-radius:8px;place-items:center;font-weight:700;display:grid}.nav{scrollbar-width:none;border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);flex:0 auto;align-items:center;gap:2px;min-width:0;margin:0 auto;padding:3px;display:flex;overflow-x:auto}.nav::-webkit-scrollbar{display:none}.nav-item{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);color:var(--fg-muted);font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:background var(--transition), color var(--transition);flex:none;display:inline-flex}.nav-item:hover{color:var(--fg);background:var(--surface-hover)}.nav-item[aria-current=page]{background:var(--accent);color:var(--accent-fg);font-weight:500}.nav-item .nav-label{display:inline}.topbar-end{align-items:center;gap:var(--sp-2);flex:none;display:flex}.topbar-search{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);color:var(--fg-subtle);display:flex}.topbar-search input{color:var(--fg);font:inherit;font-size:var(--text-sm);background:0 0;border:0;outline:none;width:8rem}.topbar-search input::placeholder{color:var(--fg-subtle)}.mobile-search-toggle{display:none}.icon-btn{border-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(--accent), var(--accent-2));cursor:pointer;flex:none;place-items:center;font-weight:600;display:grid}.ico{flex:none;display:block}.main{padding:var(--sp-6);flex:1;width:100%;overflow-x:hidden}.chat-dock{--fab-size:56px;--fab-inset:var(--sp-5);--fab-gap:var(--sp-3);right:var(--fab-inset);bottom:var(--fab-inset);z-index:40;position:fixed}.chat-fab{width:var(--fab-size);height:var(--fab-size);border-radius:var(--radius-pill);background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;cursor:pointer;box-shadow:var(--shadow-md);transition:transform var(--transition), box-shadow var(--transition);border:0;place-items:center;display:grid;position:relative}.chat-fab:hover{box-shadow:0 12px 34px color-mix(in srgb, var(--accent) 38%, transparent);transform:translateY(-1px)}.chat-fab:active{transform:translateY(0)}.chat-fab-icon{transition:opacity var(--transition), transform var(--transition);grid-area:1/1;place-items:center;display:grid}.chat-fab-icon-close,.chat-dock.is-open .chat-fab-icon-open{opacity:0;transform:scale(.7)rotate(-45deg)}.chat-fab-icon-open,.chat-dock.is-open .chat-fab-icon-close{opacity:1;transform:none}.chat-drawer{right:calc(var(--fab-size) + var(--fab-gap));width:min(440px, calc(100vw - var(--fab-size) - var(--fab-gap) - var(--fab-inset) * 2));height:min(640px, calc(100vh - var(--fab-inset) * 2));pointer-events:none;position:absolute;bottom:0}.chat-drawer-panel{pointer-events:auto;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);width:100%;height:100%;box-shadow:var(--shadow-md);opacity:0;transform-origin:100% 100%;transform:scale(.92) translateX(var(--sp-3));transition:opacity var(--transition), transform var(--transition);grid-template-rows:auto minmax(0,1fr);display:grid;overflow:hidden}.chat-drawer:not(.is-open) .chat-drawer-panel{pointer-events:none;visibility:hidden}.chat-drawer.is-open .chat-drawer-panel{opacity:1;visibility:visible;transform:none}.chat-drawer-head{justify-content:space-between;align-items:center;gap:var(--sp-2);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--border);display:flex}@media (width<=720px){.chat-dock{--fab-inset:var(--sp-4)}.chat-drawer{right:var(--fab-inset);left:var(--fab-inset);bottom:var(--fab-inset);width:auto;height:min(78vh, calc(100vh - var(--fab-inset) * 2));position:fixed}.chat-drawer-panel{transform-origin:bottom;transform:scale(.98) translateY(var(--sp-3))}.chat-dock.is-open .chat-fab{opacity:0;pointer-events:none}}@media (width<=1500px){.topbar-search{background:0 0;border:0;padding:0;overflow:hidden}.topbar-search-icon{display:none}.mobile-search-toggle{display:grid}.topbar-search input{opacity:0;pointer-events:none;width:0;transition:width var(--transition), opacity var(--transition);padding:0}.topbar-search.is-open,.topbar-search:focus-within{padding-right:var(--sp-2);border:1px solid var(--hairline);background:var(--surface-glass-strong)}.topbar-search.is-open input,.topbar-search:focus-within input{opacity:1;pointer-events:auto;width:min(9rem,34vw)}}@media (width<=1270px) and (width>=901px){.topbar{flex-wrap:wrap}.nav{border-radius:var(--radius-lg);flex-wrap:wrap;order:3;justify-content:center;width:100%;margin:0}}@media (width<=900px){body{padding:0}.shell{min-height:100vh;box-shadow:none;border:0;border-radius:0}.topbar{padding:var(--sp-3);gap:var(--sp-2);flex-wrap:wrap}.nav{border-radius:var(--radius-lg);scrollbar-width:none;flex-wrap:nowrap;order:3;justify-content:flex-start;width:100%;overflow-x:auto}.nav::-webkit-scrollbar{display:none}.nav-item .nav-label{display:inline}.main{padding:var(--sp-4)}}.page-head{justify-content:space-between;align-items:flex-start;gap:var(--sp-5);margin-bottom:var(--sp-6);flex-wrap:wrap;display:flex}.page-title{font-size:var(--text-2xl);letter-spacing:-.02em;margin:0;font-weight:600}.page-sub{color:var(--fg-muted);font-size:var(--text-sm);margin:var(--sp-1) 0 0}.page-actions{gap:var(--sp-2);align-items:center;display:flex}.btn{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-4);border-radius:var(--radius-pill);border:1px solid var(--border-strong);background:var(--surface);color:var(--fg);font:inherit;font-size:var(--text-sm);cursor:pointer;transition:background var(--transition), border-color var(--transition);display:inline-flex}.btn:hover{background:var(--surface-hover)}.btn-primary{background:var(--accent);border-color:var(--accent);color:var(--accent-fg);font-weight:500}.btn-primary:hover{filter:brightness(1.08);background:var(--accent)}.btn-icon{padding:var(--sp-2);border-radius:var(--radius-sm)}.card{background:var(--surface-glass);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);border:1px solid var(--hairline);border-radius:var(--radius-lg);padding:var(--sp-5);box-shadow:var(--shadow-sm);overflow-x:auto}.card-head{justify-content:space-between;align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.card-title{font-size:var(--text-base);margin:0;font-weight:600}.card-sub{font-size:var(--text-xs);color:var(--fg-muted);margin:var(--sp-1) 0 0}.grid{gap:var(--sp-4);display:grid}.grid>*{min-width:0}.grid-4{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-2{grid-template-columns:repeat(auto-fit,minmax(340px,1fr))}.pill{align-items:center;gap:var(--sp-1);padding:2px var(--sp-2);border-radius:var(--radius-pill);font-size:var(--text-xs);white-space:nowrap;font-weight:500;display:inline-flex}.pill:before{content:"";background:currentColor;border-radius:50%;width:5px;height:5px}.pill-ok{color:var(--ok);background:var(--ok-soft)}.pill-warn{color:var(--warn);background:var(--warn-soft)}.pill-danger{color:var(--danger);background:var(--danger-soft)}.pill-info{color:var(--info);background:var(--info-soft)}.pill-idle{color:var(--idle);background:var(--idle-soft)}.table{border-collapse:collapse;width:100%;font-size:var(--text-sm)}.table-scroll{-webkit-overflow-scrolling:touch;min-width:0;max-width:100%;overflow-x:auto}.table-scroll>.table{min-width:42rem}.table th{text-align:left;font-weight:500;font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--fg-subtle);padding:0 var(--sp-3) var(--sp-3);border-bottom:1px solid var(--border)}.table td{padding:var(--sp-3);border-bottom:1px solid var(--border);color:var(--fg-muted)}.table tbody tr:last-child td{border-bottom:0}.table tbody tr:hover td{background:var(--surface-hover)}.table td.strong{color:var(--fg);font-weight:500}.mono{font-family:var(--font-mono);font-size:.95em}.empty{text-align:center;padding:var(--sp-7) var(--sp-4);color:var(--fg-muted)}.empty-title{color:var(--fg);margin-bottom:var(--sp-1);font-weight:500}.skeleton{background:linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);border-radius:var(--radius-sm);background-size:200% 100%;animation:1.4s infinite shimmer}@keyframes shimmer{to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){*,:before,:after{transition-duration:.01ms!important;animation-duration:.01ms!important}}.nav-soon{font-size:var(--text-xs);color:var(--fg-subtle);background:var(--surface-hover);padding:1px var(--sp-2);border-radius:var(--radius-pill);margin-left:auto}.nav-item[aria-disabled]{opacity:.55;cursor:default}.nav-item[aria-disabled]:hover{color:var(--fg-muted);background:0 0}.stat-head{justify-content:space-between;align-items:center;gap:var(--sp-2);display:flex}.stat-label{font-size:var(--text-sm);color:var(--fg-muted)}.stat-trend{font-size:var(--text-xs);align-items:center;gap:3px;font-weight:500;display:inline-flex}.stat-trend.up{color:var(--ok)}.stat-trend.down{color:var(--danger)}.stat-value{font-size:var(--text-3xl);letter-spacing:-.03em;margin:var(--sp-2) 0 0;font-weight:600}.stat-unit{font-size:var(--text-lg);color:var(--fg-muted);margin-left:var(--sp-1)}.stat-compare{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:var(--sp-1)}.spark{width:100%;height:34px;margin-top:var(--sp-3);display:block}.setup{margin-bottom:var(--sp-4)}.setup-pct{font-size:var(--text-lg);color:var(--accent);font-weight:600}.setup-complete-actions{align-items:center;gap:var(--sp-2);display:flex}.setup-dismiss{width:28px;height:28px;font-size:var(--text-lg);line-height:1}.setup-done .setup-pct{color:var(--ok)}.setup-bar{border-radius:var(--radius-pill);background:var(--border);height:5px;margin-bottom:var(--sp-4);overflow:hidden}.setup-bar-fill{background:var(--accent);border-radius:var(--radius-pill);height:100%;transition:width var(--transition)}.setup-list{gap:var(--sp-3);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.setup-step{gap:var(--sp-3);align-items:flex-start;display:flex}.setup-check{border:1.5px solid var(--border-strong);width:18px;height:18px;font-size:var(--text-xs);color:var(--fg-subtle);border-radius:50%;flex:none;place-items:center;margin-top:1px;display:grid}.setup-step.done .setup-check{background:var(--ok-soft);color:var(--ok);border-color:#0000}.setup-step-title{font-size:var(--text-sm)}.setup-step.done .setup-step-title{color:var(--fg-muted);text-decoration:line-through}.setup-step-detail{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:2px}.hero{justify-content:space-between;align-items:flex-start;gap:var(--sp-5);margin-bottom:var(--sp-5);flex-wrap:wrap;display:flex}.hero-title{font-size:var(--text-3xl);letter-spacing:-.03em;margin:0;font-weight:600}.hero-sub{color:var(--fg-muted);font-size:var(--text-sm);margin:var(--sp-2) 0 0}.hero-actions{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.dash-top{gap:var(--sp-4);margin-bottom:var(--sp-4);grid-template-columns:minmax(0,1.6fr) minmax(0,1fr);display:grid}.dash-top>*,.dash-split>*{min-width:0}.dash-top>div{display:flex}.dash-top>div>.card{flex:1}.dash-top-standalone{grid-template-columns:minmax(0,1fr)}@media (width<=1080px){.dash-top{grid-template-columns:minmax(0,1fr)}}.gauge-wrap{place-items:center;display:grid;position:relative}.gauge{width:100%;max-width:200px;display:block}.gauge-value{transition:stroke-dashoffset .6s cubic-bezier(.4,0,.2,1)}.gauge-center{text-align:center;position:absolute;top:52%;transform:translateY(-50%)}.gauge-pct{font-size:var(--text-2xl);letter-spacing:-.03em;font-weight:600}.gauge-label{font-size:var(--text-xs);color:var(--fg-muted)}.pulse-list{margin:var(--sp-4) 0 0;gap:var(--sp-2);flex-direction:column;padding:0;list-style:none;display:flex}.pulse-item{justify-content:space-between;align-items:center;gap:var(--sp-3);font-size:var(--text-sm);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-sm);background:var(--bg-raised);display:flex}.pulse-name{color:var(--fg-muted);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.segbar{border-radius:var(--radius-pill);background:var(--border);gap:2px;height:10px;display:flex;overflow:hidden}.segbar-part{height:100%;display:block}.segbar-ok{background:var(--ok)}.segbar-warn{background:var(--warn)}.segbar-danger{background:var(--danger)}.segbar-info{background:var(--info)}.segbar-idle{background:var(--idle)}.segbar-legend{gap:var(--sp-4);margin-top:var(--sp-3);flex-wrap:wrap;display:flex}.segbar-key{align-items:center;gap:var(--sp-2);font-size:var(--text-xs);color:var(--fg-muted);display:inline-flex}.segbar-dot{border-radius:50%;width:8px;height:8px}.forecast-value{font-size:var(--text-3xl);letter-spacing:-.03em;margin-bottom:var(--sp-1);font-weight:600}.forecast-note{font-size:var(--text-xs);color:var(--fg-subtle);margin-bottom:var(--sp-4)}.dash-split{gap:var(--sp-4);margin-top:var(--sp-4);grid-template-columns:minmax(0,1fr) minmax(0,1.5fr);display:grid}@media (width<=1080px){.dash-split{grid-template-columns:minmax(0,1fr)}}.stat-card{position:relative;overflow:hidden}.dash-section{margin-bottom:var(--sp-5)}.dash-section-head{align-items:baseline;gap:var(--sp-3);margin-bottom:var(--sp-3);padding-left:var(--sp-1);display:flex}.dash-section-title{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.08em;color:var(--fg-subtle);margin:0;font-weight:600}.dash-section-note{font-size:var(--text-xs);color:var(--fg-subtle)}.hero-actions-inner{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.btn-attention{border-color:var(--warn);color:var(--warn);background:var(--warn-soft);font-weight:500}.btn-attention:hover{background:var(--warn-soft);filter:brightness(1.1)}.activity-detail{width:55%;max-width:0}.activity-detail span{text-overflow:ellipsis;white-space:nowrap;display:block;overflow:hidden}.task-summary{margin-bottom:var(--sp-5)}.task-filters{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.task-search,.task-filter{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3)}.task-search{width:220px}.task-search:focus,.task-filter:focus{outline:2px solid var(--accent-soft);outline-offset:1px}.task-row{cursor:pointer}.task-expand{width:1.5rem;height:1.5rem;margin-right:var(--sp-2);color:var(--fg-muted);border:1px solid var(--border);font:inherit;cursor:pointer;background:0 0;border-radius:50%;padding:0;line-height:1}.task-expand:hover,.task-expand:focus-visible{color:var(--fg);border-color:var(--accent)}.activity-row{cursor:pointer}.activity-row:hover td,.activity-row:focus td{background:var(--surface-hover)}.activity-row:focus{outline:2px solid var(--accent);outline-offset:-2px}.task-source-link{color:var(--accent);text-decoration:none}.task-source-link:hover{text-decoration:underline}.task-detail-link{color:inherit}.task-detail-link:hover,.task-detail-link:focus-visible{text-decoration:underline;-webkit-text-decoration-color:var(--accent);text-decoration-color:var(--accent)}.task-actions{gap:var(--sp-1);white-space:nowrap;flex-wrap:wrap;display:flex}.btn-small{padding:var(--sp-1) var(--sp-2);font-size:var(--text-xs)}.btn-quiet{color:var(--fg-muted)}.task-action-error{max-width:220px;font-size:var(--text-xs);white-space:normal}.task-action-error-refused{color:var(--warn)}.task-action-error-broken{color:var(--danger)}.task-action-error-session{color:var(--warn);align-items:center;gap:var(--sp-1);flex-wrap:wrap;display:inline-flex}.task-decision{margin-bottom:var(--sp-4);padding:var(--sp-3);border-left:3px solid var(--accent);background:var(--surface)}.task-detail-actions{justify-content:space-between;align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);padding-bottom:var(--sp-3);border-bottom:1px solid var(--hairline);display:flex}.task-decision-title{color:var(--fg);font-weight:600}.task-decision-plan{margin-top:var(--sp-2);color:var(--fg-muted);white-space:pre-wrap}.task-logs-section{margin-top:var(--sp-4)}.task-logs-section .task-decision-title{justify-content:space-between;align-items:center;display:flex}.task-log-list{max-height:40vh;font-family:var(--font-mono);font-size:var(--text-xs);border-top:1px solid var(--border);margin-top:var(--sp-2);overflow-y:auto}.task-log-loading,.task-log-error{padding:var(--sp-3) 0;color:var(--fg-muted)}@media (width<=700px){.task-filters,.task-search{width:100%}.task-filter{flex:100%}.table-scroll:has(.task-row){overflow:visible}.table:has(.task-row){display:block}.table:has(.task-row) tbody{display:block}.table-scroll>.table:has(.task-row){width:100%;min-width:0}.table:has(.task-row) thead{display:none}.task-row{gap:var(--sp-2) var(--sp-4);margin-bottom:var(--sp-3);padding:var(--sp-3);border:1px solid var(--hairline);border-radius:var(--radius-lg);background:var(--surface-glass);grid-template-columns:1fr 1fr;display:grid}.task-row td{justify-content:space-between;align-items:center;gap:var(--sp-2);padding:var(--sp-1) 0;text-align:right;border:0;display:flex}.task-row td:before{content:attr(data-label);color:var(--fg-subtle);font-size:var(--text-xs);text-align:left;font-weight:500}.task-row td:nth-child(3),.task-row td:last-child{grid-column:1/-1}.task-row td:last-child{align-items:flex-start}.task-timeline-row,.task-timeline-row td{width:100%;display:block}.task-timeline-row td{margin:calc(var(--sp-2) * -1) 0 var(--sp-4);border-radius:0 0 var(--radius-lg) var(--radius-lg)}.task-detail-actions{flex-direction:column;align-items:flex-start}}@media (width<=480px){.task-row{grid-template-columns:1fr}.task-row td:nth-child(3),.task-row td:last-child{grid-column:auto}}.task-timeline-row td{background:var(--bg-raised);padding:var(--sp-4)}.task-timeline-loading{color:var(--fg-muted);font-size:var(--text-sm)}.task-timeline-error{align-items:flex-start;gap:var(--sp-2);flex-direction:column;display:flex}.task-timeline-error .task-timeline-title{color:var(--fg);font-weight:500}.task-timeline{gap:var(--sp-3);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.task-timeline-entry{gap:var(--sp-3);align-items:flex-start;display:flex}.task-timeline-dot{background:var(--accent);border-radius:50%;flex:none;width:8px;height:8px;margin-top:5px}.task-timeline-kind{font-size:var(--text-sm);color:var(--fg);font-weight:500}.task-timeline-detail{font-size:var(--text-xs);color:var(--fg-muted);margin-top:2px}.task-timeline-when{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:2px}.run-meta{align-items:center;gap:var(--sp-4);margin:calc(var(--sp-2) * -1) 0 var(--sp-4);font-size:var(--text-sm);flex-wrap:wrap;display:flex}.run-meta-item{align-items:center;gap:var(--sp-2);display:inline-flex}.run-meta-label{color:var(--fg-muted);font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em}.run-meta-value{color:var(--fg)}.run-meta-muted{color:var(--fg-muted)}.run-meta-link{color:var(--accent)}.run-meta-link:hover{text-decoration:underline}.run-note{margin:0 0 var(--sp-4);padding:var(--sp-3) var(--sp-4);border-left:3px solid var(--warn);background:var(--warn-soft);border-radius:var(--radius-sm);color:var(--fg);font-size:var(--text-sm)}.run-restart{align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.run-restart-copy,.run-restart-unavailable{color:var(--fg-muted);font-size:var(--text-sm);flex:22rem;margin:0}.run-restart-error{font-size:var(--text-sm);flex:100%;margin:0}.run-restart-error-refused{color:var(--warn)}.run-restart-error-broken{color:var(--danger)}.run-restart-error-session-expired{color:var(--warn)}.run-attempts{gap:var(--sp-2);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.run-attempt{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border:1px solid var(--border);border-radius:var(--radius-pill);background:var(--surface);color:var(--fg-muted);font:inherit;font-size:var(--text-sm);cursor:pointer;transition:border-color var(--transition), color var(--transition);display:inline-flex}.run-attempt:hover{border-color:var(--border-strong);color:var(--fg)}.run-attempt.is-selected{border-color:var(--accent);background:var(--accent-soft);color:var(--fg)}.run-attempt-id{font-weight:500}.run-attempt-meta{color:var(--fg-muted);font-size:var(--text-xs)}.run-card{padding-top:var(--sp-4)}.tab-bar{gap:var(--sp-1);border-bottom:1px solid var(--border);margin-bottom:var(--sp-4);scrollbar-width:thin;display:flex;overflow-x:auto}.tab{padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-sm) var(--radius-sm) 0 0;color:var(--fg-muted);font:inherit;font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:color var(--transition), background var(--transition);background:0 0;border:0;border-bottom:2px solid #0000;position:relative}.tab:hover{color:var(--fg);background:var(--surface-hover)}.tab.is-selected{color:var(--fg);border-bottom-color:var(--accent);font-weight:500}.run-panel{min-width:0;min-height:6rem}.run-panel:focus-visible{outline:2px solid var(--accent);outline-offset:4px}.run-loading{padding:var(--sp-5) 0;color:var(--fg-muted);font-size:var(--text-sm)}.run-error{align-items:flex-start;gap:var(--sp-2);padding:var(--sp-3) 0;flex-direction:column;display:flex}.run-error-title{color:var(--fg);font-weight:500}.run-error-detail{color:var(--fg-muted);font-size:var(--text-sm);max-width:60ch}.run-json{padding:var(--sp-3);background:var(--bg-raised);border:1px solid var(--border);border-radius:var(--radius-sm);max-height:60vh;font-family:var(--font-mono);font-size:var(--text-xs);white-space:pre-wrap;overflow-wrap:anywhere;margin:0;line-height:1.5;overflow:auto}.run-rail-head{align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.run-rail-attempt{font-weight:600}.run-rail-when{color:var(--fg-muted);font-size:var(--text-xs)}.run-stages{margin:0;padding:0;list-style:none}.run-stage{gap:var(--sp-2);padding-bottom:var(--sp-4);grid-template-columns:1.75rem 1fr;display:grid;position:relative}.run-stage:before{content:"";background:var(--border-strong);width:1px;position:absolute;top:1rem;bottom:0;left:.6875rem}.run-stage:last-child:before{display:none}.run-stage-node{z-index:1;border:2px solid var(--border-strong);background:var(--bg-raised);border-radius:50%;width:.875rem;height:.875rem;margin:.25rem 0 0 .25rem;position:relative}.run-stage[data-status=ok] .run-stage-node{border-color:var(--ok)}.run-stage[data-status=failed] .run-stage-node{border-color:var(--danger)}.run-stage[data-status=interrupted] .run-stage-node{border-color:var(--warn)}.run-stage[data-status=running] .run-stage-node{border-color:var(--info)}.run-stage-body{min-width:0}.run-stage-head{align-items:center;gap:var(--sp-2);flex-wrap:wrap;display:flex}.run-stage-name{color:var(--fg);overflow-wrap:anywhere;min-width:0;font-weight:500}.run-stage-duration{color:var(--fg-muted);font-size:var(--text-xs)}.run-stage-error{margin-top:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-left:3px solid var(--danger);background:var(--danger-soft);border-radius:var(--radius-sm);color:var(--fg-muted);font-size:var(--text-sm);white-space:pre-wrap;overflow-wrap:anywhere}.run-agent-report{margin-top:var(--sp-2);color:var(--fg-muted);font-size:var(--text-xs)}.run-agent-report-label{color:var(--fg-muted)}.run-rail-legend,.run-rail-note{margin:var(--sp-3) 0 0;color:var(--fg-muted);font-size:var(--text-xs);max-width:70ch}.run-rail-legend strong{color:var(--fg-muted)}.run-capture+.run-capture{margin-top:var(--sp-5);padding-top:var(--sp-4);border-top:1px solid var(--border)}.run-capture-head{justify-content:space-between;align-items:baseline;gap:var(--sp-3);flex-wrap:wrap;display:flex}.run-capture-when{color:var(--fg);font-size:var(--text-sm);font-weight:500}.run-capture-at{color:var(--fg-muted);font-size:var(--text-xs)}.run-capture-meta{align-items:center;gap:var(--sp-3);margin:var(--sp-2) 0 var(--sp-3);color:var(--fg-muted);font-size:var(--text-xs);flex-wrap:wrap;display:flex}.run-capture-link{color:var(--accent)}.run-capture-link:hover{text-decoration:underline}.run-capture-branch,.run-capture-sha,.run-capture-totals{color:var(--fg-muted)}.run-changes-table td{padding:var(--sp-2) var(--sp-3);vertical-align:top}.run-changes-path{color:var(--fg);word-break:break-all}.run-changes-old{color:var(--fg-muted)}.run-changes-count{text-align:right;white-space:nowrap}.run-changes-hint,.run-changes-note,.run-changes-empty{color:var(--fg-muted);font-size:var(--text-xs)}.run-changes-hint{display:block}.run-changes-empty{padding:var(--sp-3) 0}.run-config-scope{margin:0 0 var(--sp-2);color:var(--fg-muted);font-size:var(--text-sm);max-width:75ch}.run-config-when{margin-bottom:var(--sp-3);color:var(--fg-muted);font-size:var(--text-xs)}.run-config-unknown{margin-bottom:var(--sp-2);color:var(--warn);font-size:var(--text-sm)}.task-log-filters{padding-bottom:var(--sp-3);border-bottom:1px solid var(--border)}.task-log-attempt{color:var(--fg);font-size:var(--text-sm);font-weight:500}.task-log-filter{align-items:center;gap:var(--sp-2);display:inline-flex}.task-log-filter-label{color:var(--fg-muted);font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em}.task-log-filter-note{color:var(--fg-muted);font-size:var(--text-xs);flex:100%;max-width:80ch;margin:0}.run-panel .task-log-list{border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--bg-raised);max-height:62vh;padding:0 var(--sp-2)}.run-page .pill{color:var(--fg)}.run-page .pill-ok:before{background:var(--ok)}.run-page .pill-warn:before{background:var(--warn)}.run-page .pill-danger:before{background:var(--danger)}.run-page .pill-info:before{background:var(--info)}.run-page .pill-idle:before{background:var(--idle)}@media (width<=700px){.run-meta{margin-bottom:var(--sp-3)}.run-restart{align-items:flex-start}.run-attempts{padding-bottom:var(--sp-1);flex-wrap:nowrap;overflow-x:auto}.run-stage{padding-bottom:var(--sp-3);border-bottom:1px solid var(--border);grid-template-columns:1fr}.run-stage:before,.run-stage-node{display:none}.run-capture-head{align-items:flex-start;gap:var(--sp-1);flex-direction:column}}@media (width<=480px){.tab{padding:var(--sp-2)}.run-json{max-height:45vh}}@media (prefers-reduced-motion:reduce){.run-attempt,.tab{transition:none}}.skill-search{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3);width:220px}.skill-search:focus{outline:2px solid var(--accent-soft);outline-offset:1px}.skill-card{flex-direction:column;display:flex}.skill-desc{color:var(--fg-muted);font-size:var(--text-sm);margin:0 0 var(--sp-3);flex:1}.skill-source{font-size:var(--text-xs);color:var(--fg-subtle)}.wf-stage-card{margin-top:var(--sp-4)}.wf-rate{font-size:var(--text-sm);color:var(--fg);align-items:baseline;gap:var(--sp-2);display:flex}.wf-rate-sub{font-size:var(--text-xs);color:var(--fg-subtle)}.wf-bar{border-radius:var(--radius-pill);background:var(--border);height:5px;margin-top:var(--sp-2);width:140px;overflow:hidden}.wf-bar-fill{border-radius:var(--radius-pill);height:100%;transition:width var(--transition)}.wf-bar-ok{background:var(--ok)}.wf-bar-warn{background:var(--warn)}.wf-bar-danger{background:var(--danger)}.wf-bar-info{background:var(--info)}.wf-form{gap:var(--sp-2);flex-direction:column;display:flex}.wf-form input,.wf-form select,.wf-form textarea{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-2);width:100%}.wf-form textarea{resize:vertical}.wf-form input:focus,.wf-form select:focus,.wf-form textarea:focus{outline:2px solid var(--accent);outline-offset:-1px}.wf-form input::placeholder,.wf-form textarea::placeholder{color:var(--fg-subtle)}.channel-card{gap:var(--sp-1);flex-direction:column;display:flex}.channel-desc{color:var(--fg-muted);font-size:var(--text-sm);margin:0}.channel-detail{color:var(--fg-subtle);font-size:var(--text-xs);margin:0}.curator-card{gap:var(--sp-2);flex-direction:column;display:flex}.curator-health-message{color:var(--fg-muted);font-size:var(--text-sm);margin:0}.curator-meta{color:var(--fg-subtle);font-size:var(--text-xs);margin:0}.curator-actions{gap:var(--sp-2);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.curator-action{border-top:1px solid var(--border);padding-top:var(--sp-2)}.curator-action-head{justify-content:space-between;gap:var(--sp-2);font-size:var(--text-sm);display:flex}.curator-action-type{color:var(--fg);font-weight:600}.curator-action-time{color:var(--fg-subtle);font-size:var(--text-xs)}.curator-action-detail{color:var(--fg-muted);font-size:var(--text-sm);margin:var(--sp-1) 0 0}.curator-action-reason{color:var(--fg-subtle);font-size:var(--text-xs);margin:var(--sp-1) 0 0}.cfg-page{max-width:70rem;margin:0 auto}.cfg-section{margin-bottom:var(--sp-4)}.cfg-subhead{font-size:var(--text-sm);color:var(--fg-muted);margin:var(--sp-5) 0 var(--sp-2);font-weight:600}.cfg-subhead:first-child{margin-top:0}.kv-list{column-gap:var(--sp-4);grid-template-columns:max-content minmax(0,1fr) auto;row-gap:0;display:grid}.kv{grid-template-columns:subgrid;align-items:center;row-gap:var(--sp-1);padding:var(--sp-2) 0;border-radius:var(--radius-sm);grid-column:1/-1;display:grid}@supports not (grid-template-columns:subgrid){.kv-list{flex-direction:column;width:auto;display:flex}.kv{column-gap:var(--sp-4);grid-template-columns:minmax(8rem,16rem) minmax(0,1fr) auto}}.kv+.kv{border-top:1px solid var(--border)}.kv:hover{background:var(--surface-hover)}.kv-label{font-size:var(--text-sm);color:var(--fg-muted)}.kv-value{min-width:0;font-size:var(--text-sm);color:var(--fg);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.kv-value.is-empty{color:var(--fg-subtle)}.kv-actions{align-items:center;gap:var(--sp-2);justify-self:end;display:flex}.kv-note{font-size:var(--text-xs);color:var(--fg-subtle);grid-column:2/-1}.kv-note.is-error{color:var(--danger)}.kv.is-locked .kv-value{color:var(--fg-muted)}.kv-btn{font:inherit;font-size:var(--text-xs);color:var(--fg-subtle);border:1px solid var(--border);border-radius:var(--radius-sm);padding:2px var(--sp-2);cursor:pointer;background:0 0;flex:none;transition:color .12s,border-color .12s,background .12s}.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)}.kv-btn:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.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(--bg,var(--surface));border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-1) var(--sp-2);width:100%;min-width:0}.kv-input:focus{outline:2px solid var(--accent);outline-offset:-1px}.kv-save,.kv-cancel{font:inherit;font-size:var(--text-xs);border-radius:var(--radius-sm);padding:var(--sp-1) var(--sp-2);cursor:pointer;flex:none}.kv-save{background:var(--accent);border:1px solid var(--accent);color:var(--accent-fg);font-weight:500}.kv-save:disabled{opacity:.6;cursor:default}.kv-cancel{border:1px solid var(--border-strong);color:var(--fg-muted);background:0 0}.kv-cancel:hover{color:var(--fg)}.cfg-notice{border-left:3px solid var(--warn)}.cfg-notice p{font-size:var(--text-sm);color:var(--warn);margin:0}@media (width<=700px){.kv-list{flex-direction:column;width:auto;display:flex}.kv{column-gap:var(--sp-4);grid-template-columns:minmax(0,1fr) auto}.kv-label{grid-column:1}.kv-actions{grid-area:1/2}.kv-value,.kv-note{white-space:normal;overflow-wrap:anywhere;grid-column:1/-1}}.log-filters{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.log-status{gap:var(--sp-3);align-items:center;display:flex}.log-meta{font-size:var(--text-xs);color:var(--fg-subtle);font-family:var(--font-mono)}.log-select,.log-search{background:var(--bg-raised);border:1px solid var(--border-strong);color:var(--fg);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3);font:inherit;font-size:var(--text-sm)}.log-search{min-width:220px}.log-select:focus,.log-search:focus{outline:2px solid var(--accent);outline-offset:-1px}.log-list{max-height:62vh;font-family:var(--font-mono);font-size:var(--text-xs);border-top:1px solid var(--border);overflow-y:auto}.log-loading{padding:var(--sp-5);color:var(--fg-muted);text-align:center}.log-row{gap:var(--sp-3);padding:var(--sp-2) var(--sp-1);border-bottom:1px solid var(--border);grid-template-columns:62px 52px 1fr;align-items:baseline;display:grid}.log-row:hover{background:var(--surface-hover)}.log-time{color:var(--fg-subtle)}.log-level{letter-spacing:.04em;font-size:10px;font-weight:600}.log-danger .log-level{color:var(--danger)}.log-warn .log-level{color:var(--warn)}.log-info .log-level{color:var(--info)}.log-idle .log-level{color:var(--idle)}.log-danger .log-msg{color:var(--fg)}.log-body{gap:var(--sp-2);flex-wrap:wrap;align-items:baseline;min-width:0;display:flex}.log-msg{color:var(--fg);word-break:break-word}.log-field{color:var(--fg-muted);background:var(--bg-raised);border-radius:var(--radius-sm);padding:0 var(--sp-2);white-space:nowrap;text-overflow:ellipsis;max-width:100%;overflow:hidden}.log-field-key{color:var(--fg-subtle)}.log-field-key:after{content:"=";opacity:.6}@media (width<=860px){.log-row{grid-template-columns:56px 1fr}.log-level{display:none}.log-search{flex:1;min-width:0}}.capture-row{cursor:pointer}.capture-row:hover{background:var(--bg-raised)}.capture-row:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}.capture-detail-row td{padding:var(--sp-3) var(--sp-3) var(--sp-4);border-bottom:1px solid var(--border)}.capture-detail{gap:var(--sp-4);grid-template-columns:1fr 1fr;display:grid}.capture-detail-section{min-width:0}.capture-detail-title{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--fg-subtle);margin-bottom:var(--sp-2)}.capture-payload{background:var(--bg-raised);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-3);font-family:var(--font-mono);font-size:var(--text-xs);white-space:pre-wrap;word-break:break-word;max-height:24rem;overflow:auto}.capture-empty{color:var(--fg-muted);font-size:var(--text-sm)}@media (width<=640px){.capture-detail{grid-template-columns:1fr}}.mapping-form,.mapping-fields,.mapping-payload{margin-bottom:var(--sp-4);padding:var(--sp-4)}.mapping-form-row{gap:var(--sp-1);margin-bottom:var(--sp-3);font-size:var(--text-sm);color:var(--fg-subtle);flex-direction:column;display:flex}.mapping-input,.mapping-select{padding:var(--sp-2);border:1px solid var(--border-strong);border-radius:var(--radius-sm);background:var(--bg-raised);color:var(--fg);font:inherit}.mapping-section-title{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--fg-subtle);margin-bottom:var(--sp-2)}.mapping-fields-table .mapping-input{width:100%}.mapping-empty-fields{color:var(--fg-muted);font-size:var(--text-sm);padding:var(--sp-3) 0}.mapping-error{color:var(--danger,#e5484d);font-size:var(--text-sm);margin-bottom:var(--sp-3)}.mapping-tree-list{padding-left:var(--sp-4);font-family:var(--font-mono);font-size:var(--text-xs);margin:0;list-style:none}.mapping-tree-item{padding:2px 0}.mapping-tree-key,.mapping-tree-value{cursor:pointer;border-radius:var(--radius-sm);padding:0 4px}.mapping-tree-key:hover,.mapping-tree-value:hover{background:var(--bg-raised);outline:1px solid var(--accent)}.mapping-tree-value{color:var(--fg-subtle);margin-left:var(--sp-1)}.binding-form{margin-bottom:var(--sp-4);padding:var(--sp-4)}.binding-form-row{gap:var(--sp-1);margin-bottom:var(--sp-3);font-size:var(--text-sm);color:var(--fg-subtle);flex-direction:column;display:flex}.binding-input,.binding-select{padding:var(--sp-2);border:1px solid var(--border-strong);border-radius:var(--radius-sm);background:var(--bg-raised);color:var(--fg);font:inherit}.binding-error{color:var(--danger,#e5484d);font-size:var(--text-sm);margin-bottom:var(--sp-3)}.chat-panel-content{flex:auto;grid-template-rows:auto minmax(0,1fr);min-height:0;display:grid;overflow:hidden}.chat-bar{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-bottom:1px solid var(--border);display:flex}.chat-session-switch{flex:auto;min-width:0}.chat-session-switch select{background:var(--surface-hover);width:100%;color:var(--fg);border:1px solid var(--border);border-radius:var(--radius-sm);padding:var(--sp-2);font:inherit;font-size:var(--text-sm)}.chat-new,.chat-settings>summary{flex:none}.chat-settings{flex:none;position:relative}.chat-settings>summary{border-radius:var(--radius-sm);width:32px;height:32px;color:var(--fg-muted);cursor:pointer;place-items:center;list-style:none;display:grid}.chat-settings>summary::-webkit-details-marker{display:none}.chat-settings>summary:hover{background:var(--surface-hover);color:var(--fg)}.chat-settings-body{top:calc(100% + var(--sp-2));z-index:2;gap:var(--sp-3);width:15rem;padding:var(--sp-3);background:var(--bg-raised);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-md);display:grid;position:absolute;right:0}.chat-settings-body label{gap:var(--sp-1);font-size:var(--text-xs);color:var(--fg-muted);display:grid}.chat-settings-body .chat-select{width:100%}.chat-layout{min-height:0;display:grid;overflow:hidden}.chat-workspace{grid-template-rows:auto minmax(0,1fr) auto;min-width:0;display:grid;overflow:hidden}.chat-workspace-head{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-bottom:1px solid var(--border);font-size:var(--text-xs);display:flex}.chat-update-panel{border:1px solid var(--border);color:var(--fg-muted);border-radius:.75rem;flex:none;justify-content:space-between;align-items:center;gap:1rem;margin:0 0 .75rem;padding:.7rem .9rem;font-size:.8rem;display:flex}.chat-update-panel>div:first-child{gap:.2rem;display:grid}.chat-update-panel strong{color:var(--fg)}.chat-update-actions{flex-shrink:0;gap:.45rem;display:flex}.chat-dangerous-panel{border:1px solid color-mix(in srgb, var(--danger) 45%, var(--border));border-radius:.75rem;flex:none;margin:0 0 .75rem;padding:.8rem .9rem}.chat-dangerous-head,.chat-dangerous-controls,.chat-dangerous-pending{justify-content:space-between;align-items:center;gap:.6rem;display:flex}.chat-dangerous-head{margin-bottom:.7rem}.chat-dangerous-controls{flex-wrap:wrap;align-items:stretch}.chat-dangerous-controls>div{flex:18rem;gap:.45rem;display:flex}.chat-dangerous-input{background:var(--surface-hover);min-width:0;color:var(--fg);border:1px solid var(--border-strong);font:inherit;border-radius:.5rem;flex:1;padding:.5rem .65rem}.chat-dangerous-pending-list{gap:.45rem;margin-top:.75rem;display:grid}.chat-dangerous-pending{border-top:1px solid var(--border);color:var(--fg-muted);padding-top:.55rem;font-size:.8rem}.chat-session-list{gap:.35rem;margin-top:1rem;display:grid}.chat-session{text-align:left;color:var(--fg-muted);cursor:pointer;background:0 0;border:1px solid #0000;border-radius:.65rem;gap:.25rem;padding:.7rem;display:grid}.chat-session:hover,.chat-session.active{background:var(--surface-hover);color:var(--fg);border-color:var(--border-strong)}.chat-session span{font-size:.72rem}.chat-session-tools{color:var(--fg-muted);margin-left:.6rem;font-size:.78rem;position:relative}.chat-session-tools summary{cursor:pointer}.chat-session-tool-list{z-index:2;background:var(--surface);border:1px solid var(--border-strong);border-radius:.65rem;flex-wrap:wrap;gap:.35rem;width:min(22rem,72vw);padding:.55rem;display:flex;position:absolute;top:calc(100% + .45rem);right:0;box-shadow:0 .7rem 2rem #0000004d}.chat-select{background:var(--surface-hover);color:var(--fg);border:1px solid var(--border-strong);border-radius:.5rem;padding:.5rem .65rem}.chat-transcript{padding:var(--sp-4);align-content:start;gap:var(--sp-4);display:grid;overflow:auto}.chat-empty-state{width:100%;padding:var(--sp-5) 0;text-align:center;place-self:center}.chat-empty-mark{width:2.2rem;height:2.2rem;margin:0 auto var(--sp-3);border:1px solid var(--border-strong);color:var(--accent);border-radius:.8rem;place-items:center;font-weight:700;display:grid}.chat-empty-state h2{font-size:var(--text-lg);letter-spacing:-.02em;margin:0}.chat-empty-state p{margin:var(--sp-2) 0 var(--sp-4);color:var(--fg-muted);font-size:var(--text-sm)}.chat-prompt-grid{gap:var(--sp-2);display:grid}.chat-prompt{padding:var(--sp-2) var(--sp-3);font-size:var(--text-sm);text-align:left;border:1px solid var(--border);background:var(--surface-hover);color:var(--fg-muted);cursor:pointer;border-radius:999px}.chat-prompt:hover{color:var(--fg);border-color:var(--border-strong)}.chat-bubble-row{display:flex}.chat-bubble-row.user{justify-content:flex-end}.chat-bubble{background:var(--surface-hover);border-radius:.85rem;max-width:min(78ch,86%);padding:.8rem 1rem;line-height:1.5}.chat-bubble-row.user .chat-bubble{background:color-mix(in srgb, var(--accent) 18%, var(--surface))}.chat-bubble-meta{color:var(--fg-muted);margin-bottom:.3rem;font-size:.7rem}.chat-bubble-text{white-space:pre-wrap;overflow-wrap:anywhere}.chat-bubble-text p{margin:0 0 .7rem}.chat-bubble-text p:last-child{margin-bottom:0}.chat-bubble-text h1,.chat-bubble-text h2,.chat-bubble-text h3{letter-spacing:-.02em;margin:.2rem 0 .6rem;line-height:1.2}.chat-bubble-text h1{font-size:1.25rem}.chat-bubble-text h2{font-size:1.1rem}.chat-bubble-text h3{font-size:1rem}.chat-bubble-text ul,.chat-bubble-text ol{margin:.25rem 0 .75rem;padding-left:1.35rem}.chat-bubble-text blockquote{border-left:3px solid var(--accent);color:var(--fg-muted);margin:.5rem 0;padding:.35rem .75rem}.chat-bubble-text code{background:color-mix(in srgb, var(--fg) 10%, transparent);border-radius:.3rem;padding:.1rem .3rem;font-size:.9em}.chat-bubble-text pre{border:1px solid var(--border);background:color-mix(in srgb, var(--surface) 75%, #000);border-radius:.5rem;margin:.6rem 0;padding:.75rem;overflow:auto}.chat-bubble-text pre code{background:0 0;padding:0}.chat-bubble-text a{color:var(--accent)}.chat-media-img{border:1px solid var(--border);object-fit:contain;background:var(--surface);cursor:pointer;border-radius:.5rem;max-width:100%;max-height:24rem;margin:.4rem 0;display:block}.chat-bubble-text table{border-collapse:collapse;width:100%;margin:.7rem 0;font-size:.92em}.chat-bubble-text th,.chat-bubble-text td{text-align:left;border:1px solid var(--border);padding:.45rem .6rem}.chat-bubble-text th{color:var(--fg);background:color-mix(in srgb, var(--surface) 70%, transparent);font-weight:700}.chat-tools{gap:.2rem;margin-bottom:.5rem;font-size:.78rem;display:grid}.chat-tools:empty{display:none}.chat-tool{color:var(--fg-muted);overflow-wrap:anywhere;align-items:baseline;gap:.4rem;display:flex}.chat-tool-name{color:var(--fg);font-weight:600}.chat-tool.failed .chat-tool-summary{color:var(--danger)}.chat-nav-chip{border:1px solid color-mix(in srgb, var(--accent) 45%, var(--border));background:var(--accent-soft);color:var(--accent);cursor:pointer;transition:background var(--transition), border-color var(--transition), color var(--transition);border-radius:999px;align-items:center;gap:.4rem;padding:.4rem .7rem;font-size:.82rem;font-weight:600;display:inline-flex}.chat-nav-chip:hover{border-color:var(--accent);background:color-mix(in srgb, var(--accent) 16%, var(--surface))}.chat-nav-chip:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.chat-nav-chip-icon{font-size:.8rem;line-height:1}.chat-compose{padding:var(--sp-3);border-top:1px solid var(--border)}.chat-composer-shell{background:var(--surface-hover);border:1px solid var(--border-strong);border-radius:.9rem;padding:.7rem .8rem .55rem;position:relative}.chat-composer{resize:vertical;box-sizing:border-box;width:100%;min-height:3.3rem;color:var(--fg);font:inherit;background:0 0;border:0;padding:.25rem 0}.chat-composer:focus{outline:0}.chat-command-menu{z-index:3;background:var(--surface);border:1px solid var(--border-strong);border-radius:.7rem;gap:.15rem;max-height:18rem;padding:.35rem;display:grid;position:absolute;bottom:calc(100% - .25rem);left:.8rem;right:.8rem;overflow:auto;box-shadow:0 .7rem 2rem #0000004d}.chat-command-menu[hidden]{display:none}.chat-command-option{text-align:left;color:var(--fg-muted);cursor:pointer;background:0 0;border:1px solid #0000;border-radius:.45rem;grid-template-columns:minmax(8rem,14rem) 1fr;align-items:center;gap:.65rem;padding:.5rem .6rem;display:grid}.chat-command-option:hover,.chat-command-option[aria-selected=true]{color:var(--fg);background:var(--surface-hover);border-color:var(--border)}.chat-command-option code{color:var(--fg)}.chat-compose-actions{margin-top:var(--sp-2);row-gap:var(--sp-2);flex-wrap:wrap;justify-content:flex-end}.chat-compose-actions .chat-hint{font-size:var(--text-xs);color:var(--fg-muted);flex:1 0 100%}.chat-hint,.chat-empty{color:var(--fg-muted);font-size:.78rem}.chat-command-help{color:var(--fg-muted);margin-right:auto;font-size:.78rem}.chat-command-help summary{cursor:pointer}.chat-command-list{min-width:min(34rem,70vw);max-width:40rem;padding-top:.4rem;line-height:1.45}.chat-command-item{grid-template-columns:minmax(10rem,16rem) 1fr;gap:.7rem;padding:.3rem 0;display:grid}.chat-command-item code{color:var(--fg)}@media (width<=520px){.chat-update-panel{flex-direction:column;align-items:flex-start}} +:root{--font-sans:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;--font-mono:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;--text-xs:.6875rem;--text-sm:.8125rem;--text-base:.875rem;--text-lg:1.0625rem;--text-xl:1.375rem;--text-2xl:1.875rem;--text-3xl:2.5rem;--sp-1:.25rem;--sp-2:.5rem;--sp-3:.75rem;--sp-4:1rem;--sp-5:1.5rem;--sp-6:2rem;--sp-7:3rem;--radius-sm:6px;--radius-md:10px;--radius-lg:14px;--radius-xl:20px;--radius-pill:999px;--transition:.14s cubic-bezier(.4, 0, .2, 1)}[data-theme=dark]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--bg:#0d1014;--bg-raised:#141920;--surface:#171d25;--surface-hover:#1d242e;--border:#232b36;--border-strong:#303a48;--fg:#e8edf4;--fg-muted:#8b97a8;--fg-subtle:#5d6878;--accent:#4c8dff;--accent-fg:#fff;--accent-soft:#4c8dff24;--ok:#3fbf7f;--ok-soft:#3fbf7f24;--warn:#e8a33d;--warn-soft:#e8a33d24;--danger:#f0616d;--danger-soft:#f0616d24;--info:#4c8dff;--info-soft:#4c8dff24;--idle:#6b7688;--idle-soft:#6b768824;--accent-2:#7b5cff;--bg-blur:#1419208c;--surface-glass:#171d259e;--surface-glass-strong:#141920c7;--workspace:#11151b8c;--hairline:#ffffff0f;--wash-a:#4c8dff1a;--wash-b:#7b5cff1f;--wash-c:#3fbf7f0f;--shadow-workspace:0 24px 70px #00000080;--shadow-sm:0 1px 2px #0006;--shadow-md:0 8px 28px #0000006b}[data-theme=light]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--bg:#f6f8fb;--bg-raised:#fff;--surface:#fff;--surface-hover:#f1f4f9;--border:#e2e8f0;--border-strong:#cbd5e1;--fg:#16202e;--fg-muted:#5a6779;--fg-subtle:#8c99ab;--accent:#2563eb;--accent-fg:#fff;--accent-soft:#2563eb1a;--ok:#10935c;--ok-soft:#10935c1f;--warn:#b87514;--warn-soft:#b875141f;--danger:#d4344a;--danger-soft:#d4344a1f;--info:#2563eb;--info-soft:#2563eb1a;--idle:#64748b;--idle-soft:#64748b1f;--accent-2:#7c3aed;--bg-blur:#fff9;--surface-glass:#ffffffb8;--surface-glass-strong:#ffffffe0;--workspace:#ffffff8c;--hairline:#0f172a0f;--wash-a:#2563eb1a;--wash-b:#7c3aed1f;--wash-c:#10935c12;--shadow-workspace:0 24px 70px #0f172a24;--shadow-sm:0 1px 2px #0f172a0f;--shadow-md:0 8px 28px #0f172a1a}*,:before,:after{box-sizing:border-box}html,body{height:100%;margin:0}body{color:var(--fg);font-family:var(--font-sans);font-size:var(--text-base);-webkit-font-smoothing:antialiased;line-height:1.5}a{color:inherit;text-decoration:none}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.visually-hidden,.sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}body{background:radial-gradient(70rem 40rem at 8% -10%, var(--wash-a), transparent 62%), radial-gradient(56rem 34rem at 92% 4%, var(--wash-b), transparent 58%), radial-gradient(48rem 30rem at 50% 108%, var(--wash-c), transparent 60%), var(--bg);padding:var(--sp-4);background-attachment:fixed}.shell{min-height:calc(100vh - var(--sp-4) * 2);border-radius:var(--radius-xl);border:1px solid var(--hairline);background:var(--workspace);-webkit-backdrop-filter:blur(28px)saturate(120%);backdrop-filter:blur(28px)saturate(120%);box-shadow:var(--shadow-workspace);flex-direction:column;display:flex;overflow:hidden}.topbar{align-items:center;gap:var(--sp-4);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--hairline);background:var(--bg-blur);z-index:10;display:flex;position:sticky;top:0}.brand{align-items:center;gap:var(--sp-2);font-weight:600;font-size:var(--text-sm);letter-spacing:-.01em;flex:none;display:flex}.brand-mark{background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;width:26px;height:26px;font-size:var(--text-xs);border-radius:8px;place-items:center;font-weight:700;display:grid}.nav{scrollbar-width:none;border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);flex:0 auto;align-items:center;gap:2px;min-width:0;margin:0 auto;padding:3px;display:flex;overflow-x:auto}.nav::-webkit-scrollbar{display:none}.nav-item{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);color:var(--fg-muted);font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:background var(--transition), color var(--transition);flex:none;display:inline-flex}.nav-item:hover{color:var(--fg);background:var(--surface-hover)}.nav-item[aria-current=page]{background:var(--accent);color:var(--accent-fg);font-weight:500}.nav-item .nav-label{display:inline}.topbar-end{align-items:center;gap:var(--sp-2);flex:none;display:flex}.topbar-search{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);color:var(--fg-subtle);display:flex}.topbar-search input{color:var(--fg);font:inherit;font-size:var(--text-sm);background:0 0;border:0;outline:none;width:8rem}.topbar-search input::placeholder{color:var(--fg-subtle)}.mobile-search-toggle{display:none}.icon-btn{border-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(--accent), var(--accent-2));cursor:pointer;flex:none;place-items:center;font-weight:600;display:grid}.ico{flex:none;display:block}.main{padding:var(--sp-6);flex:1;width:100%;overflow-x:hidden}.chat-dock{--fab-size:56px;--fab-inset:var(--sp-5);--fab-gap:var(--sp-3);right:var(--fab-inset);bottom:var(--fab-inset);z-index:40;position:fixed}.chat-fab{width:var(--fab-size);height:var(--fab-size);border-radius:var(--radius-pill);background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;cursor:pointer;box-shadow:var(--shadow-md);transition:transform var(--transition), box-shadow var(--transition);border:0;place-items:center;display:grid;position:relative}.chat-fab:hover{box-shadow:0 12px 34px color-mix(in srgb, var(--accent) 38%, transparent);transform:translateY(-1px)}.chat-fab:active{transform:translateY(0)}.chat-fab-icon{transition:opacity var(--transition), transform var(--transition);grid-area:1/1;place-items:center;display:grid}.chat-fab-icon-close,.chat-dock.is-open .chat-fab-icon-open{opacity:0;transform:scale(.7)rotate(-45deg)}.chat-fab-icon-open,.chat-dock.is-open .chat-fab-icon-close{opacity:1;transform:none}.chat-drawer{right:calc(var(--fab-size) + var(--fab-gap));width:min(440px, calc(100vw - var(--fab-size) - var(--fab-gap) - var(--fab-inset) * 2));height:min(640px, calc(100vh - var(--fab-inset) * 2));pointer-events:none;position:absolute;bottom:0}.chat-drawer-panel{pointer-events:auto;background:var(--surface);border:1px solid var(--border);width:100%;height:100%;box-shadow:var(--shadow-md);opacity:0;border-radius:var(--radius-pill);transform-origin:100% 100%;transform:translateX(calc(var(--fab-size) + var(--fab-gap))) scale(.16);grid-template-rows:minmax(0,1fr);transition:opacity .16s cubic-bezier(.4,0,.2,1),transform .26s cubic-bezier(.22,1,.36,1),border-radius .26s cubic-bezier(.22,1,.36,1);display:grid;overflow:hidden}.chat-drawer.is-open .chat-drawer-panel{opacity:1;border-radius:var(--radius-lg);transform:none}.chat-drawer-panel>*{opacity:0;transition:opacity .12s linear}.chat-drawer.is-open .chat-drawer-panel>*{opacity:1;transition:opacity .16s linear .12s}.chat-drawer:not(.is-open) .chat-drawer-panel{pointer-events:none;visibility:hidden;transition:opacity .14s cubic-bezier(.4,0,.2,1),transform .2s cubic-bezier(.4,0,1,1),border-radius .2s cubic-bezier(.4,0,1,1),visibility 0s linear .2s}.chat-drawer-head{justify-content:space-between;align-items:center;gap:var(--sp-2);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--border);display:flex}@media (width<=720px){.chat-dock{--fab-inset:var(--sp-4)}.chat-drawer{right:var(--fab-inset);left:var(--fab-inset);bottom:calc(var(--fab-inset) + var(--fab-size) + var(--fab-gap));width:auto;height:min(72vh, calc(100vh - var(--fab-inset) * 2 - var(--fab-size) - var(--fab-gap)));position:fixed}.chat-drawer-panel{transform-origin:100% 100%;transform:translateY(calc(var(--fab-size) + var(--fab-gap))) scale(.16)}.chat-fab{z-index:1;position:relative}}@media (width<=1500px){.topbar-search{background:0 0;border:0;padding:0;overflow:hidden}.topbar-search-icon{display:none}.mobile-search-toggle{display:grid}.topbar-search input{opacity:0;pointer-events:none;width:0;transition:width var(--transition), opacity var(--transition);padding:0}.topbar-search.is-open,.topbar-search:focus-within{padding-right:var(--sp-2);border:1px solid var(--hairline);background:var(--surface-glass-strong)}.topbar-search.is-open input,.topbar-search:focus-within input{opacity:1;pointer-events:auto;width:min(9rem,34vw)}}@media (width<=1270px) and (width>=901px){.topbar{flex-wrap:wrap}.nav{border-radius:var(--radius-lg);flex-wrap:wrap;order:3;justify-content:center;width:100%;margin:0}}@media (width<=900px){body{padding:0}.shell{min-height:100vh;box-shadow:none;border:0;border-radius:0}.topbar{padding:var(--sp-3);gap:var(--sp-2);flex-wrap:wrap}.nav{border-radius:var(--radius-lg);scrollbar-width:none;flex-wrap:nowrap;order:3;justify-content:flex-start;width:100%;overflow-x:auto}.nav::-webkit-scrollbar{display:none}.nav-item .nav-label{display:inline}.main{padding:var(--sp-4)}}.page-head{justify-content:space-between;align-items:flex-start;gap:var(--sp-5);margin-bottom:var(--sp-6);flex-wrap:wrap;display:flex}.page-title{font-size:var(--text-2xl);letter-spacing:-.02em;margin:0;font-weight:600}.page-sub{color:var(--fg-muted);font-size:var(--text-sm);margin:var(--sp-1) 0 0}.page-actions{gap:var(--sp-2);align-items:center;display:flex}.btn{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-4);border-radius:var(--radius-pill);border:1px solid var(--border-strong);background:var(--surface);color:var(--fg);font:inherit;font-size:var(--text-sm);cursor:pointer;transition:background var(--transition), border-color var(--transition);display:inline-flex}.btn:hover{background:var(--surface-hover)}.btn-primary{background:var(--accent);border-color:var(--accent);color:var(--accent-fg);font-weight:500}.btn-primary:hover{filter:brightness(1.08);background:var(--accent)}.btn-icon{padding:var(--sp-2);border-radius:var(--radius-sm)}.card{background:var(--surface-glass);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);border:1px solid var(--hairline);border-radius:var(--radius-lg);padding:var(--sp-5);box-shadow:var(--shadow-sm);overflow-x:auto}.card-head{justify-content:space-between;align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.card-title{font-size:var(--text-base);margin:0;font-weight:600}.card-sub{font-size:var(--text-xs);color:var(--fg-muted);margin:var(--sp-1) 0 0}.grid{gap:var(--sp-4);display:grid}.grid>*{min-width:0}.grid-4{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}.grid-2{grid-template-columns:repeat(auto-fit,minmax(340px,1fr))}.pill{align-items:center;gap:var(--sp-1);padding:2px var(--sp-2);border-radius:var(--radius-pill);font-size:var(--text-xs);white-space:nowrap;font-weight:500;display:inline-flex}.pill:before{content:"";background:currentColor;border-radius:50%;width:5px;height:5px}.pill-ok{color:var(--ok);background:var(--ok-soft)}.pill-warn{color:var(--warn);background:var(--warn-soft)}.pill-danger{color:var(--danger);background:var(--danger-soft)}.pill-info{color:var(--info);background:var(--info-soft)}.pill-idle{color:var(--idle);background:var(--idle-soft)}.table{border-collapse:collapse;width:100%;font-size:var(--text-sm)}.table-scroll{-webkit-overflow-scrolling:touch;min-width:0;max-width:100%;overflow-x:auto}.table-scroll>.table{min-width:42rem}.table th{text-align:left;font-weight:500;font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--fg-subtle);padding:0 var(--sp-3) var(--sp-3);border-bottom:1px solid var(--border)}.table td{padding:var(--sp-3);border-bottom:1px solid var(--border);color:var(--fg-muted)}.table tbody tr:last-child td{border-bottom:0}.table tbody tr:hover td{background:var(--surface-hover)}.table td.strong{color:var(--fg);font-weight:500}.mono{font-family:var(--font-mono);font-size:.95em}.empty{text-align:center;padding:var(--sp-7) var(--sp-4);color:var(--fg-muted)}.empty-title{color:var(--fg);margin-bottom:var(--sp-1);font-weight:500}.skeleton{background:linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);border-radius:var(--radius-sm);background-size:200% 100%;animation:1.4s infinite shimmer}@keyframes shimmer{to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){*,:before,:after{transition-duration:.01ms!important;animation-duration:.01ms!important}}.nav-soon{font-size:var(--text-xs);color:var(--fg-subtle);background:var(--surface-hover);padding:1px var(--sp-2);border-radius:var(--radius-pill);margin-left:auto}.nav-item[aria-disabled]{opacity:.55;cursor:default}.nav-item[aria-disabled]:hover{color:var(--fg-muted);background:0 0}.stat-head{justify-content:space-between;align-items:center;gap:var(--sp-2);display:flex}.stat-label{font-size:var(--text-sm);color:var(--fg-muted)}.stat-trend{font-size:var(--text-xs);align-items:center;gap:3px;font-weight:500;display:inline-flex}.stat-trend.up{color:var(--ok)}.stat-trend.down{color:var(--danger)}.stat-value{font-size:var(--text-3xl);letter-spacing:-.03em;margin:var(--sp-2) 0 0;font-weight:600}.stat-unit{font-size:var(--text-lg);color:var(--fg-muted);margin-left:var(--sp-1)}.stat-compare{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:var(--sp-1)}.spark{width:100%;height:34px;margin-top:var(--sp-3);display:block}.setup{margin-bottom:var(--sp-4)}.setup-pct{font-size:var(--text-lg);color:var(--accent);font-weight:600}.setup-complete-actions{align-items:center;gap:var(--sp-2);display:flex}.setup-dismiss{width:28px;height:28px;font-size:var(--text-lg);line-height:1}.setup-done .setup-pct{color:var(--ok)}.setup-bar{border-radius:var(--radius-pill);background:var(--border);height:5px;margin-bottom:var(--sp-4);overflow:hidden}.setup-bar-fill{background:var(--accent);border-radius:var(--radius-pill);height:100%;transition:width var(--transition)}.setup-list{gap:var(--sp-3);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.setup-step{gap:var(--sp-3);align-items:flex-start;display:flex}.setup-check{border:1.5px solid var(--border-strong);width:18px;height:18px;font-size:var(--text-xs);color:var(--fg-subtle);border-radius:50%;flex:none;place-items:center;margin-top:1px;display:grid}.setup-step.done .setup-check{background:var(--ok-soft);color:var(--ok);border-color:#0000}.setup-step-title{font-size:var(--text-sm)}.setup-step.done .setup-step-title{color:var(--fg-muted);text-decoration:line-through}.setup-step-detail{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:2px}.hero{justify-content:space-between;align-items:flex-start;gap:var(--sp-5);margin-bottom:var(--sp-5);flex-wrap:wrap;display:flex}.hero-title{font-size:var(--text-3xl);letter-spacing:-.03em;margin:0;font-weight:600}.hero-sub{color:var(--fg-muted);font-size:var(--text-sm);margin:var(--sp-2) 0 0}.hero-actions{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.dash-top{gap:var(--sp-4);margin-bottom:var(--sp-4);grid-template-columns:minmax(0,1.6fr) minmax(0,1fr);display:grid}.dash-top>*,.dash-split>*{min-width:0}.dash-top>div{display:flex}.dash-top>div>.card{flex:1}.dash-top-standalone{grid-template-columns:minmax(0,1fr)}@media (width<=1080px){.dash-top{grid-template-columns:minmax(0,1fr)}}.gauge-wrap{place-items:center;display:grid;position:relative}.gauge{width:100%;max-width:200px;display:block}.gauge-value{transition:stroke-dashoffset .6s cubic-bezier(.4,0,.2,1)}.gauge-center{text-align:center;position:absolute;top:52%;transform:translateY(-50%)}.gauge-pct{font-size:var(--text-2xl);letter-spacing:-.03em;font-weight:600}.gauge-label{font-size:var(--text-xs);color:var(--fg-muted)}.pulse-list{margin:var(--sp-4) 0 0;gap:var(--sp-2);flex-direction:column;padding:0;list-style:none;display:flex}.pulse-item{justify-content:space-between;align-items:center;gap:var(--sp-3);font-size:var(--text-sm);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-sm);background:var(--bg-raised);display:flex}.pulse-name{color:var(--fg-muted);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.segbar{border-radius:var(--radius-pill);background:var(--border);gap:2px;height:10px;display:flex;overflow:hidden}.segbar-part{height:100%;display:block}.segbar-ok{background:var(--ok)}.segbar-warn{background:var(--warn)}.segbar-danger{background:var(--danger)}.segbar-info{background:var(--info)}.segbar-idle{background:var(--idle)}.segbar-legend{gap:var(--sp-4);margin-top:var(--sp-3);flex-wrap:wrap;display:flex}.segbar-key{align-items:center;gap:var(--sp-2);font-size:var(--text-xs);color:var(--fg-muted);display:inline-flex}.segbar-dot{border-radius:50%;width:8px;height:8px}.forecast-value{font-size:var(--text-3xl);letter-spacing:-.03em;margin-bottom:var(--sp-1);font-weight:600}.forecast-note{font-size:var(--text-xs);color:var(--fg-subtle);margin-bottom:var(--sp-4)}.dash-split{gap:var(--sp-4);margin-top:var(--sp-4);grid-template-columns:minmax(0,1fr) minmax(0,1.5fr);display:grid}@media (width<=1080px){.dash-split{grid-template-columns:minmax(0,1fr)}}.stat-card{position:relative;overflow:hidden}.dash-section{margin-bottom:var(--sp-5)}.dash-section-head{align-items:baseline;gap:var(--sp-3);margin-bottom:var(--sp-3);padding-left:var(--sp-1);display:flex}.dash-section-title{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.08em;color:var(--fg-subtle);margin:0;font-weight:600}.dash-section-note{font-size:var(--text-xs);color:var(--fg-subtle)}.hero-actions-inner{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.btn-attention{border-color:var(--warn);color:var(--warn);background:var(--warn-soft);font-weight:500}.btn-attention:hover{background:var(--warn-soft);filter:brightness(1.1)}.activity-detail{width:55%;max-width:0}.activity-detail span{text-overflow:ellipsis;white-space:nowrap;display:block;overflow:hidden}.task-summary{margin-bottom:var(--sp-5)}.task-filters{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.task-search,.task-filter{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3)}.task-search{width:220px}.task-search:focus,.task-filter:focus{outline:2px solid var(--accent-soft);outline-offset:1px}.task-row{cursor:pointer}.task-expand{width:1.5rem;height:1.5rem;margin-right:var(--sp-2);color:var(--fg-muted);border:1px solid var(--border);font:inherit;cursor:pointer;background:0 0;border-radius:50%;padding:0;line-height:1}.task-expand:hover,.task-expand:focus-visible{color:var(--fg);border-color:var(--accent)}.activity-row{cursor:pointer}.activity-row:hover td,.activity-row:focus td{background:var(--surface-hover)}.activity-row:focus{outline:2px solid var(--accent);outline-offset:-2px}.task-source-link{color:var(--accent);text-decoration:none}.task-source-link:hover{text-decoration:underline}.task-detail-link{color:inherit}.task-detail-link:hover,.task-detail-link:focus-visible{text-decoration:underline;-webkit-text-decoration-color:var(--accent);text-decoration-color:var(--accent)}.task-actions{gap:var(--sp-1);white-space:nowrap;flex-wrap:wrap;display:flex}.btn-small{padding:var(--sp-1) var(--sp-2);font-size:var(--text-xs)}.btn-quiet{color:var(--fg-muted)}.task-action-error{max-width:220px;font-size:var(--text-xs);white-space:normal}.task-action-error-refused{color:var(--warn)}.task-action-error-broken{color:var(--danger)}.task-action-error-session{color:var(--warn);align-items:center;gap:var(--sp-1);flex-wrap:wrap;display:inline-flex}.task-decision{margin-bottom:var(--sp-4);padding:var(--sp-3);border-left:3px solid var(--accent);background:var(--surface)}.task-detail-actions{justify-content:space-between;align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);padding-bottom:var(--sp-3);border-bottom:1px solid var(--hairline);display:flex}.task-decision-title{color:var(--fg);font-weight:600}.task-decision-plan{margin-top:var(--sp-2);color:var(--fg-muted);white-space:pre-wrap}.task-logs-section{margin-top:var(--sp-4)}.task-logs-section .task-decision-title{justify-content:space-between;align-items:center;display:flex}.task-log-list{max-height:40vh;font-family:var(--font-mono);font-size:var(--text-xs);border-top:1px solid var(--border);margin-top:var(--sp-2);overflow-y:auto}.task-log-loading,.task-log-error{padding:var(--sp-3) 0;color:var(--fg-muted)}@media (width<=700px){.task-filters,.task-search{width:100%}.task-filter{flex:100%}.table-scroll:has(.task-row){overflow:visible}.table:has(.task-row){display:block}.table:has(.task-row) tbody{display:block}.table-scroll>.table:has(.task-row){width:100%;min-width:0}.table:has(.task-row) thead{display:none}.task-row{gap:var(--sp-2) var(--sp-4);margin-bottom:var(--sp-3);padding:var(--sp-3);border:1px solid var(--hairline);border-radius:var(--radius-lg);background:var(--surface-glass);grid-template-columns:1fr 1fr;display:grid}.task-row td{justify-content:space-between;align-items:center;gap:var(--sp-2);padding:var(--sp-1) 0;text-align:right;border:0;display:flex}.task-row td:before{content:attr(data-label);color:var(--fg-subtle);font-size:var(--text-xs);text-align:left;font-weight:500}.task-row td:nth-child(3),.task-row td:last-child{grid-column:1/-1}.task-row td:last-child{align-items:flex-start}.task-timeline-row,.task-timeline-row td{width:100%;display:block}.task-timeline-row td{margin:calc(var(--sp-2) * -1) 0 var(--sp-4);border-radius:0 0 var(--radius-lg) var(--radius-lg)}.task-detail-actions{flex-direction:column;align-items:flex-start}}@media (width<=480px){.task-row{grid-template-columns:1fr}.task-row td:nth-child(3),.task-row td:last-child{grid-column:auto}}.task-timeline-row td{background:var(--bg-raised);padding:var(--sp-4)}.task-timeline-loading{color:var(--fg-muted);font-size:var(--text-sm)}.task-timeline-error{align-items:flex-start;gap:var(--sp-2);flex-direction:column;display:flex}.task-timeline-error .task-timeline-title{color:var(--fg);font-weight:500}.task-timeline{gap:var(--sp-3);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.task-timeline-entry{gap:var(--sp-3);align-items:flex-start;display:flex}.task-timeline-dot{background:var(--accent);border-radius:50%;flex:none;width:8px;height:8px;margin-top:5px}.task-timeline-kind{font-size:var(--text-sm);color:var(--fg);font-weight:500}.task-timeline-detail{font-size:var(--text-xs);color:var(--fg-muted);margin-top:2px}.task-timeline-when{font-size:var(--text-xs);color:var(--fg-subtle);margin-top:2px}.run-meta{align-items:center;gap:var(--sp-4);margin:calc(var(--sp-2) * -1) 0 var(--sp-4);font-size:var(--text-sm);flex-wrap:wrap;display:flex}.run-meta-item{align-items:center;gap:var(--sp-2);display:inline-flex}.run-meta-label{color:var(--fg-muted);font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em}.run-meta-value{color:var(--fg)}.run-meta-muted{color:var(--fg-muted)}.run-meta-link{color:var(--accent)}.run-meta-link:hover{text-decoration:underline}.run-note{margin:0 0 var(--sp-4);padding:var(--sp-3) var(--sp-4);border-left:3px solid var(--warn);background:var(--warn-soft);border-radius:var(--radius-sm);color:var(--fg);font-size:var(--text-sm)}.run-restart{align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.run-restart-copy,.run-restart-unavailable{color:var(--fg-muted);font-size:var(--text-sm);flex:22rem;margin:0}.run-restart-error{font-size:var(--text-sm);flex:100%;margin:0}.run-restart-error-refused{color:var(--warn)}.run-restart-error-broken{color:var(--danger)}.run-restart-error-session-expired{color:var(--warn)}.run-attempts{gap:var(--sp-2);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.run-attempt{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border:1px solid var(--border);border-radius:var(--radius-pill);background:var(--surface);color:var(--fg-muted);font:inherit;font-size:var(--text-sm);cursor:pointer;transition:border-color var(--transition), color var(--transition);display:inline-flex}.run-attempt:hover{border-color:var(--border-strong);color:var(--fg)}.run-attempt.is-selected{border-color:var(--accent);background:var(--accent-soft);color:var(--fg)}.run-attempt-id{font-weight:500}.run-attempt-meta{color:var(--fg-muted);font-size:var(--text-xs)}.run-card{padding-top:var(--sp-4)}.tab-bar{gap:var(--sp-1);border-bottom:1px solid var(--border);margin-bottom:var(--sp-4);scrollbar-width:thin;display:flex;overflow-x:auto}.tab{padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-sm) var(--radius-sm) 0 0;color:var(--fg-muted);font:inherit;font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:color var(--transition), background var(--transition);background:0 0;border:0;border-bottom:2px solid #0000;position:relative}.tab:hover{color:var(--fg);background:var(--surface-hover)}.tab.is-selected{color:var(--fg);border-bottom-color:var(--accent);font-weight:500}.run-panel{min-width:0;min-height:6rem}.run-panel:focus-visible{outline:2px solid var(--accent);outline-offset:4px}.run-loading{padding:var(--sp-5) 0;color:var(--fg-muted);font-size:var(--text-sm)}.run-error{align-items:flex-start;gap:var(--sp-2);padding:var(--sp-3) 0;flex-direction:column;display:flex}.run-error-title{color:var(--fg);font-weight:500}.run-error-detail{color:var(--fg-muted);font-size:var(--text-sm);max-width:60ch}.run-json{padding:var(--sp-3);background:var(--bg-raised);border:1px solid var(--border);border-radius:var(--radius-sm);max-height:60vh;font-family:var(--font-mono);font-size:var(--text-xs);white-space:pre-wrap;overflow-wrap:anywhere;margin:0;line-height:1.5;overflow:auto}.run-rail-head{align-items:center;gap:var(--sp-3);margin-bottom:var(--sp-4);flex-wrap:wrap;display:flex}.run-rail-attempt{font-weight:600}.run-rail-when{color:var(--fg-muted);font-size:var(--text-xs)}.run-stages{margin:0;padding:0;list-style:none}.run-stage{gap:var(--sp-2);padding-bottom:var(--sp-4);grid-template-columns:1.75rem 1fr;display:grid;position:relative}.run-stage:before{content:"";background:var(--border-strong);width:1px;position:absolute;top:1rem;bottom:0;left:.6875rem}.run-stage:last-child:before{display:none}.run-stage-node{z-index:1;border:2px solid var(--border-strong);background:var(--bg-raised);border-radius:50%;width:.875rem;height:.875rem;margin:.25rem 0 0 .25rem;position:relative}.run-stage[data-status=ok] .run-stage-node{border-color:var(--ok)}.run-stage[data-status=failed] .run-stage-node{border-color:var(--danger)}.run-stage[data-status=interrupted] .run-stage-node{border-color:var(--warn)}.run-stage[data-status=running] .run-stage-node{border-color:var(--info)}.run-stage-body{min-width:0}.run-stage-head{align-items:center;gap:var(--sp-2);flex-wrap:wrap;display:flex}.run-stage-name{color:var(--fg);overflow-wrap:anywhere;min-width:0;font-weight:500}.run-stage-duration{color:var(--fg-muted);font-size:var(--text-xs)}.run-stage-error{margin-top:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-left:3px solid var(--danger);background:var(--danger-soft);border-radius:var(--radius-sm);color:var(--fg-muted);font-size:var(--text-sm);white-space:pre-wrap;overflow-wrap:anywhere}.run-agent-report{margin-top:var(--sp-2);color:var(--fg-muted);font-size:var(--text-xs)}.run-agent-report-label{color:var(--fg-muted)}.run-rail-legend,.run-rail-note{margin:var(--sp-3) 0 0;color:var(--fg-muted);font-size:var(--text-xs);max-width:70ch}.run-rail-legend strong{color:var(--fg-muted)}.run-capture+.run-capture{margin-top:var(--sp-5);padding-top:var(--sp-4);border-top:1px solid var(--border)}.run-capture-head{justify-content:space-between;align-items:baseline;gap:var(--sp-3);flex-wrap:wrap;display:flex}.run-capture-when{color:var(--fg);font-size:var(--text-sm);font-weight:500}.run-capture-at{color:var(--fg-muted);font-size:var(--text-xs)}.run-capture-meta{align-items:center;gap:var(--sp-3);margin:var(--sp-2) 0 var(--sp-3);color:var(--fg-muted);font-size:var(--text-xs);flex-wrap:wrap;display:flex}.run-capture-link{color:var(--accent)}.run-capture-link:hover{text-decoration:underline}.run-capture-branch,.run-capture-sha,.run-capture-totals{color:var(--fg-muted)}.run-changes-table td{padding:var(--sp-2) var(--sp-3);vertical-align:top}.run-changes-path{color:var(--fg);word-break:break-all}.run-changes-old{color:var(--fg-muted)}.run-changes-count{text-align:right;white-space:nowrap}.run-changes-hint,.run-changes-note,.run-changes-empty{color:var(--fg-muted);font-size:var(--text-xs)}.run-changes-hint{display:block}.run-changes-empty{padding:var(--sp-3) 0}.run-config-scope{margin:0 0 var(--sp-2);color:var(--fg-muted);font-size:var(--text-sm);max-width:75ch}.run-config-when{margin-bottom:var(--sp-3);color:var(--fg-muted);font-size:var(--text-xs)}.run-config-unknown{margin-bottom:var(--sp-2);color:var(--warn);font-size:var(--text-sm)}.task-log-filters{padding-bottom:var(--sp-3);border-bottom:1px solid var(--border)}.task-log-attempt{color:var(--fg);font-size:var(--text-sm);font-weight:500}.task-log-filter{align-items:center;gap:var(--sp-2);display:inline-flex}.task-log-filter-label{color:var(--fg-muted);font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em}.task-log-filter-note{color:var(--fg-muted);font-size:var(--text-xs);flex:100%;max-width:80ch;margin:0}.run-panel .task-log-list{border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--bg-raised);max-height:62vh;padding:0 var(--sp-2)}.run-page .pill{color:var(--fg)}.run-page .pill-ok:before{background:var(--ok)}.run-page .pill-warn:before{background:var(--warn)}.run-page .pill-danger:before{background:var(--danger)}.run-page .pill-info:before{background:var(--info)}.run-page .pill-idle:before{background:var(--idle)}@media (width<=700px){.run-meta{margin-bottom:var(--sp-3)}.run-restart{align-items:flex-start}.run-attempts{padding-bottom:var(--sp-1);flex-wrap:nowrap;overflow-x:auto}.run-stage{padding-bottom:var(--sp-3);border-bottom:1px solid var(--border);grid-template-columns:1fr}.run-stage:before,.run-stage-node{display:none}.run-capture-head{align-items:flex-start;gap:var(--sp-1);flex-direction:column}}@media (width<=480px){.tab{padding:var(--sp-2)}.run-json{max-height:45vh}}@media (prefers-reduced-motion:reduce){.run-attempt,.tab{transition:none}}.skill-search{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3);width:220px}.skill-search:focus{outline:2px solid var(--accent-soft);outline-offset:1px}.skill-card{flex-direction:column;display:flex}.skill-desc{color:var(--fg-muted);font-size:var(--text-sm);margin:0 0 var(--sp-3);flex:1}.skill-source{font-size:var(--text-xs);color:var(--fg-subtle)}.wf-stage-card{margin-top:var(--sp-4)}.wf-rate{font-size:var(--text-sm);color:var(--fg);align-items:baseline;gap:var(--sp-2);display:flex}.wf-rate-sub{font-size:var(--text-xs);color:var(--fg-subtle)}.wf-bar{border-radius:var(--radius-pill);background:var(--border);height:5px;margin-top:var(--sp-2);width:140px;overflow:hidden}.wf-bar-fill{border-radius:var(--radius-pill);height:100%;transition:width var(--transition)}.wf-bar-ok{background:var(--ok)}.wf-bar-warn{background:var(--warn)}.wf-bar-danger{background:var(--danger)}.wf-bar-info{background:var(--info)}.wf-form{gap:var(--sp-2);flex-direction:column;display:flex}.wf-form input,.wf-form select,.wf-form textarea{font:inherit;font-size:var(--text-sm);color:var(--fg);background:var(--surface);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-2);width:100%}.wf-form textarea{resize:vertical}.wf-form input:focus,.wf-form select:focus,.wf-form textarea:focus{outline:2px solid var(--accent);outline-offset:-1px}.wf-form input::placeholder,.wf-form textarea::placeholder{color:var(--fg-subtle)}.channel-card{gap:var(--sp-1);flex-direction:column;display:flex}.channel-desc{color:var(--fg-muted);font-size:var(--text-sm);margin:0}.channel-detail{color:var(--fg-subtle);font-size:var(--text-xs);margin:0}.curator-card{gap:var(--sp-2);flex-direction:column;display:flex}.curator-health-message{color:var(--fg-muted);font-size:var(--text-sm);margin:0}.curator-meta{color:var(--fg-subtle);font-size:var(--text-xs);margin:0}.curator-actions{gap:var(--sp-2);flex-direction:column;margin:0;padding:0;list-style:none;display:flex}.curator-action{border-top:1px solid var(--border);padding-top:var(--sp-2)}.curator-action-head{justify-content:space-between;gap:var(--sp-2);font-size:var(--text-sm);display:flex}.curator-action-type{color:var(--fg);font-weight:600}.curator-action-time{color:var(--fg-subtle);font-size:var(--text-xs)}.curator-action-detail{color:var(--fg-muted);font-size:var(--text-sm);margin:var(--sp-1) 0 0}.curator-action-reason{color:var(--fg-subtle);font-size:var(--text-xs);margin:var(--sp-1) 0 0}.cfg-page{max-width:70rem;margin:0 auto}.cfg-section{margin-bottom:var(--sp-4)}.cfg-subhead{font-size:var(--text-sm);color:var(--fg-muted);margin:var(--sp-5) 0 var(--sp-2);font-weight:600}.cfg-subhead:first-child{margin-top:0}.kv-list{column-gap:var(--sp-4);grid-template-columns:max-content minmax(0,1fr) auto;row-gap:0;display:grid}.kv{grid-template-columns:subgrid;align-items:center;row-gap:var(--sp-1);padding:var(--sp-2) 0;border-radius:var(--radius-sm);grid-column:1/-1;display:grid}@supports not (grid-template-columns:subgrid){.kv-list{flex-direction:column;width:auto;display:flex}.kv{column-gap:var(--sp-4);grid-template-columns:minmax(8rem,16rem) minmax(0,1fr) auto}}.kv+.kv{border-top:1px solid var(--border)}.kv:hover{background:var(--surface-hover)}.kv-label{font-size:var(--text-sm);color:var(--fg-muted)}.kv-value{min-width:0;font-size:var(--text-sm);color:var(--fg);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.kv-value.is-empty{color:var(--fg-subtle)}.kv-actions{align-items:center;gap:var(--sp-2);justify-self:end;display:flex}.kv-note{font-size:var(--text-xs);color:var(--fg-subtle);grid-column:2/-1}.kv-note.is-error{color:var(--danger)}.kv.is-locked .kv-value{color:var(--fg-muted)}.kv-btn{font:inherit;font-size:var(--text-xs);color:var(--fg-subtle);border:1px solid var(--border);border-radius:var(--radius-sm);padding:2px var(--sp-2);cursor:pointer;background:0 0;flex:none;transition:color .12s,border-color .12s,background .12s}.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)}.kv-btn:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.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(--bg,var(--surface));border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-1) var(--sp-2);width:100%;min-width:0}.kv-input:focus{outline:2px solid var(--accent);outline-offset:-1px}.kv-save,.kv-cancel{font:inherit;font-size:var(--text-xs);border-radius:var(--radius-sm);padding:var(--sp-1) var(--sp-2);cursor:pointer;flex:none}.kv-save{background:var(--accent);border:1px solid var(--accent);color:var(--accent-fg);font-weight:500}.kv-save:disabled{opacity:.6;cursor:default}.kv-cancel{border:1px solid var(--border-strong);color:var(--fg-muted);background:0 0}.kv-cancel:hover{color:var(--fg)}.cfg-notice{border-left:3px solid var(--warn)}.cfg-notice p{font-size:var(--text-sm);color:var(--warn);margin:0}@media (width<=700px){.kv-list{flex-direction:column;width:auto;display:flex}.kv{column-gap:var(--sp-4);grid-template-columns:minmax(0,1fr) auto}.kv-label{grid-column:1}.kv-actions{grid-area:1/2}.kv-value,.kv-note{white-space:normal;overflow-wrap:anywhere;grid-column:1/-1}}.log-filters{gap:var(--sp-2);flex-wrap:wrap;align-items:center;display:flex}.log-status{gap:var(--sp-3);align-items:center;display:flex}.log-meta{font-size:var(--text-xs);color:var(--fg-subtle);font-family:var(--font-mono)}.log-select,.log-search{background:var(--bg-raised);border:1px solid var(--border-strong);color:var(--fg);border-radius:var(--radius-sm);padding:var(--sp-2) var(--sp-3);font:inherit;font-size:var(--text-sm)}.log-search{min-width:220px}.log-select:focus,.log-search:focus{outline:2px solid var(--accent);outline-offset:-1px}.log-list{max-height:62vh;font-family:var(--font-mono);font-size:var(--text-xs);border-top:1px solid var(--border);overflow-y:auto}.log-loading{padding:var(--sp-5);color:var(--fg-muted);text-align:center}.log-row{gap:var(--sp-3);padding:var(--sp-2) var(--sp-1);border-bottom:1px solid var(--border);grid-template-columns:62px 52px 1fr;align-items:baseline;display:grid}.log-row:hover{background:var(--surface-hover)}.log-time{color:var(--fg-subtle)}.log-level{letter-spacing:.04em;font-size:10px;font-weight:600}.log-danger .log-level{color:var(--danger)}.log-warn .log-level{color:var(--warn)}.log-info .log-level{color:var(--info)}.log-idle .log-level{color:var(--idle)}.log-danger .log-msg{color:var(--fg)}.log-body{gap:var(--sp-2);flex-wrap:wrap;align-items:baseline;min-width:0;display:flex}.log-msg{color:var(--fg);word-break:break-word}.log-field{color:var(--fg-muted);background:var(--bg-raised);border-radius:var(--radius-sm);padding:0 var(--sp-2);white-space:nowrap;text-overflow:ellipsis;max-width:100%;overflow:hidden}.log-field-key{color:var(--fg-subtle)}.log-field-key:after{content:"=";opacity:.6}@media (width<=860px){.log-row{grid-template-columns:56px 1fr}.log-level{display:none}.log-search{flex:1;min-width:0}}.capture-row{cursor:pointer}.capture-row:hover{background:var(--bg-raised)}.capture-row:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}.capture-detail-row td{padding:var(--sp-3) var(--sp-3) var(--sp-4);border-bottom:1px solid var(--border)}.capture-detail{gap:var(--sp-4);grid-template-columns:1fr 1fr;display:grid}.capture-detail-section{min-width:0}.capture-detail-title{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--fg-subtle);margin-bottom:var(--sp-2)}.capture-payload{background:var(--bg-raised);border:1px solid var(--border-strong);border-radius:var(--radius-sm);padding:var(--sp-3);font-family:var(--font-mono);font-size:var(--text-xs);white-space:pre-wrap;word-break:break-word;max-height:24rem;overflow:auto}.capture-empty{color:var(--fg-muted);font-size:var(--text-sm)}@media (width<=640px){.capture-detail{grid-template-columns:1fr}}.mapping-form,.mapping-fields,.mapping-payload{margin-bottom:var(--sp-4);padding:var(--sp-4)}.mapping-form-row{gap:var(--sp-1);margin-bottom:var(--sp-3);font-size:var(--text-sm);color:var(--fg-subtle);flex-direction:column;display:flex}.mapping-input,.mapping-select{padding:var(--sp-2);border:1px solid var(--border-strong);border-radius:var(--radius-sm);background:var(--bg-raised);color:var(--fg);font:inherit}.mapping-section-title{font-size:var(--text-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--fg-subtle);margin-bottom:var(--sp-2)}.mapping-fields-table .mapping-input{width:100%}.mapping-empty-fields{color:var(--fg-muted);font-size:var(--text-sm);padding:var(--sp-3) 0}.mapping-error{color:var(--danger,#e5484d);font-size:var(--text-sm);margin-bottom:var(--sp-3)}.mapping-tree-list{padding-left:var(--sp-4);font-family:var(--font-mono);font-size:var(--text-xs);margin:0;list-style:none}.mapping-tree-item{padding:2px 0}.mapping-tree-key,.mapping-tree-value{cursor:pointer;border-radius:var(--radius-sm);padding:0 4px}.mapping-tree-key:hover,.mapping-tree-value:hover{background:var(--bg-raised);outline:1px solid var(--accent)}.mapping-tree-value{color:var(--fg-subtle);margin-left:var(--sp-1)}.binding-form{margin-bottom:var(--sp-4);padding:var(--sp-4)}.binding-form-row{gap:var(--sp-1);margin-bottom:var(--sp-3);font-size:var(--text-sm);color:var(--fg-subtle);flex-direction:column;display:flex}.binding-input,.binding-select{padding:var(--sp-2);border:1px solid var(--border-strong);border-radius:var(--radius-sm);background:var(--bg-raised);color:var(--fg);font:inherit}.binding-error{color:var(--danger,#e5484d);font-size:var(--text-sm);margin-bottom:var(--sp-3)}.chat-panel-content{flex:auto;grid-template-rows:auto auto minmax(0,1fr);min-height:0;display:grid;overflow:hidden}.chat-bar{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-bottom:1px solid var(--border);display:flex}.chat-session-switch{flex:auto;min-width:0}.chat-session-switch select{background:var(--surface-hover);width:100%;color:var(--fg);border:1px solid var(--border);border-radius:var(--radius-sm);padding:var(--sp-2);font:inherit;font-size:var(--text-sm)}.chat-new,.chat-settings>summary{flex:none}.chat-settings{flex:none;position:relative}.chat-settings>summary{border-radius:var(--radius-sm);width:32px;height:32px;color:var(--fg-muted);cursor:pointer;place-items:center;list-style:none;display:grid}.chat-settings>summary::-webkit-details-marker{display:none}.chat-settings>summary:hover{background:var(--surface-hover);color:var(--fg)}.chat-settings-body{top:calc(100% + var(--sp-2));z-index:2;gap:var(--sp-3);width:15rem;padding:var(--sp-3);background:var(--bg-raised);border:1px solid var(--border);border-radius:var(--radius-md);box-shadow:var(--shadow-md);display:grid;position:absolute;right:0}.chat-settings-body label{gap:var(--sp-1);font-size:var(--text-xs);color:var(--fg-muted);display:grid}.chat-settings-body .chat-select{width:100%}.chat-layout{min-height:0;display:grid;overflow:hidden}.chat-workspace{grid-template-rows:auto minmax(0,1fr) auto;min-width:0;display:grid;overflow:hidden}.chat-workspace-head{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-bottom:1px solid var(--border);font-size:var(--text-xs);display:flex}.chat-update-panel{border:1px solid var(--border);color:var(--fg-muted);border-radius:.75rem;flex:none;justify-content:space-between;align-items:center;gap:1rem;margin:0 0 .75rem;padding:.7rem .9rem;font-size:.8rem;display:flex}.chat-update-panel>div:first-child{gap:.2rem;display:grid}.chat-update-panel strong{color:var(--fg)}.chat-update-actions{flex-shrink:0;gap:.45rem;display:flex}.chat-dangerous-panel{border:1px solid color-mix(in srgb, var(--danger) 45%, var(--border));border-radius:.75rem;flex:none;margin:0 0 .75rem;padding:.8rem .9rem}.chat-dangerous-head,.chat-dangerous-controls,.chat-dangerous-pending{justify-content:space-between;align-items:center;gap:.6rem;display:flex}.chat-dangerous-head{margin-bottom:.7rem}.chat-dangerous-controls{flex-wrap:wrap;align-items:stretch}.chat-dangerous-controls>div{flex:18rem;gap:.45rem;display:flex}.chat-dangerous-input{background:var(--surface-hover);min-width:0;color:var(--fg);border:1px solid var(--border-strong);font:inherit;border-radius:.5rem;flex:1;padding:.5rem .65rem}.chat-dangerous-pending-list{gap:.45rem;margin-top:.75rem;display:grid}.chat-dangerous-pending{border-top:1px solid var(--border);color:var(--fg-muted);padding-top:.55rem;font-size:.8rem}.chat-session-list{gap:.35rem;margin-top:1rem;display:grid}.chat-session{text-align:left;color:var(--fg-muted);cursor:pointer;background:0 0;border:1px solid #0000;border-radius:.65rem;gap:.25rem;padding:.7rem;display:grid}.chat-session:hover,.chat-session.active{background:var(--surface-hover);color:var(--fg);border-color:var(--border-strong)}.chat-session span{font-size:.72rem}.chat-session-tools{color:var(--fg-muted);margin-left:.6rem;font-size:.78rem;position:relative}.chat-session-tools summary{cursor:pointer}.chat-session-tool-list{z-index:2;background:var(--surface);border:1px solid var(--border-strong);border-radius:.65rem;flex-wrap:wrap;gap:.35rem;width:min(22rem,72vw);padding:.55rem;display:flex;position:absolute;top:calc(100% + .45rem);right:0;box-shadow:0 .7rem 2rem #0000004d}.chat-select{background:var(--surface-hover);color:var(--fg);border:1px solid var(--border-strong);border-radius:.5rem;padding:.5rem .65rem}.chat-transcript{padding:var(--sp-4);align-content:start;gap:var(--sp-4);display:grid;overflow:auto}.chat-empty-state{width:100%;padding:var(--sp-5) 0;text-align:center;place-self:center}.chat-empty-mark{width:2.2rem;height:2.2rem;margin:0 auto var(--sp-3);border:1px solid var(--border-strong);color:var(--accent);border-radius:.8rem;place-items:center;font-weight:700;display:grid}.chat-empty-state h2{font-size:var(--text-lg);letter-spacing:-.02em;margin:0}.chat-empty-state p{margin:var(--sp-2) 0 var(--sp-4);color:var(--fg-muted);font-size:var(--text-sm)}.chat-prompt-grid{gap:var(--sp-2);display:grid}.chat-prompt{padding:var(--sp-2) var(--sp-3);font-size:var(--text-sm);text-align:left;border:1px solid var(--border);background:var(--surface-hover);color:var(--fg-muted);cursor:pointer;border-radius:999px}.chat-prompt:hover{color:var(--fg);border-color:var(--border-strong)}.chat-bubble-row{display:flex}.chat-bubble-row.user{justify-content:flex-end}.chat-bubble{background:var(--surface-hover);border-radius:.85rem;max-width:min(78ch,86%);padding:.8rem 1rem;line-height:1.5}.chat-bubble-row.user .chat-bubble{background:color-mix(in srgb, var(--accent) 18%, var(--surface))}.chat-bubble-meta{color:var(--fg-muted);margin-bottom:.3rem;font-size:.7rem}.chat-bubble-text{white-space:pre-wrap;overflow-wrap:anywhere}.chat-bubble-text p{margin:0 0 .7rem}.chat-bubble-text p:last-child{margin-bottom:0}.chat-bubble-text h1,.chat-bubble-text h2,.chat-bubble-text h3{letter-spacing:-.02em;margin:.2rem 0 .6rem;line-height:1.2}.chat-bubble-text h1{font-size:1.25rem}.chat-bubble-text h2{font-size:1.1rem}.chat-bubble-text h3{font-size:1rem}.chat-bubble-text ul,.chat-bubble-text ol{margin:.25rem 0 .75rem;padding-left:1.35rem}.chat-bubble-text blockquote{border-left:3px solid var(--accent);color:var(--fg-muted);margin:.5rem 0;padding:.35rem .75rem}.chat-bubble-text code{background:color-mix(in srgb, var(--fg) 10%, transparent);border-radius:.3rem;padding:.1rem .3rem;font-size:.9em}.chat-bubble-text pre{border:1px solid var(--border);background:color-mix(in srgb, var(--surface) 75%, #000);border-radius:.5rem;margin:.6rem 0;padding:.75rem;overflow:auto}.chat-bubble-text pre code{background:0 0;padding:0}.chat-bubble-text a{color:var(--accent)}.chat-media-img{border:1px solid var(--border);object-fit:contain;background:var(--surface);cursor:pointer;border-radius:.5rem;max-width:100%;max-height:24rem;margin:.4rem 0;display:block}.chat-bubble-text table{border-collapse:collapse;width:100%;margin:.7rem 0;font-size:.92em}.chat-bubble-text th,.chat-bubble-text td{text-align:left;border:1px solid var(--border);padding:.45rem .6rem}.chat-bubble-text th{color:var(--fg);background:color-mix(in srgb, var(--surface) 70%, transparent);font-weight:700}.chat-tools{gap:.2rem;margin-bottom:.5rem;font-size:.78rem;display:grid}.chat-tools:empty{display:none}.chat-tool{color:var(--fg-muted);overflow-wrap:anywhere;align-items:baseline;gap:.4rem;display:flex}.chat-tool-name{color:var(--fg);font-weight:600}.chat-tool.failed .chat-tool-summary{color:var(--danger)}.chat-nav-chip{border:1px solid color-mix(in srgb, var(--accent) 45%, var(--border));background:var(--accent-soft);color:var(--accent);cursor:pointer;transition:background var(--transition), border-color var(--transition), color var(--transition);border-radius:999px;align-items:center;gap:.4rem;padding:.4rem .7rem;font-size:.82rem;font-weight:600;display:inline-flex}.chat-nav-chip:hover{border-color:var(--accent);background:color-mix(in srgb, var(--accent) 16%, var(--surface))}.chat-nav-chip:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.chat-nav-chip-icon{font-size:.8rem;line-height:1}.chat-compose{padding:var(--sp-3);border-top:1px solid var(--border)}.chat-composer-shell{align-items:flex-end;gap:var(--sp-2);background:var(--surface-hover);border:1px solid var(--border-strong);border-radius:.9rem;padding:.7rem .8rem;display:flex;position:relative}.chat-composer{resize:none;box-sizing:border-box;min-width:0;min-height:2.6rem;color:var(--fg);font:inherit;background:0 0;border:0;flex:auto;padding:.25rem 0}.chat-composer:focus{outline:0}.chat-command-menu{z-index:3;background:var(--surface);border:1px solid var(--border-strong);border-radius:.7rem;gap:.15rem;max-height:18rem;padding:.35rem;display:grid;position:absolute;bottom:calc(100% - .25rem);left:.8rem;right:.8rem;overflow:auto;box-shadow:0 .7rem 2rem #0000004d}.chat-command-menu[hidden]{display:none}.chat-command-option{text-align:left;color:var(--fg-muted);cursor:pointer;background:0 0;border:1px solid #0000;border-radius:.45rem;grid-template-columns:minmax(8rem,14rem) 1fr;align-items:center;gap:.65rem;padding:.5rem .6rem;display:grid}.chat-command-option:hover,.chat-command-option[aria-selected=true]{color:var(--fg);background:var(--surface-hover);border-color:var(--border)}.chat-command-option code{color:var(--fg)}.chat-compose-actions{align-items:center;gap:var(--sp-2);flex:none;display:flex}.chat-hint,.chat-empty{color:var(--fg-muted);font-size:.78rem}.chat-command-help{color:var(--fg-muted);margin-right:auto;font-size:.78rem}.chat-command-help summary{cursor:pointer}.chat-command-list{min-width:min(34rem,70vw);max-width:40rem;padding-top:.4rem;line-height:1.45}.chat-command-item{grid-template-columns:minmax(10rem,16rem) 1fr;gap:.7rem;padding:.3rem 0;display:grid}.chat-command-item code{color:var(--fg)}@media (width<=520px){.chat-update-panel{flex-direction:column;align-items:flex-start}} diff --git a/ui/dist/assets/index.js b/ui/dist/assets/index.js index 75a6ceb4f..13228774c 100644 --- a/ui/dist/assets/index.js +++ b/ui/dist/assets/index.js @@ -1,10 +1,10 @@ -(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(e.__,e.__i+1):null;for(var n;tt&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=O.__r=0}}function k(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y=r&&r.__k||h,b=t.length;for(c=A(n,t,y,c,b),d=0;d0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=M(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:ic?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a+!!u){for(i=n-1,a=n+1;i>=0||a=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function N(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function P(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||N(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||N(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function F(e){return function(n){if(this.l){var r=this.l[n.type+e];if(n[c]==null)n[c]=d++;else if(n[c]0?e:_(e)?e.map(z):e.constructor===void 0?v({},e):null}function ee(n,r,i,a,o,s,c,l,u){var d,f,p,h,g,v,b,x=i.props||m,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d=n.__.length&&n.__.push({}),n.__[e]}function W(e){return oe=1,he(we,e)}function he(e,t,n){var r=me(B++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):we(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=V,!V.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};V.__f=!0;var a=V.shouldComponentUpdate,o=V.componentWillUpdate;V.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},V.shouldComponentUpdate=i}return r.__N||r.__}function G(e,t){var n=me(B++,3);!U.__s&&Ce(n.__H,t)&&(n.__=e,n.u=t,V.__H.__h.push(n))}function K(e){return oe=5,ge(function(){return{current:e}},[])}function ge(e,t){var n=me(B++,7);return Ce(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function _e(e,t){return oe=8,ge(function(){return e},t)}function ve(){for(var e;e=se.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(xe),t.__h.some(Se),t.__h=[]}catch(n){t.__h=[],U.__e(n,e.__v)}}}U.__b=function(e){V=null,ce&&ce(e)},U.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),pe&&pe(e,t)},U.__r=function(e){le&&le(e),B=0;var t=(V=e.__c).__H;t&&(ae===V?(t.__h=[],V.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(xe),t.__h.some(Se),t.__h=[],B=0)),ae=V},U.diffed=function(e){ue&&ue(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(se.push(t)!==1&&H===U.requestAnimationFrame||((H=U.requestAnimationFrame)||be)(ve)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),ae=V=null},U.__c=function(e,t){t.some(function(e){try{e.__h.some(xe),e.__h=e.__h.filter(function(e){return!e.__||Se(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],U.__e(n,e.__v)}}),de&&de(e,t)},U.unmount=function(e){fe&&fe(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{xe(e)}catch(e){t=e}}),n.__H=void 0,t&&U.__e(t,n.__v))};var ye=typeof requestAnimationFrame==`function`;function be(e){var t,n=function(){clearTimeout(r),ye&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ye&&(t=requestAnimationFrame(n))}function xe(e){var t=V,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),V=t}function Se(e){var t=V;e.__c=e.__(),V=t}function Ce(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function we(e,t){return typeof t==`function`?t(e):t}function Te(e=globalThis.crypto){if(typeof e?.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues==`function`)e.getRandomValues(t);else for(let e=0;ee.toString(16).padStart(2,`0`));return`${n.slice(0,4).join(``)}-${n.slice(4,6).join(``)}-${n.slice(6,8).join(``)}-${n.slice(8,10).join(``)}-${n.slice(10).join(``)}`}var Ee=15e3;function De(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e||{}))r!==``&&r!=null&&t.set(n,r);let n=t.toString();return n?`?${n}`:``}async function Oe(e){try{let t=(await e.text()).trim();if(t)return t.split(` -`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var ke=class extends Error{constructor(e,t){super(e),this.status=t}};function Ae(e){let t=e instanceof ke?e.status:void 0,n=e?.message||`Action failed`;return t===401?{kind:`session-expired`,message:n}:t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function je(e,t){let n=await fetch(e,t);if(!n.ok)throw new ke(await Oe(n),n.status);return n}async function q(e,{method:t=`GET`,body:n,timeoutMs:r=Ee,parse:i=!0}={}){let a={Accept:`application/json`},o={method:t,headers:a,signal:AbortSignal.timeout(r)};t!==`GET`&&(a[`Content-Type`]=`application/json`,a[`X-Archie-CSRF`]=`1`),n!==void 0&&(o.body=JSON.stringify(n));let s=await je(e,o);return i?s.json():void 0}var J={summary:()=>q(`/api/summary`),tasks:()=>q(`/api/tasks`),taskMeta:()=>q(`/api/task-meta`),task:e=>q(`/api/tasks/${e}`),taskAttempts:e=>q(`/api/tasks/${e}/attempts`),taskChanges:(e,t)=>q(`/api/tasks/${e}/changes`+De(t)),taskDebug:(e,t)=>q(`/api/tasks/${e}/debug`+De(t)),taskAction:(e,t)=>q(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>q(`/api/setup`),capabilities:()=>q(`/api/capabilities`),workflows:()=>q(`/api/workflows`),workRequest:e=>q(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>q(`/api/skills`),channels:()=>q(`/api/channels`),curators:()=>q(`/api/curators`),channelReload:e=>q(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>q(`/api/config`),version:()=>q(`/api/version`),configUpdate:e=>q(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>q(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>q(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>q(`/api/logs`+De(e)),taskLogs:(e,t)=>q(`/api/tasks/${e}/logs`+De(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>q(`/api/captures`+De({limit:e})),mappings:()=>q(`/api/mappings`),mappingCreate:e=>q(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>q(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>q(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>q(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>q(`/api/bindings`),bindingCreate:e=>q(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>q(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>q(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>q(`/api/bindings/${e}/approve`,{method:`POST`}),chatSessions:()=>q(`/api/chat/sessions`),chatMessages:e=>q(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>q(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>q(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>q(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:Te(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>q(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>q(`/api/chat/update`),chatUpdateDefer:e=>q(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>q(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>q(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>q(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>q(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>je(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t})};function Me(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Ne(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Pe(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var Fe=[{id:`queued`,label:`Queued`,kind:`idle`},{id:`running`,label:`Working`,kind:`info`},{id:`waiting_human`,label:`Waiting for you`,kind:`warn`,needs_you:!0},{id:`pr_open`,label:`In review`,kind:`ok`},{id:`merged`,label:`Merged`,kind:`ok`},{id:`parked`,label:`Parked`,kind:`warn`,needs_you:!0},{id:`dead`,label:`Stopped (too many retries)`,kind:`danger`},{id:`rejected`,label:`Rejected`,kind:`danger`},{id:`closed_wont_do`,label:`Won't do`,kind:`idle`}],Ie=[{id:`cancel`,label:`Cancel`,kind:`quiet`,confirm:`Cancel "{title}"? This closes the forge issue.`},{id:`stop`,label:`Stop`,kind:`primary`,confirm:`Stop "{title}"? Recoverable work will remain parked.`},{id:`approve`,label:`Approve`,kind:`primary`},{id:`reject`,label:`Reject`,kind:`quiet`,confirm:`Reject "{title}"? This closes the forge issue.`},{id:`retry`,label:`Retry`,kind:`primary`},{id:`abandon`,label:`Abandon`,kind:`quiet`,confirm:`Abandon "{title}"? This closes the forge issue.`},{id:`archive`,label:`Archive`,kind:`quiet`,confirm:`Archive the local record for "{title}"?`},{id:`open_pr`,label:`Open PR`,kind:`link`},{id:`open_issue`,label:`Open issue`,kind:`link`}],Le=[...Fe],Re=[...Ie],ze=new Map(Le.map(e=>[e.id,e])),Be=new Map(Re.map(e=>[e.id,e]));function Ve(){ze=new Map(Le.map(e=>[e.id,e])),Be=new Map(Re.map(e=>[e.id,e]))}async function He(){try{let e=await J.taskMeta();Array.isArray(e?.statuses)&&(Le=e.statuses),Array.isArray(e?.actions)&&(Re=e.actions),Ve()}catch{}}function Ue(e){return ze.get(e)?.label||e||`Unknown`}function We(e){return ze.get(e)?.kind||`idle`}function Ge(){return Le.map(e=>e.id)}function Ke(){return new Set(Le.filter(e=>e.needs_you).map(e=>e.id))}function qe(e){return Be.get(e)||null}var Je=0;Array.isArray;function Y(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:--Je,__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}var Ye={dashboard:``,chat:``,tasks:``,logs:``,skills:``,workflows:``,memory:``,channels:``,curators:``,captures:``,mappings:``,bindings:``,settings:``,search:``,moon:``,sun:``,refresh:``,bell:``,trendUp:``,trendDown:``,check:``,close:``,help:``};function X({name:e,size:t=18,className:n=``}){return Y(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,"stroke-width":`1.6`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,className:`ico ${n}`.trim(),dangerouslySetInnerHTML:{__html:Ye[e]||Ye.dashboard}})}function Z(e){if(!e)return`—`;let t=e instanceof Date?e:new Date(e),n=Math.floor((Date.now()-t.getTime())/1e3);if(!Number.isFinite(n))return`—`;if(n<45)return`just now`;let r=[[`min`,60],[`hr`,3600],[`day`,86400],[`wk`,604800]],i=`min`,a=60;for(let[e,t]of r)n>=t&&([i,a]=[e,t]);let o=Math.floor(n/a);return`${o} ${i}${o===1?``:`s`} ago`}function Xe(e){return e==null||Number.isNaN(e)?`—`:new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e)}function Ze({label:e,value:t,unit:n,trend:r,compare:i,series:a=[],goodDirection:o=`up`}){let s=r==null?null:r>=0?`up`:`down`,c=s==null?null:s===o;return Y(`div`,{className:`card stat`,children:[Y(`div`,{className:`stat-head`,children:[Y(`span`,{className:`stat-label`,children:e}),s?Y(`span`,{className:`stat-trend ${c?`up`:`down`}`,children:[Y(X,{name:s===`up`?`trendUp`:`trendDown`,size:13}),`${Math.abs(r).toFixed(1)}%`]}):null]}),Y(`div`,{className:`stat-value`,children:[t,n?Y(`span`,{className:`stat-unit`,children:n}):null]}),i?Y(`div`,{className:`stat-compare`,children:i}):null,a.length>1?Y(Qe,{series:a,stroke:c===!1?`var(--danger)`:`var(--ok)`}):null]})}function Qe({series:e,stroke:t=`var(--ok)`,width:n=220,height:r=34}){let i=Math.max(...e,1),a=Math.min(...e,0),o=i-a||1,s=e.length>1?n/(e.length-1):n,c=e.map((e,t)=>`${(t*s).toFixed(1)},${(r-(e-a)/o*r).toFixed(1)}`).join(` `);return Y(`svg`,{className:`spark`,viewBox:`0 0 ${n} ${r}`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:Y(`polyline`,{points:c,fill:`none`,stroke:t,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"vector-effect":`non-scaling-stroke`})})}function $e({value:e,label:t,size:n=168}){let r=Math.max(0,Math.min(100,Number(e)||0)),i=r>=90?`var(--ok)`:r>=70?`var(--warn)`:`var(--danger)`,a=n/2,o=n/2,s=2*Math.PI*62*(240/360),c=(e,t)=>{let n=e*Math.PI/180,r=(e+t)*Math.PI/180,i=+(t>180);return[`M ${a+62*Math.cos(n)} ${o+62*Math.sin(n)}`,`A 62 62 0 ${i} 1 ${a+62*Math.cos(r)} ${o+62*Math.sin(r)}`].join(` `)};return Y(`div`,{className:`gauge-wrap`,children:[Y(`svg`,{className:`gauge`,viewBox:`0 0 ${n} ${n*.78}`,role:`img`,"aria-label":`${t}: ${r}%`,children:[Y(`path`,{d:c(150,240),fill:`none`,stroke:`var(--border)`,"stroke-width":`12`,"stroke-linecap":`round`}),Y(`path`,{d:c(150,240),fill:`none`,stroke:i,"stroke-width":`12`,"stroke-linecap":`round`,"stroke-dasharray":s,"stroke-dashoffset":s*(1-r/100),className:`gauge-value`})]}),Y(`div`,{className:`gauge-center`,children:[Y(`div`,{className:`gauge-pct`,children:`${Math.round(r)}%`}),Y(`div`,{className:`gauge-label`,children:t})]})]})}function et({segments:e}){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return Y(`div`,{children:[Y(`div`,{className:`segbar`,children:e.filter(e=>e.value>0).map(e=>Y(`span`,{className:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`},e.label))}),Y(`div`,{className:`segbar-legend`,children:e.map(e=>Y(`span`,{className:`segbar-key`,children:[Y(`span`,{className:`segbar-dot segbar-${e.kind||`idle`}`}),e.label]},e.label))})]})}var tt=160;function nt(e){let t=String(e?.detail||e?.message||``);if(!t)return{text:``,full:``,truncated:!1};let n=t.split(` -`).map(e=>e.trim()).find(Boolean)||``,r=n.length>tt?`${n.slice(0,tt).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}function Q({text:e,kind:t=`idle`}){return Y(`span`,{className:`pill pill-${t}`,children:e})}var rt=`archie.setup-complete.dismissed.v1`;function it(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(rt),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function at(e=globalThis.localStorage){e?.setItem?.(rt,`1`)}var ot=new Set([`waiting_human`,`parked`]);function st(e=[]){let t=e.filter(e=>ot.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}function ct({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function lt(e,t){return Number(e.task_id)>0?Number(e.task_id):!e.repo||!e.issue?0:Number(t.get(`${e.repo}#${e.issue}`))||0}function ut(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function dt(e){if(e.length<4)return null;let t=Math.floor(e.length/2),n=e.slice(0,t).reduce((e,t)=>e+t,0),r=e.slice(t).reduce((e,t)=>e+t,0);return n?(r-n)/n*100:null}function ft(){let[e,t]=W([]),[n,r]=W(`connecting`),[i,a]=W(`idle`),[o,s]=W(new Map),[c,l]=W(null),[u,d]=W(null),[f,p]=W(null),[m,h]=W(null),[g,_]=W(null),[,v]=W(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([J.summary(),J.setup().catch(()=>null),J.workflows().catch(()=>null),J.tasks().catch(()=>[])]),i=new Map;for(let e of r)e.owner&&e.repo&&e.issue_number&&i.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);s(i),l(e),d(t),p(n),h(r)}catch(e){_(String(e.message||e))}};G(()=>(y(),Me(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{at(),v(e=>!e)},x=u?.operator?`${ut()}, ${u.operator}`:ut(),C=null;if(g)C=Y(`button`,{className:`btn btn-primary`,onClick:y,children:[Y(X,{name:`refresh`,size:15}),` Retry`]});else if(m!==null){let e=st(m),t=e.attention.count,n=e.running.count;C=Y(S,{children:[t>0&&Y(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[Y(X,{name:`tasks`,size:15}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&Y(`a`,{className:`btn`,href:e.running.href,children:[Y(X,{name:`workflows`,size:15}),` `,n,` running`]}),Y(`a`,{className:`btn`,href:`#/logs`,children:[Y(X,{name:`logs`,size:15}),` Logs`]}),Y(`button`,{className:`btn btn-primary`,onClick:y,children:[Y(X,{name:`refresh`,size:15}),` Refresh`]})]})}let w=null;if(g)w=Y(`div`,{className:`card`,children:Y(ct,{title:`Cannot reach archied`,detail:g})});else if(c){let e=c?.statuses||{},t=(e.merged||0)+(e.pr_open||0),n=(e.parked||0)+(e.waiting_human||0),r=Object.values(e).reduce((e,t)=>e+t,0),i=c?.tokens_by_day||[];w=Y(S,{children:[Y(Ze,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),Y(Ze,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),Y(Ze,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),Y(Ze,{label:`Tokens used`,value:Xe(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:dt(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let T=null,E=it(u),D=E.kind===`omit`||E.kind===`dismissed`;if(!D){let e=E.remaining;if(e.length){let t=Math.round((u.steps.length-e.length)/u.steps.length*100);T=Y(`div`,{className:`card setup`,children:[Y(`div`,{className:`card-head`,children:[Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:`Finish setting up`}),Y(`p`,{className:`card-sub`,children:`Archie needs these before it can work on its own.`})]}),Y(`span`,{className:`setup-pct`,children:[t,`%`]})]}),Y(`div`,{className:`setup-bar`,children:Y(`div`,{className:`setup-bar-fill`,style:{width:`${t}%`}})}),Y(`ul`,{className:`setup-list`,children:u.steps.map((e,t)=>Y(`li`,{className:`setup-step ${e.done?`done`:``}`,children:[Y(`span`,{className:`setup-check`,children:e.done?Y(X,{name:`check`,size:12}):``}),Y(`div`,{children:[Y(`div`,{className:`setup-step-title`,children:e.title}),e.detail&&Y(`div`,{className:`setup-step-detail`,children:e.detail})]})]},t))})]})}else T=Y(`div`,{className:`card setup setup-done`,children:Y(`div`,{className:`card-head`,children:[Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:`Setup complete`}),Y(`p`,{className:`card-sub`,children:`Archie is configured and ready to work.`})]}),Y(`div`,{className:`setup-complete-actions`,children:[Y(`span`,{className:`setup-pct`,children:Y(X,{name:`check`,size:16})}),Y(`button`,{className:`icon-btn setup-dismiss`,type:`button`,title:`Dismiss setup complete`,"aria-label":`Dismiss setup complete`,onClick:b,children:`×`})]})]})})}let O=null;if(c){let e=f?.workflows||[],t=e.reduce((e,t)=>e+(t.runs||0),0),n=e.reduce((e,t)=>e+(t.merged||0)+(t.pr_open||0),0),r=e.reduce((e,t)=>e+(t.parked||0),0);if(!t)O=Y(`div`,{className:`card`,children:[Y(`div`,{className:`card-head`,children:Y(`h2`,{className:`card-title`,children:`Gate pulse`})}),Y(ct,{title:`No completed runs yet`,detail:`Once Archie finishes a task, its gate pass rate appears here.`})]});else{let i=n/t*100;O=Y(`div`,{className:`card`,children:[Y(`div`,{className:`card-head`,children:Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:`Gate pulse`}),Y(`p`,{className:`card-sub`,children:`Work that passed its quality gates`})]})}),Y($e,{value:i,label:`pass rate`}),Y(`ul`,{className:`pulse-list`,children:[e.slice(0,3).map((e,t)=>Y(`li`,{className:`pulse-item`,children:[Y(`span`,{className:`pulse-name`,children:e.workflow||`workflow`}),Y(Q,{text:`${e.merged||0}/${e.runs||0}`,kind:(e.merged||0)===(e.runs||0)?`ok`:(e.parked||0)>0?`warn`:`info`})]},t)),r>0&&Y(`li`,{className:`pulse-item`,children:[Y(`span`,{className:`pulse-name`,children:`Parked, awaiting you`}),Y(Q,{text:String(r),kind:`warn`})]})]})]})}}let k=null;if(c){let e=c?.tokens_by_day||[],t=e.reduce((e,t)=>e+(t.tokens||0),0);if(!e.length)k=Y(`div`,{className:`card`,children:[Y(`div`,{className:`card-head`,children:Y(`h2`,{className:`card-title`,children:`Token outlook`})}),Y(ct,{title:`Nothing spent yet`,detail:`Usage appears here once Archie runs its first task.`})]});else{let n=t/e.length,r=Math.round(n*30),i=e.slice(-7).reduce((e,t)=>e+(t.tokens||0),0);k=Y(`div`,{className:`card`,children:[Y(`div`,{className:`card-head`,children:Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:`Token outlook`}),Y(`p`,{className:`card-sub`,children:`Next 30 days at the current rate`})]})}),Y(`div`,{className:`forecast-value`,children:Xe(r)}),Y(`div`,{className:`forecast-note`,children:[`Based on `,Xe(Math.round(n)),` per day over `,e.length,` days`]}),Y(et,{segments:[{label:`Last 7 days (${Xe(i)})`,value:i,kind:`info`},{label:`Earlier (${Xe(t-i)})`,value:Math.max(t-i,0),kind:`idle`}]})]})}}return Y(S,{children:[Y(`div`,{className:`hero`,children:[Y(`div`,{children:[Y(`h1`,{className:`hero-title`,children:x}),Y(`p`,{className:`hero-sub`,children:`Your agent's control room — what it is working on, what needs you, and what it is spending.`})]}),Y(`div`,{className:`hero-actions`,children:Y(`div`,{className:`hero-actions-inner`,children:C})})]}),Y(`div`,{className:`dash-section`,children:[Y(`div`,{className:`dash-section-head`,children:Y(`h2`,{className:`dash-section-title`,children:`Health`})}),Y(`div`,{className:`dash-top ${D?`dash-top-standalone`:``}`,children:[Y(`div`,{children:T}),Y(`div`,{children:O})]})]}),Y(`div`,{className:`dash-section`,children:[Y(`div`,{className:`dash-section-head`,children:[Y(`h2`,{className:`dash-section-title`,children:`Throughput`}),Y(`span`,{className:`dash-section-note`,children:`Across all repositories`})]}),Y(`div`,{className:`grid grid-4`,children:w})]}),Y(`div`,{className:`dash-section`,children:[Y(`div`,{className:`dash-section-head`,children:Y(`h2`,{className:`dash-section-title`,children:`Right now`})}),Y(`div`,{className:`dash-split`,children:[Y(`div`,{children:k}),Y(`div`,{className:`card`,children:[Y(`div`,{className:`card-head`,children:[Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:`Live activity`}),Y(`p`,{className:`card-sub`,children:`Last 50, newest first`})]}),Y(Q,{text:n,kind:i})]}),Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Event`}),Y(`th`,{children:`Task`}),Y(`th`,{children:`Detail`}),Y(`th`,{children:`When`})]})}),Y(`tbody`,{children:e.length?e.map((e,t)=>{let n=lt(e,o),r=n>0,i=nt(e),a=()=>{r&&(location.hash=`#/tasks?task=${encodeURIComponent(n)}`)};return Y(`tr`,{className:r?`activity-row`:``,role:r?`link`:void 0,tabIndex:r?`0`:void 0,title:r?`Open task details`:void 0,onClick:r?a:void 0,onKeyDown:r?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())}:void 0,children:[Y(`td`,{className:`strong`,children:Y(`span`,{children:e.kind||e.type||`event`})}),Y(`td`,{className:`mono`,children:r?`#${n}`:`—`}),Y(`td`,{className:`activity-detail`,children:Y(`span`,{title:i.truncated?i.full:void 0,children:i.text})}),Y(`td`,{children:Z(e.at||Date.now())})]},t)}):Y(`tr`,{children:Y(`td`,{colSpan:`4`,children:Y(ct,{title:`Waiting for activity`,detail:`Events appear here as Archie works.`})})})})]})})]})]})]})]})}function pt(){return Y(ft,{})}function mt(e,t){let n=e.title||`untitled task`;return{"aria-expanded":String(t),"aria-controls":`task-timeline-${e.id}`,"aria-label":`${t?`Collapse`:`Expand`} timeline for ${n}`}}function ht(){return new Set([`needs_you`,...Ge()])}function gt(e){let t=e?.get?.(`status`)||``;return ht().has(t)?t:``}function _t(e,t){return t?t===`needs_you`?Ke().has(e.status):e.status===t:!0}function vt(e){return String(e||`event`).replaceAll(`_`,` `).replace(/\b\w/g,e=>e.toUpperCase())}function yt(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return``;if(t<1e3)return`${Math.round(t)} ms`;let n=t/1e3;if(n<60)return`${n.toFixed(+(n<10))} s`;let r=Math.round(n),i=Math.floor(r/60),a=r%60;if(i<60)return a===0?`${i} min`:`${i} min ${a} s`;let o=Math.floor(i/60),s=i-o*60;return s===0?`${o} h`:`${o} h ${s} min`}function bt(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:t.toLocaleString(`en-US`)}function xt(e={}){let t=e.data||{},n=e.stage||`unknown stage`,r=e.workflow?`${e.workflow} workflow`:``;if(e.kind===`stage_start`)return{title:`Started stage: ${n}`,detail:r};if(e.kind===`stage_finish`){let e=yt(t.duration_ms),i=[r,e&&`ran for ${e}`].filter(Boolean).join(` · `);return{title:t.interrupted?`Stage interrupted: ${n}`:t.error?`Stage failed: ${n}`:`Finished stage: ${n}`,detail:[i,t.error].filter(Boolean).join(` — `)}}if(e.kind===`task_retried`){let n=Number(t.retry_count);return{title:Number.isFinite(n)&&n>0?`Retry ${n}`:`Retry requested`,detail:[t.previous_stage&&`after ${t.previous_stage}`,t.previous_reason].filter(Boolean).join(`: `)||e.detail||``}}if(e.kind===`agent_finish`){let r=bt(t.iterations),i=bt(t.tokens),a=Number(t.cached_tokens)||0,o=bt((Number(t.prompt_tokens)||0)-a),s=bt(t.completion_tokens),c=bt(t.cached_tokens),l=[r&&`${r} iterations`,i&&`${i} tokens`,o&&`${o} fresh prompt`,s&&`${s} completion`,c&&`${c} cached`,t.model].filter(Boolean);return{title:`Agent ${t.status||`finished`}: ${n}`,detail:l.join(` · `)||e.detail||``}}if(e.kind===`config_captured`)return{title:`Configuration captured`,detail:`The effective task-runtime configuration for this run.`};if(e.kind===`changes_captured`){let e=Number(t.totals?.files);return{title:`Change capture recorded`,detail:[Number.isFinite(e)&&e>0?`${e} file${e===1?``:`s`} changed`:``,t.captured_after?`captured after ${t.captured_after}`:``].filter(Boolean).join(` · `)}}return{title:vt(e.kind||e.type),detail:e.detail||``}}var St=[{value:``,label:`All levels`},{value:`ERROR`,label:`Errors`},{value:`WARN,ERROR`,label:`Warnings and errors`},{value:`INFO,WARN,ERROR`,label:`Info and above`},{value:`DEBUG`,label:`Debug only`}];function Ct(e){switch((e||``).toUpperCase()){case`ERROR`:return`danger`;case`WARN`:return`warn`;case`DEBUG`:return`idle`;default:return`info`}}function wt({entry:e}){let t=e.fields||{};return Y(`div`,{className:`log-row log-${Ct(e.level)}`,children:[Y(`span`,{className:`log-time mono`,children:Et(e.time)}),Y(`span`,{className:`log-level`,children:(e.level||`info`).toUpperCase()}),Y(`span`,{className:`log-body`,children:[Y(`span`,{className:`log-msg`,children:e.message||e.msg||``}),Object.entries(t).map(([e,t])=>Y(`span`,{className:`log-field`,children:[Y(`span`,{className:`log-field-key`,children:e}),String(Tt(t))]},e))]})]})}function Tt(e){return e==null?``:typeof e==`object`?JSON.stringify(e):e}function Et(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`--:--:--`:t.toTimeString().slice(0,8)}function Dt(e,t){return`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`)}var Ot={level:``,stage:``};function kt(e,t,n=Ot){let r=n||Ot;return[e,Number(t)||0,r.level||``,r.stage||``].join(`|`)}function At({filters:e,onFilterChange:t,stages:n,attempt:r}){let i=n=>t?.({...e,...n}),a=Number(r)||0;return Y(`div`,{className:`log-filters task-log-filters`,children:[Y(`span`,{className:`task-log-attempt`,children:a>0?`Attempt ${a}`:`Current attempt`}),t?Y(S,{children:[Y(`label`,{className:`task-log-filter`,children:[Y(`span`,{className:`task-log-filter-label`,children:`Level`}),Y(`select`,{className:`task-filter`,value:e.level,"aria-label":`Filter log entries by level`,onChange:e=>i({level:e.target.value}),children:St.map(e=>Y(`option`,{value:e.value,children:e.label},e.value))})]}),Y(`label`,{className:`task-log-filter`,children:[Y(`span`,{className:`task-log-filter-label`,children:`Stage`}),Y(`select`,{className:`task-filter`,value:e.stage,"aria-label":`Filter log entries by stage`,onChange:e=>i({stage:e.target.value}),children:[Y(`option`,{value:``,children:`All stages`}),(n||[]).map(e=>Y(`option`,{value:e,children:e},e))]})]}),e.stage?Y(`p`,{className:`task-log-filter-note`,children:`A stage filter matches only log lines that record a stage. Agent and tool output carries none, so it is not shown while this filter is set.`}):null,!e.stage&&!(n||[]).length?Y(`p`,{className:`task-log-filter-note`,children:`This attempt recorded no stage names, so the stage filter has nothing to match.`}):null]}):null]})}function jt({text:e}){return Y(`p`,{className:`visually-hidden`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:e})}function Mt({state:e,onRetry:t,taskId:n,attempt:r,filters:i=Ot,onFilterChange:a,stages:o=[]}){let s=Number(r)||Number(e?.attempt)||0,c,l;if(e===void 0)c=`Loading this attempt's log`,l=Y(`div`,{className:`task-log-loading`,children:`Loading attempt log…`});else if(e===null)c=`This attempt's log could not be loaded`,l=Y(`div`,{className:`task-log-error`,children:[Y(`div`,{className:`task-timeline-detail`,children:`Could not load this attempt's log.`}),Y(`button`,{className:`btn`,onClick:t,children:`Retry`})]});else if(e.found===!1&&!e.disabled)c=`No log recorded for this attempt`,l=Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:`No log recorded for this attempt`}),Y(`div`,{children:`This attempt produced no output, or it has not started writing yet.`})]});else if(e.disabled)c=`This dashboard cannot read task logs`,l=Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:`No persisted log for this attempt`}),Y(`div`,{children:`This dashboard cannot read task logs. The service that owns the log files is not reporting a log reader.`})]});else{let t=e.entries||[],r=n==null?null:Dt(n,s||null),i=r?Y(`a`,{className:`btn btn-small task-log-download`,href:r,download:!0,children:`Download log`}):null;t.length?(c=`${t.length} log entr${t.length===1?`y`:`ies`} shown`,l=Y(S,{children:[Y(`div`,{className:`log-list task-log-list`,children:t.map((e,t)=>Y(wt,{entry:e},t))}),i]})):(c=`This attempt's log has no entries matching the current filter`,l=Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:`Nothing recorded`}),Y(`div`,{children:`This attempt's log file has no entries matching the current filter.`}),i]}))}return Y(S,{children:[Y(At,{filters:i,onFilterChange:a,stages:o,attempt:s}),Y(jt,{text:c}),l]})}function Nt(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0}function Pt(){return Nt()?`auto`:`smooth`}function Ft({kind:e,message:t}){return e===`session-expired`?Y(`span`,{className:`task-action-error task-action-error-session`,children:[`Your session has expired.`,` `,Y(`button`,{className:`button btn btn-small`,type:`button`,onClick:()=>window.location.reload(),children:`Reload to sign in`})]}):e===`refused`?Y(`span`,{className:`task-action-error task-action-error-refused`,children:[t,` — you can't do that.`]}):Y(`span`,{className:`task-action-error task-action-error-broken`,children:[t,` — try again, or check the daemon.`]})}function It({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function Lt({taskId:e,attempt:t,state:n,onLoad:r,onRetry:i}){let a=K(r);return a.current=r,G(()=>{n===void 0&&a.current()},[n]),Y(Mt,{state:n,taskId:e,attempt:t,onRetry:i})}function Rt({query:e}){let[t,n]=W(null),[r,i]=W(null),[a,o]=W(()=>gt(e)),[s,c]=W(``),l=Number(e.get(`task`)),u=Number.isFinite(l)&&l>0?l:null,[d,f]=W(u),[p,m]=W(u!==null),[h,g]=W(new Map),[_,v]=W(new Map),y=K(new Set),[b,x]=W(new Set),[C,w]=W(new Map),[T,E]=W(new Set),D=async()=>{try{i(null);let e=await J.tasks();return n(e),d&&e.some(e=>String(e.id)===String(d))&&(h.has(d)||O(d)),e}catch(e){return i(String(e.message||e)),n(null),null}};G(()=>{D()},[]);let O=async e=>{try{let t=await J.task(e);g(n=>new Map(n).set(e,t||[]))}catch{g(t=>new Map(t).set(e,null))}},k=async(e,t,{force:n=!1}={})=>{let r=kt(e,t);if(!(y.current.has(r)&&!n)){y.current.add(r),n&&v(e=>{let t=new Map(e);return t.delete(r),t});try{let n=await J.taskLogs(e,{attempt:t||void 0,limit:500});v(e=>new Map(e).set(r,n))}catch{v(e=>new Map(e).set(r,null))}}},A=e=>{g(t=>{let n=new Map(t);return n.delete(e),n})},j=async(e,t)=>{w(t=>{let n=new Map(t);return n.delete(e),n}),E(t=>new Set(t).add(e));try{await J.taskAction(e,t),E(t=>{let n=new Set(t);return n.delete(e),n}),t===`archive`&&f(null),A(e);let n=await D();Array.isArray(n)&&n.find(t=>String(t.id)===String(e))&&d===e&&O(e)}catch(t){E(t=>{let n=new Set(t);return n.delete(e),n}),w(n=>new Map(n).set(e,Ae(t)))}};G(()=>{p&&d&&t&&(m(!1),requestAnimationFrame(()=>{let e=document.getElementById(`task-row-${d}`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView?.({block:`center`,behavior:Pt()}))}))},[p,d,t]);let M=(e,t)=>{t&&t.stopPropagation();let n=d!==e;f(n?e:null),n&&O(e)},N=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},P=()=>{if(!t)return null;let e=t.length,n={};for(let e of t)n[e.status]=(n[e.status]||0)+1;let r=n.running||0,i=(n.waiting_human||0)+(n.parked||0),a=(n.merged||0)+(n.pr_open||0);return Y(`div`,{className:`grid grid-4 task-summary`,children:[Y(Ze,{label:`Total tasks`,value:e,compare:e?`Everything archied has ever picked up`:`No tasks yet`}),Y(Ze,{label:`Working now`,value:r,compare:e?`${r} of ${e} in progress`:`Nothing running`}),Y(Ze,{label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),Y(Ze,{label:`Delivered`,value:a,compare:e?`${Math.round(a/e*100)}% of all tasks`:`No tasks yet`})]})},F=e=>{let t=C.get(e.id),n=t?Ft(t):null,r=T.has(e.id),i=e=>e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``,a=(e.actions||[]).map(t=>{let n=qe(t);if(!n)return null;let a=e.title||`this task`,o=n.confirm?n.confirm.replaceAll(`{title}`,a):void 0,s=[`button`,`btn`,`btn-small`,i(n.kind)].filter(Boolean).join(` `);if(n.kind===`link`){if(t===`open_pr`)return I(e,`pull_request`,e.pr_number,n.label);if(t===`open_issue`)return I(e,`issue`,e.issue_number,n.label)}return Y(`button`,{className:s,type:`button`,disabled:r,onClick:n=>{n.stopPropagation(),!(o&&!window.confirm(o))&&j(e.id,t)},children:n.label},t)}).filter(Boolean);return!a.length&&!n?`—`:Y(`div`,{className:`task-actions`,children:[n,a]})},I=(e,t,n,r)=>{let i=t===`issue`?e.issue_url:e.pr_url;return!i||!n||t===`issue`&&e.source===`chat`?Y(`button`,{className:`btn btn-small`,type:`button`,disabled:!0,title:`${r} is unavailable`,children:r}):Y(`a`,{className:`btn btn-small`,href:i,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:r})},L=e=>{let t=e.repo_url;return t?Y(`a`,{className:`task-source-link`,href:t,target:`_blank`,rel:`noreferrer`,title:`Open ${e.owner}/${e.repo} on the forge`,onClick:e=>e.stopPropagation(),children:[e.owner,`/`,e.repo]}):null},R=e=>{let t=e.issue_url;return e.source===`chat`||!t||!e.issue_number?null:Y(`a`,{className:`task-source-link`,href:t,target:`_blank`,rel:`noreferrer`,title:`Open issue #${e.issue_number} on the forge`,onClick:e=>e.stopPropagation(),children:[`#`,e.issue_number]})},z=e=>{let t=kt(e.id,e.attempt),n=h.get(e.id),r=b.has(e.id);return Y(`tr`,{className:`task-timeline-row`,id:`task-timeline-${e.id}`,children:Y(`td`,{colSpan:8,children:[Y(`div`,{className:`task-detail-actions`,children:[Y(`div`,{className:`task-decision-title`,children:`Available actions`}),F(e)]}),e.status===`waiting_human`&&e.plan&&Y(`div`,{className:`task-decision`,children:[Y(`div`,{className:`task-decision-title`,children:`Decision required`}),Y(`div`,{className:`task-decision-plan`,children:e.plan})]}),e.status===`parked`&&e.park_reason&&Y(`div`,{className:`task-decision`,children:[Y(`div`,{className:`task-decision-title`,children:`Park reason`}),Y(`div`,{className:`task-decision-plan`,children:e.park_reason})]}),n===void 0?Y(`div`,{className:`task-timeline-loading`,children:`Loading timeline…`}):n===null?Y(`div`,{className:`task-timeline-error`,children:[Y(`div`,{className:`task-timeline-title`,children:`Could not load timeline`}),Y(`div`,{className:`task-timeline-detail`,children:`archied did not answer for this task's events. It may be restarting — retry, or check the daemon.`}),Y(`button`,{className:`btn`,onClick:()=>O(e.id),children:`Retry`})]}):n.length?Y(`ul`,{className:`task-timeline`,children:n.map((e,t)=>{let n=xt(e);return Y(`li`,{className:`task-timeline-entry`,children:[Y(`span`,{className:`task-timeline-dot`}),Y(`div`,{children:[Y(`div`,{className:`task-timeline-kind`,children:n.title}),n.detail&&Y(`div`,{className:`task-timeline-detail`,children:n.detail}),Y(`div`,{className:`task-timeline-when`,children:Z(e.at)})]})]},t)})}):Y(It,{title:`No events yet`,detail:`This task has not recorded any transitions.`}),Y(`div`,{className:`task-logs-section`,children:[Y(`div`,{className:`task-decision-title`,children:[`Attempt log`,Y(`button`,{className:`btn btn-small`,onClick:()=>N(e.id),style:{marginLeft:`10px`},children:r?`Hide`:`Show`})]}),r&&Y(Lt,{taskId:e.id,attempt:e.attempt,state:_.has(t)?_.get(t):void 0,onLoad:()=>k(e.id,e.attempt),onRetry:()=>k(e.id,e.attempt,{force:!0})})]})]})})};return Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Tasks`}),Y(`p`,{className:`page-sub`,children:`Every issue archied has picked up, and where it stands.`})]}),Y(`div`,{className:`page-actions`,children:Y(`button`,{className:`btn`,onClick:D,children:`Refresh`})})]}),r?Y(`div`,{className:`grid grid-4 task-summary`,children:Y(`div`,{className:`card`,children:Y(It,{title:`Cannot reach archied`,detail:r})})}):P(),Y(`div`,{className:`card`,children:[Y(`div`,{className:`card-head`,children:[Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:`All tasks`}),Y(`p`,{className:`card-sub`,children:`Click a row for its timeline`})]}),Y(`div`,{className:`task-filters`,children:[Y(`input`,{className:`task-search`,type:`search`,placeholder:`Search by title or repo…`,value:s,onInput:e=>c(e.target.value.trim().toLowerCase())}),Y(`select`,{className:`task-filter`,value:a,onChange:e=>o(e.target.value),children:[Y(`option`,{value:``,children:`All statuses`}),Y(`option`,{value:`needs_you`,children:`Needs you`}),Ge().map(e=>Y(`option`,{value:e,children:Ue(e)},e))]})]})]}),Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[`Repo`,`Issue`,`Title`,`Status`,`Workflow`,`Stage`,`Last activity`,`Action`].map(e=>Y(`th`,{children:e},e))})}),Y(`tbody`,{children:(()=>{if(r)return Y(`tr`,{children:Y(`td`,{colSpan:8,children:Y(It,{title:`Cannot reach archied`,detail:r})})});if(!t)return Y(`tr`,{children:Y(`td`,{colSpan:8,children:Y(`div`,{className:`task-timeline-loading`,children:`Loading tasks...`})})});if(!t.length)return Y(`tr`,{children:Y(`td`,{colSpan:8,children:Y(It,{title:`No tasks yet`,detail:`Tasks appear here once archied picks up an issue to work.`})})});let e=t.filter(e=>_t(e,a)?!s||`${e.title} ${e.repo}`.toLowerCase().includes(s):!1);return e.length?e.map(e=>{let t=d===e.id,n=`task-timeline-${e.id}`;return Y(S,{children:[Y(`tr`,{className:`task-row`,id:`task-row-${e.id}`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),M(e.id,t))},onClick:t=>M(e.id,t),...mt(e,t),children:[Y(`td`,{className:`mono`,"data-label":`Repository`,children:[Y(`button`,{className:`task-expand`,type:`button`,"aria-expanded":String(t),"aria-controls":n,"aria-label":`${t?`Collapse`:`Expand`} timeline for ${e.title||`untitled task`}`,onClick:t=>M(e.id,t),children:t?`−`:`+`}),L(e)??`${e.owner}/${e.repo}`]}),Y(`td`,{className:`mono`,"data-label":`Issue`,children:R(e)??`#${e.issue_number}`}),Y(`td`,{className:`strong`,"data-label":`Title`,children:Y(`a`,{className:`task-detail-link`,href:`#/tasks/${e.id}`,title:`Open the run detail for this task`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:e.title||`(untitled)`})}),Y(`td`,{"data-label":`Status`,children:Y(Q,{text:Ue(e.status),kind:We(e.status)})}),Y(`td`,{"data-label":`Workflow`,children:e.workflow||`—`}),Y(`td`,{"data-label":`Stage`,children:e.stage||`—`}),Y(`td`,{"data-label":`Last activity`,title:e.created_at?`Created ${Z(e.created_at)}`:``,children:Z(e.updated_at)}),Y(`td`,{"data-label":`Actions`,children:F(e)})]}),t&&z(e)]},e.id)}):Y(`tr`,{children:Y(`td`,{colSpan:8,children:Y(It,{title:`No matching tasks`,detail:`Try a different search or status filter.`})})})})()})]})})]})]})}function zt(e){return Y(Rt,{query:e})}function Bt(e,t){return`${e}-tab-${t}`}function Vt(e,t){return`${e}-panel-${t}`}function Ht({tabs:e,active:t,onSelect:n,prefix:r=`run`,label:i=`Run detail views`}){let a=K([]),o=t=>{let r=e[t];r&&(n?.(r.id),a.current[t]?.focus?.())};return Y(`div`,{className:`tab-bar`,role:`tablist`,"aria-label":i,onKeyDown:n=>{let r=e.findIndex(e=>e.id===t);if(r<0)return;let i;if(n.key===`ArrowRight`)i=(r+1)%e.length;else if(n.key===`ArrowLeft`)i=(r-1+e.length)%e.length;else if(n.key===`Home`)i=0;else if(n.key===`End`)i=e.length-1;else return;n.preventDefault(),o(i)},children:e.map((e,i)=>{let o=e.id===t;return Y(`button`,{ref:e=>{a.current[i]=e},id:Bt(r,e.id),className:`tab${o?` is-selected`:``}`,type:`button`,role:`tab`,"aria-selected":o,"aria-controls":Vt(r,e.id),tabIndex:o?0:-1,onClick:()=>n?.(e.id),children:e.label},e.id)})})}var Ut={ok:{label:`ok`,kind:`ok`},failed:{label:`failed`,kind:`danger`},interrupted:{label:`interrupted`,kind:`warn`},running:{label:`running`,kind:`info`},unknown:{label:`unknown`,kind:`idle`}};function Wt(e){return Ut[e]||{label:e||`unknown`,kind:`idle`}}function Gt(e,t,n){return(e||[]).filter(e=>e&&e.kind===`agent_finish`&&Number(e.attempt)===Number(t)&&(e.stage||``)===(n||``)).map(e=>xt(e))}function Kt(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`start time not recorded`:`started ${t.toISOString().replace(`T`,` `).slice(0,16)} UTC`}function qt({stage:e,attemptNumber:t,events:n}){let r=Wt(e.status),i=yt(e.duration_ms),a=Gt(n,t,e.name);return Y(`li`,{className:`run-stage`,"data-status":e.status||`unknown`,children:[Y(`span`,{className:`run-stage-node`,"aria-hidden":`true`}),Y(`div`,{className:`run-stage-body`,children:[Y(`div`,{className:`run-stage-head`,children:[Y(`span`,{className:`run-stage-name mono`,children:e.name||`(unnamed stage)`}),Y(Q,{text:r.label,kind:r.kind}),Y(`span`,{className:`run-stage-duration`,children:i?`ran for ${i}`:`duration not recorded`})]}),e.error?Y(`div`,{className:`run-stage-error`,children:e.error}):null,a.map((e,t)=>Y(`div`,{className:`run-agent-report`,children:[Y(`span`,{className:`run-agent-report-label`,children:`Agent's own report, not verified by archie: `}),[e.title,e.detail].filter(Boolean).join(` · `)]},t))]})]})}function Jt({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function Yt({count:e}){let t=Number(e)||0;return t?Y(`p`,{className:`run-rail-note`,children:[t,` event`,t===1?``:`s`,` on this task predate attempt attribution and cannot be assigned to a run.`]}):null}function Xt({state:e,attemptNumber:t,events:n,onRetry:r}){if(e===void 0)return Y(`div`,{className:`run-loading`,children:`Loading this task's attempts…`});if(e===null)return Y(`div`,{className:`run-error`,children:[Y(`div`,{className:`run-error-title`,children:`Could not load this task's attempts`}),Y(`div`,{className:`run-error-detail`,children:`archied did not answer for this task's run history. It may be restarting — retry, or check the daemon.`}),r?Y(`button`,{className:`btn`,type:`button`,onClick:r,children:`Retry`}):null]});let i=e?.attempts||[];if(!i.length)return Y(S,{children:[Y(Jt,{title:`No attempts recorded`,detail:`This task has no recorded run. An attempt is written when a stage event is emitted, and none exist here.`}),Y(Yt,{count:e?.unattributed_events})]});let a=i.find(e=>Number(e.attempt)===Number(t));if(!a)return Y(S,{children:[Y(Jt,{title:`Attempt ${t} is not recorded for this task`,detail:`This task recorded attempt ${i.map(e=>e.attempt).join(`, `)}.`}),Y(Yt,{count:e?.unattributed_events})]});let o=a.stages||[],s=Wt(a.status);return Y(`div`,{className:`run-rail`,children:[Y(`div`,{className:`run-rail-head`,children:[Y(`span`,{className:`run-rail-attempt`,children:[`Attempt `,a.attempt]}),Y(Q,{text:s.label,kind:s.kind}),Y(`span`,{className:`run-rail-when`,children:Kt(a.started_at)})]}),o.length?Y(`ol`,{className:`run-stages`,"aria-label":`Stages recorded in attempt ${a.attempt}`,children:o.map((e,t)=>Y(qt,{stage:e,attemptNumber:a.attempt,events:n},`${e.seq??t}:${e.name}`))}):Y(Jt,{title:`No stages recorded for this attempt`,detail:`The attempt exists, but nothing recorded a stage for it.`}),Y(`p`,{className:`run-rail-legend`,children:[Y(`strong`,{children:`ok`}),` means the stage returned without error. Archie records no exit code and does not verify that the work was correct, so this is a progress status, not a check result.`]}),Y(Yt,{count:e?.unattributed_events})]})}var Zt={added:`Added`,modified:`Modified`,deleted:`Deleted`,renamed:`Renamed`,typechange:`Type changed`};function Qt(e){return Zt[e]||e||`unknown`}function $t(e,t){let n=e?.repo_url||t?.repo_url||``,r=t&&String(t.pr_number??``)!==``&&String(t.pr_number)===String(e?.pr_number??``);return{repo:n,pr:e?.pr_url||r&&t.pr_url||``}}function en(e={}){let t=Number(e.files)||0,n=[`${t} file${t===1?``:`s`}`];return e.additions&&n.push(`+${e.additions}`),e.deletions&&n.push(`−${e.deletions}`),n.join(` · `)}function tn({capture:e}){let t=e.files||[],n=Number(e.totals?.files)||t.length;return t.length?Y(S,{children:[Y(`table`,{className:`table run-changes-table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Path`}),Y(`th`,{children:`Change`}),Y(`th`,{className:`run-changes-count`,children:`Added`}),Y(`th`,{className:`run-changes-count`,children:`Deleted`})]})}),Y(`tbody`,{children:t.map((e,t)=>Y(`tr`,{children:[Y(`td`,{className:`mono run-changes-path`,children:[e.old_path?Y(`span`,{className:`run-changes-old`,children:[e.old_path,` → `]}):null,e.path]}),Y(`td`,{children:[Qt(e.status),e.binary?Y(`span`,{className:`run-changes-hint`,children:`no textual hunks`}):null]}),Y(`td`,{className:`run-changes-count mono`,children:e.additions?`+${e.additions}`:`—`}),Y(`td`,{className:`run-changes-count mono`,children:e.deletions?`−${e.deletions}`:`—`})]},`${e.path}:${t}`))})]}),e.truncated?Y(`p`,{className:`run-changes-note`,children:[`Showing the first `,t.length,` of `,n,` files. The totals above cover every file in this capture.`]}):null]}):Y(`div`,{className:`run-changes-empty`,children:[`This capture recorded no file entries`,n?`, though its totals cover ${n} file${n===1?``:`s`}`:``,`.`]})}function nn({capture:e,task:t}){let n=$t(e,t),r=e.pr_number;return Y(`section`,{className:`run-capture`,children:[Y(`div`,{className:`run-capture-head`,children:[Y(`span`,{className:`run-capture-when`,children:[e.captured_after?`Captured after ${e.captured_after}`:`Captured`,e.stage?` in stage ${e.stage}`:``]}),Y(`span`,{className:`run-capture-at`,children:e.captured_at?Z(e.captured_at):``})]}),Y(`div`,{className:`run-capture-meta`,children:[Y(`span`,{className:`mono`,children:n.repo?Y(`a`,{className:`run-capture-link`,href:n.repo,target:`_blank`,rel:`noreferrer`,children:[e.owner,`/`,e.repo]}):`${e.owner||``}/${e.repo||``}`}),e.branch?Y(`span`,{className:`mono run-capture-branch`,children:[e.branch,e.base?` → ${e.base}`:``]}):null,e.head_sha?Y(`span`,{className:`mono run-capture-sha`,children:String(e.head_sha).slice(0,8)}):null,r?n.pr?Y(`a`,{className:`run-capture-link`,href:n.pr,target:`_blank`,rel:`noreferrer`,children:[`PR #`,r]}):Y(`span`,{className:`mono`,children:[`PR #`,r]}):null,Y(`span`,{className:`run-capture-totals`,children:en(e.totals)})]}),Y(tn,{capture:e})]})}function rn({state:e,task:t,onRetry:n}){if(e===void 0)return Y(`div`,{className:`run-loading`,children:`Loading changed files…`});if(e===null)return Y(`div`,{className:`run-error`,children:[Y(`div`,{className:`run-error-title`,children:`Could not load this attempt's changed files`}),Y(`div`,{className:`run-error-detail`,children:`archied did not answer for this attempt. It may be restarting — retry, or check the daemon.`}),n?Y(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]});let r=e.captures||[];return e.found===!0&&!r.length?Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:`A change capture was recorded but could not be read`}),Y(`div`,{children:`This attempt has a change capture event, but this dashboard could not decode its payload. That is a read failure, not a statement about what the attempt changed.`})]}):!e.found||!r.length?Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:`No change capture was recorded for this attempt`}),Y(`div`,{children:`Archie records what an attempt changed when it commits or pushes that work. Nothing was recorded here — the attempt may predate capture, or it produced no commit. This is not the same as "no files changed".`})]}):Y(`div`,{className:`run-changes`,children:r.map((e,n)=>Y(nn,{capture:e,task:t},`${e.captured_at||``}:${n}`))})}function an(e,t){return(e||[]).find(e=>e&&e.kind===`config_captured`&&Number(e.attempt)===Number(t))||null}function on({events:e,attempt:t,onRetry:n}){if(e===void 0)return Y(`div`,{className:`run-loading`,children:`Loading this task's events…`});if(e===null)return Y(`div`,{className:`run-error`,children:[Y(`div`,{className:`run-error-title`,children:`Could not load this task's events`}),Y(`div`,{className:`run-error-detail`,children:`The configuration is recorded as an event on the task, so it cannot be shown while the event stream is unreadable. archied did not answer — retry, or check the daemon.`}),n?Y(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]});let r=an(e,t);if(!r)return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:`Not captured for this run`}),Y(`div`,{children:[`Archie records the effective configuration when it dispatches an attempt. Attempt `,t,` `,`has no such record — it predates the record, or the capture did not run. Nothing here says the run used the defaults.`]})]});let i=r.data||{},a=i.schema||``,o=i.document;return Y(`div`,{className:`run-config`,children:[Y(`p`,{className:`run-config-scope`,children:[`This is attempt `,r.attempt,`'s effective task-runtime configuration: a non-secret subset covering bot identity, models, limits, budgets, dispatch, diff cap, notifications, forge host and tool policy. It is not the dashboard configuration view — providers, repositories, identities, credentials and lock state are not part of it.`]}),Y(`div`,{className:`run-config-when`,children:[`Captured `,r.at||`at an unrecorded time`,r.stage?` in stage ${r.stage}`:``]}),a===`archie/task-config@1`?Y(`pre`,{className:`run-json`,children:JSON.stringify(o??{},null,2)}):Y(S,{children:[Y(`div`,{className:`run-config-unknown`,children:[`Recorded in an unknown schema`,a?` (${a})`:``,`. The raw payload is shown verbatim; nothing here reinterprets it.`]}),Y(`pre`,{className:`run-json`,children:JSON.stringify(i,null,2)})]})]})}function sn({state:e,attempt:t,onRetry:n}){return e===void 0?Y(`div`,{className:`run-loading`,children:`Loading the stored record…`}):e===null?Y(`div`,{className:`run-error`,children:[Y(`div`,{className:`run-error-title`,children:`Could not load the stored record`}),Y(`div`,{className:`run-error-detail`,children:`archied did not answer for this task's debug view. It may be restarting — retry, or check the daemon.`}),n?Y(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]}):Y(`div`,{className:`run-debug`,children:[Y(`p`,{className:`run-debug-note`,children:[`The stored task record and its events, verbatim. Events are unfiltered on purpose: this is every event the task has, and each one carries the attempt it belongs to. Attempt `,t,` `,`is the one selected above.`]}),Y(`pre`,{className:`run-json`,children:JSON.stringify(e,null,2)})]})}var cn=[{id:`stages`,label:`Stages`},{id:`log`,label:`Log`},{id:`changes`,label:`Changed files`},{id:`config`,label:`Configuration`},{id:`debug`,label:`Debug`}],ln=`run`,un=new Set(cn.map(e=>e.id));function dn(e){let t=String(e??``).trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return Number.isSafeInteger(n)&&n>0?n:null}function fn(e){let t=e?.get?.(`tab`)||``;return un.has(t)?t:cn[0].id}function pn(e){let t=e?.get?.(`attempt`);if(t==null||t===``)return null;let n=Number(t);return Number.isInteger(n)&&n>0?n:null}function mn(e,t,n){let r=new URLSearchParams;return r.set(`tab`,t||cn[0].id),n&&r.set(`attempt`,String(n)),`#/tasks/${e}?${r.toString()}`}function hn(e,t,n){try{window.history.replaceState(null,``,`${location.pathname}${location.search}${mn(e,t,n)}`)}catch{}}function gn(e,t){return`${e}|${Number(t)||0}`}function _n({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function vn({id:e}){return Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Task not found`}),Y(`p`,{className:`page-sub`,children:[`No task with id `,e,` in this deployment.`]})]}),Y(`div`,{className:`page-actions`,children:Y(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`})})]}),Y(`div`,{className:`card`,children:Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:[`Nothing is recorded for task `,e]}),Y(`div`,{children:`archied answered that this task does not exist, so there is no run history to show.`})]})})]})}function yn({raw:e}){return Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Not a task id`}),Y(`p`,{className:`page-sub`,children:`The run view addresses one task by its id: #/tasks/42`})]}),Y(`div`,{className:`page-actions`,children:Y(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`})})]}),Y(`div`,{className:`card`,children:Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:[`“`,e,`” is not a task id`]}),Y(`div`,{children:`A task id is a positive whole number. Nothing was requested.`})]})})]})}function bn({attempts:e,selected:t,onSelect:n}){let r=e?.attempts||[];return r.length?Y(`div`,{className:`run-attempts`,role:`group`,"aria-label":`Attempts of this task`,children:r.map(e=>{let r=Wt(e.status),i=Number(e.attempt)===Number(t);return Y(`button`,{type:`button`,className:`run-attempt${i?` is-selected`:``}`,"aria-pressed":i,onClick:()=>n(e.attempt),children:[Y(`span`,{className:`run-attempt-id`,children:[`Attempt `,e.attempt]}),Y(Q,{text:r.label,kind:r.kind}),Y(`span`,{className:`run-attempt-meta`,children:[(e.stages||[]).length,` stage`,(e.stages||[]).length===1?``:`s`]})]},e.attempt)})}):null}function xn({id:e,query:t}){let[n,r]=W(()=>fn(t)),[i,a]=W(()=>pn(t)),[o,s]=W(void 0),[c,l]=W(void 0),[u,d]=W(!1),[f,p]=W(void 0),[m,h]=W(Ot),[g,_]=W(new Map),[v,y]=W(new Map),[b,x]=W(new Map),[S,C]=W(!1),[w,T]=W(null),[E,D]=W(0),O=K(new Set),k=Array.isArray(o)&&o.find(t=>String(t.id)===String(e))||null,A=Number(c?.current_attempt)>0?Number(c.current_attempt):null,j=i??A,M=(c?.attempts||[]).find(e=>Number(e.attempt)===Number(j)),N=[...new Set((M?.stages||[]).map(e=>e.name).filter(Boolean))],P=(e,t,n,{force:r=!1}={})=>{O.current.has(e)&&!r||(O.current.add(e),n(t=>new Map(t).set(e,void 0)),t().then(t=>n(n=>new Map(n).set(e,t))).catch(()=>n(t=>new Map(t).set(e,null))))},F=()=>{s(void 0),J.tasks().then(e=>s(e)).catch(()=>s(null))},I=()=>{l(void 0),d(!1),J.taskAttempts(e).then(e=>l(e)).catch(e=>{e?.status===404&&d(!0),l(null)})},L=()=>{p(void 0),J.task(e).then(e=>p(e||[])).catch(()=>p(null))},R=(t,n)=>P(kt(e,t,m),()=>J.taskLogs(e,{attempt:t||void 0,level:m.level,stage:m.stage,limit:500}),_,n),z=(t,n)=>P(gn(e,t),()=>J.taskChanges(e,{attempt:t}),y,n),ee=(t,n)=>P(gn(e,t),()=>J.taskDebug(e,{attempt:t}),x,n),te=()=>{O.current=new Set,_(new Map),y(new Map),x(new Map),F(),I(),L(),D(e=>e+1)};G(()=>{F(),I(),L()},[]),G(()=>{j!=null&&(n===`log`?R(j):n===`changes`?z(j):n===`debug`&&ee(j))},[n,j,m,E]),G(()=>{hn(e,n,j)},[e,n,j]);let ne=async()=>{let t=k?.title||`task ${e}`;if(window.confirm(`Start a new run for "${t}"? This is a new attempt, and the previous attempt's commits are discarded.`)){T(null),C(!0);try{await J.taskAction(e,`retry`),O.current=new Set,_(new Map),y(new Map),x(new Map),a(null),F(),I(),L(),D(e=>e+1)}catch(e){T(Ae(e))}finally{C(!1)}}};if(u)return Y(vn,{id:e});let re=j==null?null:kt(e,j,m),ie=gn(e,j),B=gn(e,j),V=()=>{if(n===`stages`)return Y(Xt,{state:c,attemptNumber:j,events:f,onRetry:I});if(c===void 0)return Y(`div`,{className:`run-loading`,children:`Loading this task's attempts…`});if(c===null)return Y(`div`,{className:`run-error`,children:[Y(`div`,{className:`run-error-title`,children:`Could not load this task's attempts`}),Y(`div`,{className:`run-error-detail`,children:`This panel reads one attempt, and the task's run history could not be read.`}),Y(`button`,{className:`btn`,type:`button`,onClick:I,children:`Retry`})]});if(j==null)return Y(_n,{title:`No attempt recorded`,detail:`This task has no recorded run, so there is nothing to read for an attempt.`});switch(n){case`log`:return Y(Mt,{state:re&&g.has(re)?g.get(re):void 0,attempt:j,stages:N,filters:m,onFilterChange:h,taskId:e,onRetry:()=>R(j,{force:!0})});case`changes`:return Y(rn,{state:v.has(ie)?v.get(ie):void 0,task:k,onRetry:()=>z(j,{force:!0})});case`config`:return Y(on,{events:f,attempt:j,onRetry:L});case`debug`:return Y(sn,{state:b.has(B)?b.get(B):void 0,attempt:j,onRetry:()=>ee(j,{force:!0})});default:return Y(Xt,{state:c,attemptNumber:j,events:f,onRetry:I})}},ae=qe(`retry`),H=!!(ae&&(k?.actions||[]).includes(`retry`));return Y(`div`,{className:`run-page`,children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:k?.title||`Task #${e}`}),Y(`p`,{className:`page-sub`,children:[`One run of task `,e,k?.workflow?` · ${k.workflow} workflow`:``,k?.repo?` · ${k.owner}/${k.repo}`:``]})]}),Y(`div`,{className:`page-actions`,children:[Y(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`}),Y(`button`,{className:`btn`,type:`button`,onClick:te,children:`Refresh`})]})]}),Y(`div`,{className:`run-meta`,children:[Y(`span`,{className:`run-meta-item`,children:[Y(`span`,{className:`run-meta-label`,children:`Task status`}),o===void 0?Y(`span`,{className:`run-meta-muted`,children:`loading…`}):k?Y(Q,{text:Ue(k.status),kind:We(k.status)}):Y(`span`,{className:`run-meta-muted`,children:`not read`})]}),Y(`span`,{className:`run-meta-item`,children:[Y(`span`,{className:`run-meta-label`,children:`Attempt`}),Y(`span`,{className:`run-meta-value`,children:c===null?`run history unreadable`:c===void 0?`loading…`:j==null?`none recorded`:`attempt ${j} of ${A??j}`})]}),k?.repo_url?Y(`a`,{className:`run-meta-link`,href:k.repo_url,target:`_blank`,rel:`noreferrer`,children:[k.owner,`/`,k.repo]}):null,k?.issue_url&&k.issue_number?Y(`a`,{className:`run-meta-link`,href:k.issue_url,target:`_blank`,rel:`noreferrer`,children:[`Issue #`,k.issue_number]}):null,k?.pr_url&&k.pr_number?Y(`a`,{className:`run-meta-link`,href:k.pr_url,target:`_blank`,rel:`noreferrer`,children:[`PR #`,k.pr_number]}):null]}),o===null?Y(`p`,{className:`run-note`,children:`The task list could not be read, so this page cannot show the task's current status or its operator controls. The run history below comes from the task's own endpoints.`}):null,Array.isArray(o)&&!k?Y(`p`,{className:`run-note`,children:[`Task `,e,` is not among the tasks this dashboard lists (the list covers the 100 most recently updated). Its recorded attempts are shown below; the Debug tab holds the stored record verbatim.`]}):null,Y(`section`,{className:`run-restart`,"aria-label":`Start a new run`,children:[Y(`button`,{className:`btn ${ae?.kind===`primary`?`btn-primary`:``}`,type:`button`,disabled:!H||S,title:`Retry this task as a new run`,onClick:ne,children:S?`Starting…`:`Start a new run`}),Y(`p`,{className:`run-restart-copy`,children:`Starts a new attempt for this task: a fresh worktree reset onto the base branch. The previous attempt's commits are discarded — they are not carried into the new run.`}),!H&&o!==void 0?Y(`p`,{className:`run-restart-unavailable`,children:k?`A new run can only start from a parked task. This task is ${Ue(k.status)}.`:`This task's operator controls could not be read, so a new run cannot be started from here.`}):null,w?Y(`p`,{className:`run-restart-error run-restart-error-${w.kind}`,children:w.kind===`session-expired`?`Your session has expired. Reload to sign in.`:w.kind===`refused`?`${w.message} — this run cannot be restarted from here.`:`${w.message} — try again, or check the daemon.`}):null]}),Y(bn,{attempts:c,selected:j,onSelect:e=>a(e)}),Y(`div`,{className:`card run-card`,children:[Y(Ht,{tabs:cn,active:n,onSelect:r,prefix:ln}),Y(`div`,{className:`run-panel`,role:`tabpanel`,id:Vt(ln,n),"aria-labelledby":Bt(ln,n),tabIndex:0,children:V()})]})]})}function Sn(e,t){let n=t?.id,r=dn(n);return r===null?Y(yn,{raw:n??``}):Y(xn,{id:r,query:e},r)}function Cn({title:e,detail:t}){return Y(`div`,{class:`empty`,children:[Y(`div`,{class:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function wn(e){return Y(Tn,{query:e})}function Tn(){let[e,t]=W([]),[n,r]=W(``),[i,a]=W(null),o=async()=>{try{let e=await J.skills();t(e?.skills||[]),a(null)}catch(e){t([]),a(String(e.message||e))}};G(()=>{o()},[]);let s=(e,t)=>!t||`${e.name} ${e.description}`.toLowerCase().includes(t),c=ge(()=>e.filter(e=>s(e,n)),[e,n]);return Y(`div`,{children:[Y(`div`,{class:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{class:`page-title`,children:`Skills`}),Y(`p`,{class:`page-sub`,children:`What Archie can do, in plain language.`})]}),Y(`div`,{class:`page-actions`,children:Y(`button`,{class:`btn`,onClick:o,children:`Refresh`})})]}),Y(`div`,{class:`card`,children:[Y(`div`,{class:`card-head`,children:[Y(`div`,{children:[Y(`h2`,{class:`card-title`,children:`Catalogue`}),Y(`p`,{class:`card-sub`,children:`Project, shared, and user-global skills`})]}),Y(`input`,{class:`skill-search`,type:`search`,placeholder:`Search skills…`,onInput:e=>r(e.target.value.trim().toLowerCase())})]}),Y(`div`,{class:`grid grid-2`,children:i?Y(Cn,{title:`Cannot reach archied`,detail:i}):e.length?c.length?c.map(e=>Y(`div`,{class:`card skill-card`,children:[Y(`div`,{class:`card-head`,children:[Y(`h3`,{class:`card-title`,children:e.name||`Untitled skill`}),e.workflow&&Y(Q,{text:e.workflow,kind:`info`})]}),Y(`p`,{class:`skill-desc`,children:e.description||`No description provided.`}),Y(`div`,{class:`skill-source`,children:e.source||`Unknown source`})]},e.name)):Y(Cn,{title:`No skills match`,detail:`Nothing found for "${n}".`}):Y(Cn,{title:`No skills discovered yet`,detail:`Skills live as SKILL.md files under project, shared, or user-global .agents/skills// directories. Add one and refresh to make it available.`})})]})]})}var En={bootstrap:`Bootstrap`,implement:`Implement`,tdd:`TDD`,feasibility:`Feasibility check`};function Dn(e){return En[e]?En[e]:e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown`}function On(e,t){return t?Math.round(e/t*100):0}function kn(e){if(!e)return`—`;if(e<1e3)return`${e} ms`;let t=e/1e3;return t<60?`${t.toFixed(1)} s`:`${(t/60).toFixed(1)} min`}function An({title:e,detail:t}){return Y(`div`,{class:`empty`,children:[Y(`div`,{class:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function jn({fraction:e,kind:t=`ok`}){let n=Math.min(100,Math.max(0,e));return Y(`div`,{class:`wf-bar`,children:Y(`div`,{class:`wf-bar-fill wf-bar-${t}`,style:{width:`${n}%`}})})}function Mn(e){return Y(Nn,{query:e})}function Nn(){let[e,t]=W([]),[n,r]=W([]),[i,a]=W([]),[o,s]=W(null),c=async()=>{try{let e=await J.workflows();t(e?.definitions||[]),r(e?.workflows||[]),a(e?.stages||[]),s(null)}catch(e){s(String(e.message||e))}};return G(()=>{c()},[]),Y(`div`,{children:[Y(`div`,{class:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{class:`page-title`,children:`Workflows`}),Y(`p`,{class:`page-sub`,children:`Run outcomes and spend per workflow, and where stages get stuck.`})]}),Y(`div`,{class:`page-actions`,children:Y(`button`,{class:`btn`,onClick:c,children:`Refresh`})})]}),Y(Pn,{definitions:e}),o?Y(`div`,{class:`card`,children:Y(An,{title:`Cannot reach archied`,detail:o})}):Y(S,{children:[Y(Fn,{workflows:n,definitions:e}),Y(In,{stages:i})]})]})}function Pn({definitions:e}){if(!e.length)return null;let t=e.filter(e=>e.enabled)[0]?.id||``,[n,r]=W(``),[i,a]=W(``),[o,s]=W(t),[c,l]=W(``),[u,d]=W(``),[f,p]=W(!1),[m,h]=W(``);return G(()=>{!o&&t&&s(t)},[t,o]),Y(`div`,{class:`card`,children:[Y(`div`,{class:`card-head`,children:Y(`div`,{children:[Y(`h2`,{class:`card-title`,children:`Start work`}),Y(`p`,{class:`card-sub`,children:`This enters Archie’s normal admitted task queue.`})]})}),Y(`form`,{class:`wf-form`,onSubmit:async e=>{e.preventDefault(),p(!0),h(``);try{let e=await J.workRequest({identity:n,repository:i,workflow:o,title:c,instructions:u});h(`Queued task #${e.task_id}.`),r(``),a(``),s(t),l(``),d(``)}catch(e){h(String(e.message||e))}finally{p(!1)}},children:[Y(`input`,{placeholder:`Identity`,required:!0,value:n,onInput:e=>r(e.target.value)}),Y(`input`,{placeholder:`owner/repository`,required:!0,value:i,onInput:e=>a(e.target.value)}),Y(`select`,{required:!0,value:o,onInput:e=>s(e.target.value),children:e.filter(e=>e.enabled).map(e=>Y(`option`,{value:e.id,children:Dn(e.name||e.id)},e.id))}),Y(`input`,{placeholder:`Short task title`,required:!0,value:c,onInput:e=>l(e.target.value)}),Y(`textarea`,{placeholder:`Instructions for the work`,required:!0,rows:3,value:u,onInput:e=>d(e.target.value)}),Y(`button`,{class:`btn`,type:`submit`,disabled:f,children:`Start work`}),m&&Y(`p`,{class:`card-sub`,children:m})]})]})}function Fn({workflows:e,definitions:t}){let n=new Map(e.map(e=>[e.workflow,e])),r=t.map(e=>({...e,...n.get(e.id)||{workflow:e.id,runs:0,merged:0}}));return r.length?Y(`div`,{class:`card`,children:[Y(`div`,{class:`card-head`,children:Y(`div`,{children:[Y(`h2`,{class:`card-title`,children:`Per workflow`}),Y(`p`,{class:`card-sub`,children:`Success rate is merged tasks over all runs`})]})}),Y(`div`,{class:`table-scroll`,children:Y(`table`,{class:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Workflow`}),Y(`th`,{children:`Origin`}),Y(`th`,{children:`Runs`}),Y(`th`,{children:`Success rate`}),Y(`th`,{children:`Avg tokens`}),Y(`th`,{children:`Avg steps`})]})}),Y(`tbody`,{children:r.map(e=>{let t=On(e.merged,e.runs);return Y(`tr`,{children:[Y(`td`,{class:`strong`,children:Dn(e.workflow)}),Y(`td`,{class:`mono`,children:e.origin||`registry`}),Y(`td`,{children:`${e.runs} run${e.runs===1?``:`s`}`}),Y(`td`,{children:[Y(`div`,{class:`wf-rate`,children:[t,`%`,Y(`span`,{class:`wf-rate-sub`,children:[e.merged,` of `,e.runs,` merged`]})]}),Y(jn,{fraction:t,kind:t>=50?`ok`:`warn`})]}),Y(`td`,{class:`mono`,children:e.avg_tokens?e.avg_tokens.toLocaleString():`—`}),Y(`td`,{class:`mono`,children:e.avg_steps?e.avg_steps.toFixed(1):`—`})]},e.workflow)})})]})})]}):Y(`div`,{class:`card`,children:[Y(`div`,{class:`card-head`,children:Y(`div`,{children:Y(`h2`,{class:`card-title`,children:`Per workflow`})})}),Y(An,{title:`No workflow runs yet`,detail:`Stats appear here once a task has run through a workflow.`})]})}function In({stages:e}){if(!e.length)return Y(`div`,{class:`card wf-stage-card`,children:[Y(`div`,{class:`card-head`,children:Y(`div`,{children:Y(`h2`,{class:`card-title`,children:`Per stage`})})}),Y(An,{title:`No stage data yet`,detail:`Stage timing and failures appear here once workflows have run.`})]});let t=Math.max(...e.map(e=>e.avg_ms||0),1),n=[...e].sort((e,t)=>(t.avg_ms||0)-(e.avg_ms||0)),r=[...e].filter(e=>e.errors>0).sort((e,t)=>t.errors-e.errors);return Y(`div`,{class:`grid grid-2 wf-stage-card`,children:[Y(`div`,{class:`card`,children:[Y(`div`,{class:`card-head`,children:Y(`div`,{children:[Y(`h2`,{class:`card-title`,children:`Slowest stages`}),Y(`p`,{class:`card-sub`,children:`Average duration, this workflow's stages`})]})}),Y(`div`,{class:`table-scroll`,children:Y(`table`,{class:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Workflow`}),Y(`th`,{children:`Stage`}),Y(`th`,{children:`Runs`}),Y(`th`,{children:`Avg duration`})]})}),Y(`tbody`,{children:n.map((e,n)=>Y(`tr`,{children:[Y(`td`,{children:Dn(e.workflow)}),Y(`td`,{class:`strong`,children:e.stage}),Y(`td`,{children:e.runs}),Y(`td`,{children:[Y(`div`,{class:`wf-rate`,children:kn(e.avg_ms)}),Y(jn,{fraction:On(e.avg_ms,t),kind:`info`})]})]},n))})]})})]}),Y(`div`,{class:`card`,children:[Y(`div`,{class:`card-head`,children:Y(`div`,{children:[Y(`h2`,{class:`card-title`,children:`Most failures`}),Y(`p`,{class:`card-sub`,children:`Stages that error out, over their runs`})]})}),r.length?Y(`div`,{class:`table-scroll`,children:Y(`table`,{class:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Workflow`}),Y(`th`,{children:`Stage`}),Y(`th`,{children:`Failures`})]})}),Y(`tbody`,{children:r.map((e,t)=>Y(`tr`,{children:[Y(`td`,{children:Dn(e.workflow)}),Y(`td`,{class:`strong`,children:e.stage}),Y(`td`,{children:[Y(`div`,{class:`wf-rate`,children:[e.errors,` of `,e.runs]}),Y(jn,{fraction:On(e.errors,e.runs),kind:`danger`})]})]},t))})]})}):Y(An,{title:`No failures recorded`,detail:`Every stage has completed cleanly so far.`})]})]})}function Ln({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function Rn(e,t){return e===`running`?`ok`:e===`failed`||e===`degraded`?`warn`:`idle`}function zn(){let[e,t]=W([]),[n,r]=W(null),i=async()=>{try{let e=await J.channels();t(e?.channels||[]),r(null)}catch(e){r(String(e.message||e))}};return G(()=>{i()},[]),Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Channels`}),Y(`p`,{className:`page-sub`,children:`The conversational front-ends Archie can be reached through.`})]}),Y(`div`,{className:`page-actions`,children:Y(`button`,{className:`btn`,onClick:i,children:`Refresh`})})]}),Y(`div`,{className:`grid grid-2`,children:n?Y(Ln,{title:`Cannot reach archied`,detail:n}):e.length===0?Y(Ln,{title:`No channels configured`,detail:`Configure [chat.telegram] or [chat.webhook_addr] in config.toml to talk to Archie outside the dashboard.`}):e.map(e=>Y(`div`,{className:`card channel-card`,children:[Y(`div`,{className:`card-head`,children:[Y(`h3`,{className:`card-title`,children:e.name}),Y(Q,{text:e.state||(e.configured?`configured`:`stopped`),kind:Rn(e.state,e.configured)})]}),Y(`p`,{className:`channel-desc`,children:e.description}),Y(`p`,{className:`channel-detail`,children:e.detail}),e.reload_supported?Y(`button`,{className:`btn`,onClick:async t=>{t.currentTarget.disabled=!0;try{await J.channelReload(e.id||e.name.toLowerCase()),await i()}catch{}finally{t.currentTarget&&(t.currentTarget.disabled=!1)}},children:`Reload`}):Y(`p`,{className:`channel-detail`,children:`Reload requires a daemon restart for this adapter.`})]},e.id||e.name))})]})}function Bn(e){return Y(zn,{query:e})}function Vn({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function Hn(e){return Y(Un,{query:e})}function Un({query:e}){let[t,n]=W([]),[r,i]=W(null),a=async()=>{try{let e=await J.curators();n(e?.curators||[]),i(null)}catch(e){i(String(e.message||e))}};return G(()=>{a()},[]),Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Curators`}),Y(`p`,{className:`page-sub`,children:`Background agents that maintain memory and skills: what ran, and why.`})]}),Y(`div`,{className:`page-actions`,children:Y(`button`,{className:`btn`,onClick:a,children:`Refresh`})})]}),Y(`div`,{className:`grid grid-2`,children:r?Y(Vn,{title:`Cannot reach archied`,detail:r}):t.length?t.map(e=>Y(Gn,{curator:e},e.name)):Y(Vn,{title:`No curators registered`,detail:`Curators are background agent loops that maintain memory and skills. None are registered on this daemon.`})})]})}function Wn(e){switch(e){case`healthy`:return`ok`;case`degraded`:return`warn`;case`unhealthy`:return`danger`;default:return`idle`}}function Gn({curator:e}){let t=e.recent_actions||[];return Y(`div`,{className:`card curator-card`,children:[Y(`div`,{className:`card-head`,children:[Y(`h3`,{className:`card-title`,children:e.name}),Y(Q,{text:e.health?.status||`unknown`,kind:Wn(e.health?.status)})]}),e.health?.message&&Y(`p`,{className:`curator-health-message`,children:e.health.message}),Y(`p`,{className:`curator-meta`,children:e.last_run_at?`Last ran ${Z(e.last_run_at)} · ${e.last_run_actions} action${e.last_run_actions===1?``:`s`}`:`Has not run yet`}),t.length?Y(`ul`,{className:`curator-actions`,children:t.map((e,t)=>Y(`li`,{className:`curator-action`,children:[Y(`div`,{className:`curator-action-head`,children:[Y(`span`,{className:`curator-action-type`,children:e.type||`action`}),Y(`span`,{className:`curator-action-time`,children:Z(e.at)})]}),e.detail&&Y(`p`,{className:`curator-action-detail`,children:e.detail}),e.reason&&Y(`p`,{className:`curator-action-reason`,children:[`Why: `,e.reason]})]},t))}):Y(`p`,{className:`curator-meta`,children:`No recorded activity yet.`})]})}function Kn(e){return e==null||e===``?`—`:String(e)}function qn({label:e,value:t,opts:n}){let r=Kn(t),[i,a]=W(!1),[o,s]=W(``),[c,l]=W(null),[u,d]=W(!1),[f,p]=W(!1),m=n?.key;if(!m)return Y(`div`,{className:`kv`,children:[Y(`span`,{className:`kv-label`,title:n?.hint,children:e}),Y(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r})]});let h=n.locked?.[m];if(h)return Y(`div`,{className:`kv is-locked`,children:[Y(`span`,{className:`kv-label`,title:n.hint,children:e}),Y(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),Y(`span`,{className:`kv-note`,children:h})]});if(n.editable===!1)return Y(`div`,{className:`kv`,children:[Y(`span`,{className:`kv-label`,title:n.hint,children:e}),Y(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r})]});let g=n.overridden?.includes(m),_=()=>{s(String(n.raw??``)),l(null),a(!0)},v=async()=>{p(!0),l(null);try{await J.configReset(m),n.onSaved?.()}catch(e){l(String(e.message||e))}finally{p(!1)}},y=async()=>{let e=Jn(n.type,o);if(e.error){l(e.error);return}d(!0),l(null);try{await(n.save||(e=>J.configUpdate({[m]:e})))(e.value),a(!1),n.onSaved?.()}catch(e){l(String(e.message||e))}finally{d(!1)}};if(i){let t=K(null);G(()=>{t.current&&t.current.focus()},[]);let r=e=>{e.key===`Enter`&&(e.preventDefault(),y()),e.key===`Escape`&&a(!1)},i;return i=n.type===`bool`?Y(`select`,{className:`kv-input`,value:o,onChange:e=>s(e.target.value),onKeyDown:r,ref:t,children:[Y(`option`,{value:`true`,children:`true`}),Y(`option`,{value:`false`,children:`false`})]}):n.type===`enum`?Y(`select`,{className:`kv-input`,value:o,onChange:e=>s(e.target.value),onKeyDown:r,ref:t,children:(n.options||[]).map(e=>Y(`option`,{value:e,children:e},e))}):Y(`input`,{className:`kv-input`,type:`text`,value:o,onInput:e=>s(e.target.value),onKeyDown:r,ref:t}),Y(`div`,{className:`kv`,children:[Y(`span`,{className:`kv-label`,title:n.hint,children:e}),i,Y(`div`,{className:`kv-actions`,children:[Y(`button`,{className:`kv-save`,type:`button`,onClick:y,disabled:u,children:`Save`}),Y(`button`,{className:`kv-cancel`,type:`button`,onClick:()=>a(!1),disabled:u,children:`Cancel`})]}),c&&Y(`span`,{className:`kv-note is-error`,children:c})]})}return Y(`div`,{className:`kv`,children:[Y(`span`,{className:`kv-label`,title:n.hint,children:e}),Y(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),Y(`div`,{className:`kv-actions`,children:[g&&Y(`span`,{className:`kv-flag`,title:`Set from the dashboard; this shadows the value in the config file`,children:`overridden`}),Y(`button`,{className:`kv-btn`,type:`button`,title:`Edit ${e}`,onClick:_,children:`Edit`}),g&&Y(`button`,{className:`kv-btn`,type:`button`,title:`Discard the dashboard value and fall back to the config file`,onClick:v,disabled:f,children:`Reset`})]}),c&&Y(`span`,{className:`kv-note is-error`,children:c})]})}function Jn(e,t){switch(e){case`int`:{let e=parseInt(t,10);return Number.isNaN(e)?{error:`Enter a whole number`}:{value:e}}case`bool`:return{value:t===`true`};default:return{value:t}}}function Yn({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function Xn({sub:e,title:t,children:n}){return Y(`div`,{className:`card cfg-section`,children:[Y(`div`,{className:`card-head`,children:Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:t||`Update status`}),Y(`p`,{className:`card-sub`,children:e})]})}),n]})}var Zn={ok:`OK`,update_available:`Update available`,drift:`Drift`,unknown:`Unknown`},Qn={ok:`ok`,update_available:`info`,drift:`danger`,unknown:`idle`};function $n({components:e}){return!e||!e.length?Y(Xn,{sub:`How each component is deployed, and whether what's running matches what's installed.`,children:Y(Yn,{title:`No components reported`,detail:`The configured update-check command returned nothing.`})}):Y(Xn,{sub:`How each component is deployed, and whether what's running matches what's installed. Hover a row for the exact versions compared.`,children:Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Component`}),Y(`th`,{children:`Install type`}),Y(`th`,{children:`Running`}),Y(`th`,{children:`Latest available`}),Y(`th`,{children:`Status`})]})}),Y(`tbody`,{children:e.map(e=>Y(`tr`,{title:[`Installed claim: ${e.installed_claim||`unknown`}`,`Running: ${e.running_version||`not observed`}`,e.reference?`Reference: ${e.reference}`:null].filter(Boolean).join(` -`),children:[Y(`td`,{className:`strong`,children:e.label||e.id}),Y(`td`,{className:`mono`,children:e.install_type||`—`}),Y(`td`,{className:`mono`,children:e.running_version||`—`}),Y(`td`,{className:`mono`,children:e.latest_available||`—`}),Y(`td`,{children:Y(Q,{text:Zn[e.status]||e.status,kind:Qn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function $({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function er({title:e,sub:t,children:n}){return Y(`div`,{className:`card cfg-section`,children:[Y(`div`,{className:`card-head`,children:Y(`div`,{children:[Y(`h2`,{className:`card-title`,children:e}),Y(`p`,{className:`card-sub`,children:t})]})}),n]})}function tr({origins:e}){return e?.length?Y(er,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:Y(`div`,{className:`kv-list`,children:e.map((e,t)=>Y(qn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):Y(er,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:Y($,{title:`Source provenance is unavailable.`})})}function nr(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function rr({data:e,error:t}){if(t)return Y(er,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:Y($,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return Y(er,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,children:[Y(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?Y(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??Ue(e.id),n=e.kind??We(e.id);return Y(`div`,{className:`kv`,children:[Y(`span`,{className:`kv-label`,children:e.id}),Y(`span`,{className:`kv-value`,children:Y(Q,{text:t,kind:n})})]},e.id)})}):Y($,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),Y(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?Y(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=nr(e.kind);return Y(`div`,{className:`kv`,children:[Y(`span`,{className:`kv-label`,children:e.id}),Y(`span`,{className:`kv-value`,children:Y(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):Y($,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function ir({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=W(!1),[o,s]=W(null),[c,l]=W(!!e[t]);return r?Y(`td`,{children:[Y(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:c,onChange:async r=>{let i=r.target.checked;l(i),a(!0),s(null);try{await J.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){l(!i),s(String(e.message||e))}finally{a(!1)}},disabled:i}),o&&Y(`span`,{className:`kv-note is-error`,children:o})]}):Y(`td`,{children:c?`yes`:`no`})}function ar({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=W(String(e[t]??0)),[o,s]=W(null),[c,l]=W(!1);return r?Y(`td`,{children:[Y(`input`,{className:`kv-input`,type:`text`,value:i,onChange:e=>a(e.target.value),onBlur:async()=>{let r=parseInt(i,10);if(Number.isNaN(r)){s(`Enter a whole number`);return}l(!0),s(null);try{await J.configRepoUpdate(e.owner,e.name,t,r),n?.()}catch(e){s(String(e.message||e))}finally{l(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:c}),o&&Y(`span`,{className:`kv-note is-error`,children:o})]}):Y(`td`,{className:`mono`,children:i})}function or({repos:e,onSaved:t,editable:n=!0}){if(!e?.length)return Y(er,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:Y($,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let r=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return Y(er,{title:`Repositories`,sub:`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, not the file config.toml directly.`,children:Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Repository`}),Y(`th`,{children:`Base branch`}),Y(`th`,{children:`Ecosystem`}),Y(`th`,{children:`Quality gate`}),Y(`th`,{children:`Protected paths`}),Y(`th`,{children:`Concurrent`}),Y(`th`,{children:`Max retries`}),Y(`th`,{children:`Self-review`})]})}),Y(`tbody`,{children:e.map((e,i)=>Y(`tr`,{children:[Y(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),Y(`td`,{className:`mono`,children:e.base}),Y(`td`,{children:e.ecosystem||`go`}),Y(`td`,{className:`mono`,children:r(e.gate)}),Y(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),Y(ir,{r:e,field:`allow_concurrent`,onSaved:t,editable:n}),Y(ar,{r:e,field:`max_retries`,onSaved:t,editable:n}),Y(ir,{r:e,field:`review_enabled`,onSaved:t,editable:n})]},i))})]})})})}function sr(e){return e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown role`}function cr({models:e,providers:t}){let n=Object.entries(e||{}),r=Object.entries(t||{});return Y(er,{title:`Models & providers`,sub:`Which model handles each stage of work, and which LLM providers are wired up. Only the environment variable NAME is shown, never its value.`,children:[Y(`h3`,{className:`cfg-subhead`,children:`Model roles`}),n.length?Y(`div`,{className:`kv-list`,children:n.map(([e,t])=>Y(qn,{label:sr(e),value:t},e))}):Y($,{title:`No model roles configured`,detail:`Assign a model to at least one role (e.g. "builder") in [models].`}),Y(`h3`,{className:`cfg-subhead`,children:`Providers`}),r.length?Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[Y(`th`,{children:`Provider`}),Y(`th`,{children:`Class`}),Y(`th`,{children:`Base URL`}),Y(`th`,{children:`API key env var`}),Y(`th`,{children:`Status`})]})}),Y(`tbody`,{children:r.map(([e,t])=>Y(`tr`,{children:[Y(`td`,{className:`strong`,children:e}),Y(`td`,{children:t.class}),Y(`td`,{className:`mono`,children:t.base_url||`default`}),Y(`td`,{className:`mono`,children:t.api_key_env||`—`}),Y(`td`,{children:t.configured?Y(Q,{text:`configured`,kind:`ok`}):Y(Q,{text:`missing credentials`,kind:`warn`})})]},e))})]})}):Y($,{title:`No providers configured`,detail:`Add a [providers.] entry so a model role above has something to run on.`})]})}function lr(){let[e,t]=W(null),[n,r]=W(null),[i,a]=W(null),[o,s]=W(null),[c,l]=W(!1),[u,d]=W(null),[f,p]=W(null),m=()=>{h(),g(),_()},h=async()=>{try{let e=await J.config();t(e),r(null)}catch(e){r(String(e.message||e))}},g=async()=>{try{let e=await J.version();a(e?.components||[]),s(null),l(!1)}catch(e){e?.status===501?l(!0):s(String(e.message||e))}},_=async()=>{try{let e=await J.taskMeta();d(e),p(null)}catch(e){p(String(e.message||e))}};return G(()=>{m()},[]),Y(`div`,{className:`cfg-page`,children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Configuration`}),Y(`p`,{className:`page-sub`,children:`What archied is actually running with right now.`})]}),Y(`div`,{className:`page-actions`,children:Y(`button`,{className:`btn`,onClick:m,children:`Refresh`})})]}),Y(`div`,{children:!c&&(o?Y(`div`,{className:`card`,children:Y($,{title:`Update status unavailable`,detail:o})}):i?Y($n,{components:i}):null)}),Y(`div`,{children:Y(rr,{data:u,error:f})}),Y(`div`,{children:n?Y(`div`,{className:`card`,children:Y($,{title:`Cannot reach archied`,detail:n})}):!e||Object.keys(e).length===0?Y(`div`,{className:`card`,children:Y($,{title:`No configuration loaded`,detail:`archied is running without a config file wired into the dashboard, so there is nothing to show.`})}):Y(S,{children:[e.reload?.overlay_unavailable&&Y(`div`,{className:`card cfg-notice`,children:Y(`p`,{children:[`The runtime config overlay is not in effect: `,e.reload.overlay_unavailable]})}),e.reload?.last_error&&Y(`div`,{className:`card cfg-notice`,children:Y(`p`,{children:[`The last config reload failed; the running config is unchanged: `,e.reload.last_error]})}),(e.schema||[]).map((t,n)=>{let r=t.fields.filter(e=>e.type!==`structured`);return r.length?Y(er,{title:t.label,sub:t.description,children:Y(`div`,{className:`kv-list`,children:r.map(t=>Y(qn,{label:t.label,value:t.value,opts:{key:t.key,type:t.type,options:t.options,raw:t.value,hint:t.description,editable:t.editable&&e.editable!==!1,locked:e.locked||{},overridden:e.overridden||[],onSaved:h}},t.key))})},n):null}),Y(or,{repos:e.repositories,onSaved:h,editable:e.editable!==!1}),Y(cr,{models:e.models,providers:e.providers}),Y(tr,{origins:e.provenance})]})})]})}function ur(e){return Y(lr,{query:e})}function dr({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function fr(e){return`${e.time||``}|${e.level||``}|${e.message||e.msg||``}|${JSON.stringify(e.fields||{})}`}function pr(){let[e,t]=W({level:``,component:``,q:``}),[n,r]=W(!1),[i,a]=W([]),[o,s]=W([]),c=K(new Map),[l,u]=W(0),[d,f]=W(!1),[p,m]=W(`connecting`),[h,g]=W(`Refreshing…`),_=K(null),v=K(null),y=async()=>{g(`Refreshing…`);try{let t=await J.logs({level:e.level,component:e.component,q:e.q,limit:500});a(e=>{let n=t.components||[];return e.length===n.length&&e.every((e,t)=>e===n[t])?e:n}),f(!!t.disabled);let n=t.disabled?`Durable history unavailable; live daemon logs continue.`:t.truncated?`showing the most recent matches from ${t.file}`:t.file||``;g(n),s(t.entries||[])}catch{g(`Cannot read logs`)}};G(()=>{y()},[e]),G(()=>{let e=Ne(e=>{if(b.current)return;let t=e;S.current(t)&&(c.current.set(fr(t),t),t.fields?.component&&a(e=>e.includes(t.fields.component)?e:[...e,t.fields.component]),u(e=>e+1))},e=>{m(e)});return()=>e()},[]);let b=K(n);b.current=n;let x=t=>{if(e.level&&!e.level.split(`,`).includes((t.level||``).toUpperCase())||e.component&&t.fields?.component!==e.component)return!1;if(e.q){let n=e.q.toLowerCase();if(!`${t.message||t.msg||``} ${JSON.stringify(t.fields||{})}`.toLowerCase().includes(n))return!1}return!0},S=K(x);S.current=x;let C=ge(()=>{let e=new Map;for(let t of o)e.set(fr(t),t);for(let[t,n]of c.current)e.set(t,n);return[...e.values()].filter(x).slice(-1e3)},[o,l,e]);return G(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[C]),Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Logs`}),Y(`p`,{className:`page-sub`,children:`What Archie has been doing, newest last.`})]}),Y(`div`,{className:`page-actions`,children:[Y(`button`,{className:`btn ${n?`btn-primary`:``}`,onClick:()=>r(!n),children:n?`Resume`:`Pause`}),Y(`button`,{className:`btn`,onClick:y,children:`Refresh`})]})]}),Y(`div`,{className:`card`,children:[Y(`div`,{className:`card-head`,children:[Y(`div`,{className:`log-filters`,children:[Y(`select`,{className:`log-select`,value:e.level,onChange:e=>t(t=>({...t,level:e.target.value})),children:St.map(e=>Y(`option`,{value:e.value,children:e.label},e.value))}),Y(`select`,{className:`log-select`,value:e.component,onChange:e=>t(t=>({...t,component:e.target.value})),children:[Y(`option`,{value:``,children:`All components`}),i.map(e=>Y(`option`,{value:e,children:e},e))]}),Y(`input`,{className:`log-search`,type:`search`,placeholder:`Search messages and fields…`,onInput:e=>{let n=e.target.value;v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{t(e=>({...e,q:n}))},250)}})]}),Y(`div`,{className:`log-status`,children:[Y(`span`,{className:`log-meta`,children:h}),Y(Q,{text:p,kind:p===`live`?`ok`:`warn`})]})]}),Y(`div`,{className:`log-list`,ref:_,children:h===`Cannot read logs`?Y(dr,{title:`Cannot read logs`}):C.length?C.map(e=>Y(wt,{entry:e},fr(e))):Y(dr,{title:d?`Durable history unavailable`:`Nothing matches`,detail:d?`Live daemon logs will appear here while this page is open.`:`Try a wider level or clear the search.`})})]})]})}function mr(e){return Y(pr,{query:e})}function hr({capture:e,expanded:t,onToggle:n}){return Y(S,{children:[Y(`tr`,{className:`capture-row`,tabIndex:`0`,"aria-expanded":String(t),onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(e))},children:[Y(`td`,{className:`mono`,children:e.source||`(unknown)`}),Y(`td`,{title:e.received_at||``,children:Z(e.received_at)}),Y(`td`,{children:Y(Q,{text:`Unbound`,kind:`idle`})}),Y(`td`,{className:`mono`,children:e.content_type||`—`}),Y(`td`,{children:Y(`button`,{className:`btn btn-small`,type:`button`,children:t?`Hide`:`View`})})]}),t&&Y(gr,{capture:e})]})}function gr({capture:e}){return Y(`tr`,{className:`capture-detail-row`,children:Y(`td`,{colSpan:`5`,children:Y(`div`,{className:`capture-detail`,children:[Y(`div`,{className:`capture-detail-section`,children:[Y(`div`,{className:`capture-detail-title`,children:`Payload`}),Y(_r,{raw:e.body})]}),Y(`div`,{className:`capture-detail-section`,children:[Y(`div`,{className:`capture-detail-title`,children:`Headers`}),Y(_r,{raw:e.headers})]})]})})})}function _r({raw:e}){return e?Y(`pre`,{className:`capture-payload`,children:vr(e)}):Y(`div`,{className:`capture-empty`,children:`(empty)`})}function vr(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function yr({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function br(e){return Y(xr,{query:e})}function xr({query:e}){let[t,n]=W([]),[r,i]=W(null),[a,o]=W(null),[s,c]=W(!0),[l,u]=W({text:`connecting`,kind:`idle`}),d=async()=>{try{let e=await J.captures(100);c(e.enabled!==!1),n(e.captures||[]),o(null)}catch(e){o(String(e.message||e))}};return G(()=>{d();let e=Me(e=>{e.kind===`capture`&&d()},e=>{u({text:e,kind:e===`live`?`ok`:`warn`})});return()=>e()},[]),Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Event inspector`}),Y(`p`,{className:`page-sub`,children:`Real inbound payloads archie has captured, most recent first.`})]}),Y(`div`,{className:`page-actions`,children:[Y(Q,{text:l.text,kind:l.kind}),Y(`button`,{className:`btn`,onClick:d,children:`Refresh`})]})]}),Y(`div`,{className:`card`,children:a?Y(yr,{title:`Cannot reach archied`,detail:a}):s?t.length?Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[`Source`,`Received`,`Binding`,`Content type`,``].map((e,t)=>Y(`th`,{children:e},t))})}),Y(`tbody`,{children:t.map(e=>Y(hr,{capture:e,expanded:r===e.id,onToggle:()=>i(r===e.id?null:e.id)},e.id))})]})}):Y(yr,{title:`No captures yet`,detail:`Point a webhook at /webhooks/capture/ and it will show up here.`}):Y(yr,{title:`Capture is not configured`,detail:`This deployment has no capture storage wired up.`})})]})}var Sr=[`string`,`number`,`bool`,`object`,`array`,`any`];function Cr(e){if(e==null)return`any`;if(Array.isArray(e))return`array`;switch(typeof e){case`string`:return`string`;case`number`:return`number`;case`boolean`:return`bool`;case`object`:return`object`;default:return`any`}}function wr(e,t){return e?`${e}.${t}`:t}function Tr(e,t){return`${e}[${t}]`}function Er({value:e,path:t=``,name:n=``,onPick:r}){return typeof e==`object`&&e?Y(`ul`,{className:`mapping-tree-list`,children:(Array.isArray(e)?e.map((e,n)=>[String(n),e,Tr(t,n)]):Object.entries(e).map(([e,n])=>[e,n,wr(t,e)])).map(([e,t,n])=>Y(`li`,{className:`mapping-tree-item`,children:[Y(`span`,{className:`mapping-tree-key`,onClick:i=>{i.stopPropagation(),r&&r({path:n,type:Cr(t),name:e})},children:e}),Y(Er,{value:t,path:n,name:e,onPick:r})]},n))}):Y(`span`,{className:`mapping-tree-value`,onClick:i=>{i.stopPropagation(),r&&r({path:t,type:Cr(e),name:n})},children:JSON.stringify(e)})}function Dr({fields:e,preview:t,onRemove:n,onNameChange:r,onTypeChange:i,onRequiredChange:a}){if(!e.length)return Y(`div`,{className:`mapping-empty-fields`,children:`Click a value in the payload to bind a field.`});let o=new Map((t?.failures||[]).map(e=>[e.field_name,e]));return Y(`table`,{className:`table mapping-fields-table`,children:[Y(`thead`,{children:Y(`tr`,{children:[`Field name`,`Path`,`Type`,`Required`,`Preview`,``].map((e,t)=>Y(`th`,{children:e},t))})}),Y(`tbody`,{children:e.map((e,s)=>Y(`tr`,{children:[Y(`td`,{children:Y(`input`,{className:`mapping-input`,value:e.name,onInput:e=>r?.(s,e.target.value)})}),Y(`td`,{className:`mono`,children:e.path}),Y(`td`,{children:Y(`select`,{className:`mapping-select`,value:e.type,onChange:e=>i?.(s,e.target.value),children:Sr.map(e=>Y(`option`,{value:e,children:e},e))})}),Y(`td`,{children:Y(`input`,{type:`checkbox`,checked:e.required,onChange:e=>a?.(s,e.target.checked)})}),Y(`td`,{children:Y(Or,{field:e,preview:t,failureByField:o})}),Y(`td`,{children:Y(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>n?.(s),children:`Remove`})})]},s))})]})}function Or({field:e,preview:t,failureByField:n}){if(!t)return Y(Q,{text:`not previewed`,kind:`idle`});let r=n.get(e.name);return r?Y(Q,{text:r.reason,kind:`danger`}):Object.prototype.hasOwnProperty.call(t.values||{},e.name)?Y(Q,{text:JSON.stringify(t.values[e.name]),kind:`ok`}):Y(Q,{text:`skipped (optional)`,kind:`idle`})}function kr({mapping:e,onEdit:t,onDelete:n}){return Y(`tr`,{children:[Y(`td`,{children:e.name}),Y(`td`,{className:`mono`,children:e.source_hint||`—`}),Y(`td`,{children:String(e.fields?.length??0)}),Y(`td`,{children:[Y(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>t?.(e),children:`Edit`}),Y(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>n?.(e),children:`Delete`})]})]})}function Ar({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function jr(e){return Y(Mr,{query:e})}function Mr({query:e}){let[t,n]=W([]),[r,i]=W([]),[a,o]=W(null),[s,c]=W(null),l=async()=>{try{let[e,t]=await Promise.all([J.mappings(),J.captures(100)]);n(e.mappings||[]),i(t.captures||[]),o(null)}catch(e){o(String(e.message||e))}};G(()=>{l()},[]);let u=()=>{c({id:null,name:``,sourceHint:``,fields:[],captureId:null,payload:null,payloadError:null,preview:null,actionError:null})},d=e=>{c({id:e.id,name:e.name,sourceHint:e.source_hint||``,fields:(e.fields||[]).map(e=>({...e})),captureId:null,payload:null,payloadError:null,preview:null,actionError:null})},f=async e=>{if(window.confirm(`Delete mapping "${e.name}"?`))try{await J.mappingDelete(e.id),await l()}catch(e){o(String(e.message||e))}},p=e=>{let t=r.find(t=>String(t.id)===String(e));c(e=>{let n={...e,captureId:t?t.id:null,preview:null};if(!t)n.payload=null,n.payloadError=null;else try{n.payload=JSON.parse(t.body),n.payloadError=null}catch{n.payload=null,n.payloadError=`This capture's body is not valid JSON, so its fields cannot be mapped by path.`}return n})},m=({path:e,type:t,name:n})=>{c(r=>{let i=new Set(r.fields.map(e=>e.name)),a=n||`field`,o=1;for(;i.has(a);)a=`${n||`field`}_${++o}`;let s=[...r.fields,{name:a,path:e,type:t,required:!0}];return{...r,fields:s,preview:null}})},h=e=>{c(t=>{let n=t.fields.slice();return n.splice(e,1),{...t,fields:n,preview:null}})},g=(e,t)=>{c(n=>{let r=n.fields.slice();return r[e]={...r[e],...t},{...n,fields:r,preview:null}})};return s?Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:Y(`h1`,{className:`page-title`,children:s.id?`Edit mapping`:`New mapping`})}),Y(`div`,{className:`page-actions`,children:[Y(`button`,{className:`btn`,type:`button`,onClick:()=>{c(null)},children:`Cancel`}),Y(`button`,{className:`btn btn-primary`,type:`button`,onClick:async()=>{let e={name:s.name,source_hint:s.sourceHint,fields:s.fields};try{s.id?await J.mappingUpdate(s.id,e):await J.mappingCreate(e),c(null),await l()}catch(e){c(t=>({...t,actionError:String(e.message||e)}))}},children:`Save`})]})]}),s.actionError&&Y(`div`,{className:`mapping-error`,children:s.actionError}),Y(`div`,{className:`card mapping-form`,children:[Y(`label`,{className:`mapping-form-row`,children:[`Name`,Y(`input`,{className:`mapping-input`,value:s.name,onInput:e=>c(t=>({...t,name:e.target.value}))})]}),Y(`label`,{className:`mapping-form-row`,children:[`Source hint (organisational only)`,Y(`input`,{className:`mapping-input`,value:s.sourceHint,onInput:e=>c(t=>({...t,sourceHint:e.target.value}))})]}),Y(`label`,{className:`mapping-form-row`,children:[`Preview against captured event`,Y(`select`,{className:`mapping-select`,value:s.captureId||``,onChange:e=>p(e.target.value),children:[Y(`option`,{value:``,children:`— pick a captured event —`}),r.map(e=>Y(`option`,{value:e.id,children:[e.source||`(unknown)`,` — `,e.received_at||``]},e.id))]})]})]}),Y(`div`,{className:`card mapping-fields`,children:[Y(`div`,{className:`mapping-section-title`,children:`Bound fields`}),Y(Dr,{fields:s.fields,preview:s.preview,onRemove:h,onNameChange:(e,t)=>g(e,{name:t}),onTypeChange:(e,t)=>g(e,{type:t}),onRequiredChange:(e,t)=>g(e,{required:t})}),Y(`button`,{className:`btn`,type:`button`,onClick:async()=>{if(!s.captureId){c(e=>({...e,actionError:`Pick a captured event to preview against.`}));return}try{let e=await J.mappingPreview(s.captureId,s.fields);c(t=>({...t,preview:e,actionError:null}))}catch(e){c(t=>({...t,actionError:String(e.message||e)}))}},children:`Preview`})]}),Y(`div`,{className:`card mapping-payload`,children:[Y(`div`,{className:`mapping-section-title`,children:`Payload — click a value to bind it`}),s.payloadError?Y(`div`,{className:`mapping-error`,children:s.payloadError}):s.payload===null?Y(`div`,{className:`mapping-empty-fields`,children:`Pick a captured event above to see its payload.`}):Y(Er,{value:s.payload,onPick:m})]})]}):Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Field mappings`}),Y(`p`,{className:`page-sub`,children:`Bind named fields to JSON paths from a real captured event, ready for a playbook binding.`})]}),Y(`div`,{className:`page-actions`,children:Y(`button`,{className:`btn btn-primary`,type:`button`,onClick:u,children:`New mapping`})})]}),a?Y(Ar,{title:`Cannot reach archied`,detail:a}):t.length?Y(`div`,{className:`card`,children:Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[`Name`,`Source hint`,`Fields`,``].map((e,t)=>Y(`th`,{children:e},t))})}),Y(`tbody`,{children:t.map(e=>Y(kr,{mapping:e,onEdit:()=>d(e),onDelete:()=>f(e)},e.id))})]})})}):Y(Ar,{title:`No mappings yet`,detail:`Create one from a captured event to reuse fields in a future playbook binding.`})]})}var Nr={draft:`draft`,pending_approval:`pending approval`,armed:`armed`},Pr={draft:`idle`,pending_approval:`warn`,armed:`ok`};function Fr({status:e}){return Y(Q,{text:Nr[e]||e,kind:Pr[e]||`idle`})}function Ir({binding:e,onEdit:t,onApprove:n,onDelete:r}){let i=e.owner&&e.repo?`${e.owner}/${e.repo}`:`—`;return Y(`tr`,{children:[Y(`td`,{children:e.name}),Y(`td`,{className:`mono`,children:e.matcher?.source||`—`}),Y(`td`,{children:e.workflow}),Y(`td`,{className:`mono`,children:i}),Y(`td`,{children:Y(Fr,{status:e.status})}),Y(`td`,{children:[Y(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>t?.(e),children:`Edit`}),e.status===`pending_approval`&&Y(`button`,{className:`btn btn-small btn-primary`,type:`button`,onClick:()=>n?.(e),children:`Approve`}),Y(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>r?.(e),children:`Delete`})]})]})}function Lr({title:e,detail:t}){return Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:e}),t&&Y(`div`,{children:t})]})}function Rr(e){return Y(Br,{query:e})}function zr(){return{id:null,name:``,source:``,mappingId:``,workflow:``,owner:``,repo:``,secret:``,actionError:null}}function Br({query:e}){let[t,n]=W([]),[r,i]=W([]),[a,o]=W([]),[s,c]=W(null),[l,u]=W(null),d=async()=>{try{let[e,t,r]=await Promise.all([J.bindings(),J.mappings(),J.workflows()]);n(e.bindings||[]),i(t.mappings||[]),o((r.definitions||[]).filter(e=>e.enabled)),c(null)}catch(e){c(String(e.message||e))}};G(()=>{d()},[]);let f=()=>{u(zr())},p=e=>{u({id:e.id,name:e.name,source:e.matcher?.source||``,mappingId:e.mapping_id?String(e.mapping_id):``,workflow:e.workflow||``,owner:e.owner||``,repo:e.repo||``,secret:``,actionError:null})},m=()=>u(null),h=async()=>{let e={name:l.name,matcher:{source:l.source},mapping_id:Number(l.mappingId)||0,workflow:l.workflow,owner:l.owner,repo:l.repo,secret:l.secret};try{l.id?await J.bindingUpdate(l.id,e):await J.bindingCreate(e),u(null),await d()}catch(e){u(t=>({...t,actionError:String(e.message||e)}))}},g=async e=>{try{await J.bindingApprove(e.id),await d()}catch(e){c(String(e.message||e))}},_=async e=>{if(window.confirm(`Delete binding "${e.name}"?`))try{await J.bindingDelete(e.id),await d()}catch(e){c(String(e.message||e))}};return l?Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:Y(`h1`,{className:`page-title`,children:l.id?`Edit binding`:`New binding`})}),Y(`div`,{className:`page-actions`,children:[Y(`button`,{className:`btn`,type:`button`,onClick:m,children:`Cancel`}),Y(`button`,{className:`btn btn-primary`,type:`button`,onClick:h,children:`Save`})]})]}),l.actionError&&Y(`div`,{className:`binding-error`,children:l.actionError}),Y(`div`,{className:`card binding-form`,children:[Y(`label`,{className:`binding-form-row`,children:[`Name`,Y(`input`,{className:`binding-input`,value:l.name,onInput:e=>u(t=>({...t,name:e.target.value}))})]}),Y(`label`,{className:`binding-form-row`,children:[`Source (the path segment senders POST to, e.g. "sentry")`,Y(`input`,{className:`binding-input`,value:l.source,onInput:e=>u(t=>({...t,source:e.target.value}))})]}),Y(`label`,{className:`binding-form-row`,children:[`Field mapping`,Y(`select`,{className:`binding-select`,value:l.mappingId,onChange:e=>u(t=>({...t,mappingId:e.target.value})),children:[Y(`option`,{value:``,children:`— pick a saved mapping —`}),r.map(e=>Y(`option`,{value:e.id,children:e.name},e.id))]})]}),Y(`label`,{className:`binding-form-row`,children:[`Workflow`,Y(`select`,{className:`binding-select`,value:l.workflow,onChange:e=>u(t=>({...t,workflow:e.target.value})),children:[Y(`option`,{value:``,children:`— pick a workflow —`}),a.map(e=>Y(`option`,{value:e.id,children:e.name},e.id))]})]}),Y(`label`,{className:`binding-form-row`,children:[`Repo pin -- owner (optional; leave both blank for the single-configured-repo default)`,Y(`input`,{className:`binding-input`,value:l.owner,onInput:e=>u(t=>({...t,owner:e.target.value}))})]}),Y(`label`,{className:`binding-form-row`,children:[`Repo pin -- repo`,Y(`input`,{className:`binding-input`,value:l.repo,onInput:e=>u(t=>({...t,repo:e.target.value}))})]}),Y(`label`,{className:`binding-form-row`,children:[`Shared secret (`,l.id?`leave blank to keep the current secret`:`senders sign with this via HMAC-SHA256`,`)`,Y(`input`,{className:`binding-input`,type:`password`,value:l.secret,onInput:e=>u(t=>({...t,secret:e.target.value}))})]})]})]}):Y(`div`,{children:[Y(`div`,{className:`page-head`,children:[Y(`div`,{children:[Y(`h1`,{className:`page-title`,children:`Playbook bindings`}),Y(`p`,{className:`page-sub`,children:`Tie a matcher, a field mapping, and a workflow together. New and edited bindings need explicit approval before they can fire.`})]}),Y(`div`,{className:`page-actions`,children:Y(`button`,{className:`btn btn-primary`,type:`button`,onClick:f,children:`New binding`})})]}),s?Y(Lr,{title:`Cannot reach archied`,detail:s}):t.length?Y(`div`,{className:`card`,children:Y(`div`,{className:`table-scroll`,children:Y(`table`,{className:`table`,children:[Y(`thead`,{children:Y(`tr`,{children:[`Name`,`Source`,`Workflow`,`Repo pin`,`Status`,``].map((e,t)=>Y(`th`,{children:e},t))})}),Y(`tbody`,{children:t.map(e=>Y(Ir,{binding:e,onEdit:()=>p(e),onApprove:()=>g(e),onDelete:()=>_(e)},e.id))})]})})}):Y(Lr,{title:`No bindings yet`,detail:`Create one from a saved field mapping to turn a captured webhook into a workflow.`})]})}var Vr=/(!\[[^\]]*\]\((?:https?:\/\/[^\s)]+|data:image\/[^\s)]+|\/[^\s)]+)\)|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|`[^`]+`|\[[^\]]+\]\((?:https?:\/\/[^\s)]+|\/[^\s)]+)\)|\*[^*]+\*|_[^_]+_)/g;function Hr(e){let t=[],n=0,r=0;for(let i of String(e).matchAll(Vr)){i.index>n&&t.push(e.slice(n,i.index));let a=i[0];if(a.startsWith(`![`)){let e=a.match(/^!\[([^\]]*)\]\((.+)\)$/);e&&t.push(Y(`img`,{className:`chat-media-img`,src:e[2],alt:e[1]||`Image`,loading:`lazy`},r++))}else if(a.startsWith(`~~`))t.push(Y(`del`,{children:a.slice(2,-2)},r++));else if(a.startsWith(`**`)||a.startsWith(`__`))t.push(Y(`strong`,{children:a.slice(2,-2)},r++));else if(a.startsWith("`"))t.push(Y(`code`,{children:a.slice(1,-1)},r++));else if(a.startsWith(`[`)){let e=a.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+|\/[^\s)]+)\)$/);e&&t.push(Y(`a`,{href:e[2],target:`_blank`,rel:`noreferrer`,children:e[1]},r++))}else t.push(Y(`em`,{children:a.slice(1,-1)},r++));n=i.index+a.length}return n{i.length&&(n.push(Y(`p`,{children:Hr(i.join(` `))},s++)),i=[])},l=()=>{if(!a)return;let e=a.items.map((e,t)=>Y(`li`,{children:Hr(e)},t));n.push(a.tag===`ol`?Y(`ol`,{children:e},s++):Y(`ul`,{children:e},s++)),a=null};for(let e=0;eY(`th`,{children:Hr(e)},t))})}),Y(`tbody`,{children:t.map((e,t)=>Y(`tr`,{children:e.map((e,t)=>Y(`td`,{children:Hr(e)},t))},t))})]},s++));continue}if(!t.trim()){c(),l();continue}let f=t.match(/^(#{1,3})\s+(.+)$/);if(f){c(),l();let e=`h${f[1].length}`;n.push(Y(e,{children:Hr(f[2])},s++));continue}let p=t.match(/^\s*[-*]\s+(.+)$/),m=t.match(/^\s*\d+[.)]\s+(.+)$/);if(p||m){c();let e=m?`ol`:`ul`;(!a||a.tag!==e)&&(l(),a={tag:e,items:[]}),a.items.push((p||m)[1]);continue}if(t.startsWith(`>`)){c(),l(),n.push(Y(`blockquote`,{children:Hr(t.replace(/^>\s?/,``))},s++));continue}i.push(t)}return c(),l(),o&&n.push(Y(`pre`,{children:Y(`code`,{children:o.join(` -`)})},s++)),Y(`div`,{className:t,children:n})}function Wr(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function Gr(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Kr=`archie.web.chat.channel`;function qr(){let e=localStorage.getItem(Kr);return e||(e=Te(),localStorage.setItem(Kr,e)),e}function Jr(e){return{text:e,sourceID:Te()}}function Yr(e){return{...e}}function Xr(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?Yr(e.turn):Jr(r),isRetry:n}}function Zr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function Qr(){return location.hash.slice(1)||`/`}function $r(){let[e,t]=W([]),[n,r]=W(``),[i,a]=W([]),[o,s]=W(``),[c,l]=W(`Ready`),[u,d]=W(!1),[f,p]=W({}),[m,h]=W(``),[g,_]=W(``),[v,y]=W(``),[b,x]=W([]),[C,w]=W([]),[T,E]=W(0),[D,O]=W(!1),[k,A]=W(null),j=K(null),M=K(null),N=K(null),P=K(null),F=K(null),I=K(u);I.current=u,G(()=>{j.current&&(j.current.scrollTop=j.current.scrollHeight)},[i,k]),G(()=>{L().catch(e=>{l(e.message||`Chat unavailable`)});let e=()=>{N.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),N.current?.abort()}},[]);async function L(){let e=await J.chatSessions(),r=e.sessions||[];t(r),p(e),h(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;_(a),y(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);x(o),!n&&r[0]&&await R(r[0].session_id,e,r)}async function R(e,t,n){let i=t||f;r(e),a([]),A(null);let o=i.active_personas?.[e]||i.active_persona||``;h(o);try{await J.chatMessage(qr(),`/resume ${e}`);let[t,n]=await Promise.all([J.chatMessages(e),J.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});a(i)}catch(e){l(e.message||`Could not load session messages`)}}async function z(e){if(n)try{l(`Working…`);let t=await J.chatMessage(qr(),e);t.session_id&&r(t.session_id),l(t.reply||`Session updated`),await L(),(t.session_id||n)&&await R(t.session_id||n),P.current&&(P.current.open=!1)}catch(e){l(e.message||`Session action failed`)}}function ee(e,t){let n=window.prompt(t);n?.trim()&&z(`${e} ${n.trim()}`)}function te(e){let t=e.target.value;h(t),!(!n||!t)&&J.chatPersona(n,t).then(()=>{p(e=>({...e,active_personas:{...e.active_personas||{},[n]:t}})),l(`Personality: ${t}`)}).catch(e=>{l(e.message||`Failed to set personality`)})}async function ne(e){let t=e.target.value;if(_(t),t)try{let e=await J.chatMessage(qr(),`/model --provider ${t}`);l(e.reply||`Provider updated`),await L()}catch(e){l(`Provider update failed: ${e.message||e}`)}}async function re(e){let t=e.target.value;if(y(t),t)try{let e=await J.chatMessage(qr(),`/model ${t}`);l(e.reply||`Model updated`),await L()}catch(e){l(`Model update failed: ${e.message||e}`)}}function ie(){s(`/new`),H({textOverride:`/new`})}function B(e){let t=e.target.value;s(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=b.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){w(t),E(0),O(!0);return}}O(!1),w([])}function V(e){let t=C[e];if(!t||!M.current)return;let n=M.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.search(/(?:^|\s)\/[^\s]*$/),o=a<0?r.length:a+ +(r[a]===` `),c=`${r.slice(0,o)}${t.command} ${i}`;s(c),O(!1);let l=o+t.command.length+1;setTimeout(()=>{n.focus(),n.setSelectionRange(l,l)},0)}function ae(e){if(D&&C.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&C.some(e=>e.command===o.trim())){e.preventDefault(),O(!1),H();return}if(e.key===`ArrowDown`){e.preventDefault(),E(e=>(e+1)%C.length);return}if(e.key===`ArrowUp`){e.preventDefault(),E(e=>(e+C.length-1)%C.length);return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),V(T);return}if(e.key===`Escape`){e.preventDefault(),O(!1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),H())}async function H(e=null){let t=e?.textOverride,{text:n,turn:i,isRetry:c}=Xr(e,t===void 0?o:t);if(!n||I.current)return;O(!1),d(!0),l(c?`Retrying…`:`Thinking…`),c||(a(e=>[...e,{from:`web`,text:n}]),s(``));let u=[];A({text:``,tools:[],isError:!1,turn:i,isRetry:c});let f=``,p=!1,m=!1,h=null;try{let e=new AbortController;N.current=e,h=setTimeout(()=>{m=!0,e.abort()},12e4);let t=(await J.chatStream({channel_id:qr(),source_id:i.sourceID,text:i.text,page:Qr()},{signal:e.signal})).body.getReader(),n=new TextDecoder,o=``;for(;;){let{value:e,done:i}=await t.read();o+=n.decode(e||new Uint8Array,{stream:!i});let a=o.split(` +(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(e.__,e.__i+1):null;for(var n;tt&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=O.__r=0}}function k(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y=r&&r.__k||h,b=t.length;for(c=A(n,t,y,c,b),d=0;d0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=M(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:ic?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a+!!u){for(i=n-1,a=n+1;i>=0||a=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function N(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function P(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||N(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||N(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function F(e){return function(n){if(this.l){var r=this.l[n.type+e];if(n[c]==null)n[c]=d++;else if(n[c]0?e:_(e)?e.map(R):e.constructor===void 0?v({},e):null}function te(n,r,i,a,o,s,c,l,u){var d,f,p,h,g,v,b,x=i.props||m,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d=n.__.length&&n.__.push({}),n.__[e]}function U(e){return se=1,ge(Te,e)}function ge(e,t,n){var r=he(B++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Te(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=V,!V.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};V.__f=!0;var a=V.shouldComponentUpdate,o=V.componentWillUpdate;V.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},V.shouldComponentUpdate=i}return r.__N||r.__}function W(e,t){var n=he(B++,3);!H.__s&&we(n.__H,t)&&(n.__=e,n.u=t,V.__H.__h.push(n))}function G(e){return se=5,_e(function(){return{current:e}},[])}function _e(e,t){var n=he(B++,7);return we(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function ve(e,t){return se=8,_e(function(){return e},t)}function ye(){for(var e;e=ce.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Se),t.__h.some(Ce),t.__h=[]}catch(n){t.__h=[],H.__e(n,e.__v)}}}H.__b=function(e){V=null,le&&le(e)},H.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),me&&me(e,t)},H.__r=function(e){ue&&ue(e),B=0;var t=(V=e.__c).__H;t&&(ae===V?(t.__h=[],V.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Se),t.__h.some(Ce),t.__h=[],B=0)),ae=V},H.diffed=function(e){de&&de(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ce.push(t)!==1&&oe===H.requestAnimationFrame||((oe=H.requestAnimationFrame)||xe)(ye)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),ae=V=null},H.__c=function(e,t){t.some(function(e){try{e.__h.some(Se),e.__h=e.__h.filter(function(e){return!e.__||Ce(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],H.__e(n,e.__v)}}),fe&&fe(e,t)},H.unmount=function(e){pe&&pe(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Se(e)}catch(e){t=e}}),n.__H=void 0,t&&H.__e(t,n.__v))};var be=typeof requestAnimationFrame==`function`;function xe(e){var t,n=function(){clearTimeout(r),be&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);be&&(t=requestAnimationFrame(n))}function Se(e){var t=V,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),V=t}function Ce(e){var t=V;e.__c=e.__(),V=t}function we(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Te(e,t){return typeof t==`function`?t(e):t}function Ee(e=globalThis.crypto){if(typeof e?.randomUUID==`function`)return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues==`function`)e.getRandomValues(t);else for(let e=0;ee.toString(16).padStart(2,`0`));return`${n.slice(0,4).join(``)}-${n.slice(4,6).join(``)}-${n.slice(6,8).join(``)}-${n.slice(8,10).join(``)}-${n.slice(10).join(``)}`}var De=15e3;function Oe(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e||{}))r!==``&&r!=null&&t.set(n,r);let n=t.toString();return n?`?${n}`:``}async function ke(e){try{let t=(await e.text()).trim();if(t)return t.split(` +`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Ae=class extends Error{constructor(e,t){super(e),this.status=t}};function je(e){let t=e instanceof Ae?e.status:void 0,n=e?.message||`Action failed`;return t===401?{kind:`session-expired`,message:n}:t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Me(e,t){let n=await fetch(e,t);if(!n.ok)throw new Ae(await ke(n),n.status);return n}async function K(e,{method:t=`GET`,body:n,timeoutMs:r=De,parse:i=!0}={}){let a={Accept:`application/json`},o={method:t,headers:a,signal:AbortSignal.timeout(r)};t!==`GET`&&(a[`Content-Type`]=`application/json`,a[`X-Archie-CSRF`]=`1`),n!==void 0&&(o.body=JSON.stringify(n));let s=await Me(e,o);return i?s.json():void 0}var q={summary:()=>K(`/api/summary`),tasks:()=>K(`/api/tasks`),taskMeta:()=>K(`/api/task-meta`),task:e=>K(`/api/tasks/${e}`),taskAttempts:e=>K(`/api/tasks/${e}/attempts`),taskChanges:(e,t)=>K(`/api/tasks/${e}/changes`+Oe(t)),taskDebug:(e,t)=>K(`/api/tasks/${e}/debug`+Oe(t)),taskAction:(e,t)=>K(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>K(`/api/setup`),capabilities:()=>K(`/api/capabilities`),workflows:()=>K(`/api/workflows`),workRequest:e=>K(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>K(`/api/skills`),channels:()=>K(`/api/channels`),curators:()=>K(`/api/curators`),channelReload:e=>K(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>K(`/api/config`),version:()=>K(`/api/version`),configUpdate:e=>K(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>K(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>K(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>K(`/api/logs`+Oe(e)),taskLogs:(e,t)=>K(`/api/tasks/${e}/logs`+Oe(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>K(`/api/captures`+Oe({limit:e})),mappings:()=>K(`/api/mappings`),mappingCreate:e=>K(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>K(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>K(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>K(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>K(`/api/bindings`),bindingCreate:e=>K(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>K(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>K(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>K(`/api/bindings/${e}/approve`,{method:`POST`}),chatSessions:()=>K(`/api/chat/sessions`),chatMessages:e=>K(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>K(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>K(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>K(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:Ee(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>K(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>K(`/api/chat/update`),chatUpdateDefer:e=>K(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>K(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>K(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>K(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>K(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>Me(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t})};function Ne(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Pe(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function Fe(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var Ie=[{id:`queued`,label:`Queued`,kind:`idle`},{id:`running`,label:`Working`,kind:`info`},{id:`waiting_human`,label:`Waiting for you`,kind:`warn`,needs_you:!0},{id:`pr_open`,label:`In review`,kind:`ok`},{id:`merged`,label:`Merged`,kind:`ok`},{id:`parked`,label:`Parked`,kind:`warn`,needs_you:!0},{id:`dead`,label:`Stopped (too many retries)`,kind:`danger`},{id:`rejected`,label:`Rejected`,kind:`danger`},{id:`closed_wont_do`,label:`Won't do`,kind:`idle`}],Le=[{id:`cancel`,label:`Cancel`,kind:`quiet`,confirm:`Cancel "{title}"? This closes the forge issue.`},{id:`stop`,label:`Stop`,kind:`primary`,confirm:`Stop "{title}"? Recoverable work will remain parked.`},{id:`approve`,label:`Approve`,kind:`primary`},{id:`reject`,label:`Reject`,kind:`quiet`,confirm:`Reject "{title}"? This closes the forge issue.`},{id:`retry`,label:`Retry`,kind:`primary`},{id:`abandon`,label:`Abandon`,kind:`quiet`,confirm:`Abandon "{title}"? This closes the forge issue.`},{id:`archive`,label:`Archive`,kind:`quiet`,confirm:`Archive the local record for "{title}"?`},{id:`open_pr`,label:`Open PR`,kind:`link`},{id:`open_issue`,label:`Open issue`,kind:`link`}],Re=[...Ie],ze=[...Le],Be=new Map(Re.map(e=>[e.id,e])),Ve=new Map(ze.map(e=>[e.id,e]));function He(){Be=new Map(Re.map(e=>[e.id,e])),Ve=new Map(ze.map(e=>[e.id,e]))}async function Ue(){try{let e=await q.taskMeta();Array.isArray(e?.statuses)&&(Re=e.statuses),Array.isArray(e?.actions)&&(ze=e.actions),He()}catch{}}function We(e){return Be.get(e)?.label||e||`Unknown`}function Ge(e){return Be.get(e)?.kind||`idle`}function Ke(){return Re.map(e=>e.id)}function qe(){return new Set(Re.filter(e=>e.needs_you).map(e=>e.id))}function Je(e){return Ve.get(e)||null}var Ye=0;Array.isArray;function J(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:--Ye,__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}var Xe={dashboard:``,chat:``,tasks:``,logs:``,skills:``,workflows:``,memory:``,channels:``,curators:``,captures:``,mappings:``,bindings:``,settings:``,search:``,moon:``,sun:``,refresh:``,bell:``,trendUp:``,trendDown:``,check:``,close:``,"message-circle-plus":``,help:``};function Y({name:e,size:t=18,className:n=``}){return J(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,"stroke-width":`1.6`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,className:`ico ${n}`.trim(),dangerouslySetInnerHTML:{__html:Xe[e]||Xe.dashboard}})}function X(e){if(!e)return`—`;let t=e instanceof Date?e:new Date(e),n=Math.floor((Date.now()-t.getTime())/1e3);if(!Number.isFinite(n))return`—`;if(n<45)return`just now`;let r=[[`min`,60],[`hr`,3600],[`day`,86400],[`wk`,604800]],i=`min`,a=60;for(let[e,t]of r)n>=t&&([i,a]=[e,t]);let o=Math.floor(n/a);return`${o} ${i}${o===1?``:`s`} ago`}function Ze(e){return e==null||Number.isNaN(e)?`—`:new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e)}function Z({label:e,value:t,unit:n,trend:r,compare:i,series:a=[],goodDirection:o=`up`}){let s=r==null?null:r>=0?`up`:`down`,c=s==null?null:s===o;return J(`div`,{className:`card stat`,children:[J(`div`,{className:`stat-head`,children:[J(`span`,{className:`stat-label`,children:e}),s?J(`span`,{className:`stat-trend ${c?`up`:`down`}`,children:[J(Y,{name:s===`up`?`trendUp`:`trendDown`,size:13}),`${Math.abs(r).toFixed(1)}%`]}):null]}),J(`div`,{className:`stat-value`,children:[t,n?J(`span`,{className:`stat-unit`,children:n}):null]}),i?J(`div`,{className:`stat-compare`,children:i}):null,a.length>1?J(Qe,{series:a,stroke:c===!1?`var(--danger)`:`var(--ok)`}):null]})}function Qe({series:e,stroke:t=`var(--ok)`,width:n=220,height:r=34}){let i=Math.max(...e,1),a=Math.min(...e,0),o=i-a||1,s=e.length>1?n/(e.length-1):n,c=e.map((e,t)=>`${(t*s).toFixed(1)},${(r-(e-a)/o*r).toFixed(1)}`).join(` `);return J(`svg`,{className:`spark`,viewBox:`0 0 ${n} ${r}`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:J(`polyline`,{points:c,fill:`none`,stroke:t,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"vector-effect":`non-scaling-stroke`})})}function $e({value:e,label:t,size:n=168}){let r=Math.max(0,Math.min(100,Number(e)||0)),i=r>=90?`var(--ok)`:r>=70?`var(--warn)`:`var(--danger)`,a=n/2,o=n/2,s=2*Math.PI*62*(240/360),c=(e,t)=>{let n=e*Math.PI/180,r=(e+t)*Math.PI/180,i=+(t>180);return[`M ${a+62*Math.cos(n)} ${o+62*Math.sin(n)}`,`A 62 62 0 ${i} 1 ${a+62*Math.cos(r)} ${o+62*Math.sin(r)}`].join(` `)};return J(`div`,{className:`gauge-wrap`,children:[J(`svg`,{className:`gauge`,viewBox:`0 0 ${n} ${n*.78}`,role:`img`,"aria-label":`${t}: ${r}%`,children:[J(`path`,{d:c(150,240),fill:`none`,stroke:`var(--border)`,"stroke-width":`12`,"stroke-linecap":`round`}),J(`path`,{d:c(150,240),fill:`none`,stroke:i,"stroke-width":`12`,"stroke-linecap":`round`,"stroke-dasharray":s,"stroke-dashoffset":s*(1-r/100),className:`gauge-value`})]}),J(`div`,{className:`gauge-center`,children:[J(`div`,{className:`gauge-pct`,children:`${Math.round(r)}%`}),J(`div`,{className:`gauge-label`,children:t})]})]})}function et({segments:e}){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return J(`div`,{children:[J(`div`,{className:`segbar`,children:e.filter(e=>e.value>0).map(e=>J(`span`,{className:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`},e.label))}),J(`div`,{className:`segbar-legend`,children:e.map(e=>J(`span`,{className:`segbar-key`,children:[J(`span`,{className:`segbar-dot segbar-${e.kind||`idle`}`}),e.label]},e.label))})]})}var tt=160;function nt(e){let t=String(e?.detail||e?.message||``);if(!t)return{text:``,full:``,truncated:!1};let n=t.split(` +`).map(e=>e.trim()).find(Boolean)||``,r=n.length>tt?`${n.slice(0,tt).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}function Q({text:e,kind:t=`idle`}){return J(`span`,{className:`pill pill-${t}`,children:e})}var rt=`archie.setup-complete.dismissed.v1`;function it(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(rt),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function at(e=globalThis.localStorage){e?.setItem?.(rt,`1`)}var ot=new Set([`waiting_human`,`parked`]);function st(e=[]){let t=e.filter(e=>ot.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}function ct({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function lt(e,t){return Number(e.task_id)>0?Number(e.task_id):!e.repo||!e.issue?0:Number(t.get(`${e.repo}#${e.issue}`))||0}function ut(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function dt(e){if(e.length<4)return null;let t=Math.floor(e.length/2),n=e.slice(0,t).reduce((e,t)=>e+t,0),r=e.slice(t).reduce((e,t)=>e+t,0);return n?(r-n)/n*100:null}function ft(){let[e,t]=U([]),[n,r]=U(`connecting`),[i,a]=U(`idle`),[o,s]=U(new Map),[c,l]=U(null),[u,d]=U(null),[f,p]=U(null),[m,h]=U(null),[g,_]=U(null),[,v]=U(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([q.summary(),q.setup().catch(()=>null),q.workflows().catch(()=>null),q.tasks().catch(()=>[])]),i=new Map;for(let e of r)e.owner&&e.repo&&e.issue_number&&i.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);s(i),l(e),d(t),p(n),h(r)}catch(e){_(String(e.message||e))}};W(()=>(y(),Ne(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{at(),v(e=>!e)},x=u?.operator?`${ut()}, ${u.operator}`:ut(),C=null;if(g)C=J(`button`,{className:`btn btn-primary`,onClick:y,children:[J(Y,{name:`refresh`,size:15}),` Retry`]});else if(m!==null){let e=st(m),t=e.attention.count,n=e.running.count;C=J(S,{children:[t>0&&J(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[J(Y,{name:`tasks`,size:15}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&J(`a`,{className:`btn`,href:e.running.href,children:[J(Y,{name:`workflows`,size:15}),` `,n,` running`]}),J(`a`,{className:`btn`,href:`#/logs`,children:[J(Y,{name:`logs`,size:15}),` Logs`]}),J(`button`,{className:`btn btn-primary`,onClick:y,children:[J(Y,{name:`refresh`,size:15}),` Refresh`]})]})}let w=null;if(g)w=J(`div`,{className:`card`,children:J(ct,{title:`Cannot reach archied`,detail:g})});else if(c){let e=c?.statuses||{},t=(e.merged||0)+(e.pr_open||0),n=(e.parked||0)+(e.waiting_human||0),r=Object.values(e).reduce((e,t)=>e+t,0),i=c?.tokens_by_day||[];w=J(S,{children:[J(Z,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),J(Z,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),J(Z,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),J(Z,{label:`Tokens used`,value:Ze(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:dt(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let T=null,E=it(u),D=E.kind===`omit`||E.kind===`dismissed`;if(!D){let e=E.remaining;if(e.length){let t=Math.round((u.steps.length-e.length)/u.steps.length*100);T=J(`div`,{className:`card setup`,children:[J(`div`,{className:`card-head`,children:[J(`div`,{children:[J(`h2`,{className:`card-title`,children:`Finish setting up`}),J(`p`,{className:`card-sub`,children:`Archie needs these before it can work on its own.`})]}),J(`span`,{className:`setup-pct`,children:[t,`%`]})]}),J(`div`,{className:`setup-bar`,children:J(`div`,{className:`setup-bar-fill`,style:{width:`${t}%`}})}),J(`ul`,{className:`setup-list`,children:u.steps.map((e,t)=>J(`li`,{className:`setup-step ${e.done?`done`:``}`,children:[J(`span`,{className:`setup-check`,children:e.done?J(Y,{name:`check`,size:12}):``}),J(`div`,{children:[J(`div`,{className:`setup-step-title`,children:e.title}),e.detail&&J(`div`,{className:`setup-step-detail`,children:e.detail})]})]},t))})]})}else T=J(`div`,{className:`card setup setup-done`,children:J(`div`,{className:`card-head`,children:[J(`div`,{children:[J(`h2`,{className:`card-title`,children:`Setup complete`}),J(`p`,{className:`card-sub`,children:`Archie is configured and ready to work.`})]}),J(`div`,{className:`setup-complete-actions`,children:[J(`span`,{className:`setup-pct`,children:J(Y,{name:`check`,size:16})}),J(`button`,{className:`icon-btn setup-dismiss`,type:`button`,title:`Dismiss setup complete`,"aria-label":`Dismiss setup complete`,onClick:b,children:`×`})]})]})})}let O=null;if(c){let e=f?.workflows||[],t=e.reduce((e,t)=>e+(t.runs||0),0),n=e.reduce((e,t)=>e+(t.merged||0)+(t.pr_open||0),0),r=e.reduce((e,t)=>e+(t.parked||0),0);if(!t)O=J(`div`,{className:`card`,children:[J(`div`,{className:`card-head`,children:J(`h2`,{className:`card-title`,children:`Gate pulse`})}),J(ct,{title:`No completed runs yet`,detail:`Once Archie finishes a task, its gate pass rate appears here.`})]});else{let i=n/t*100;O=J(`div`,{className:`card`,children:[J(`div`,{className:`card-head`,children:J(`div`,{children:[J(`h2`,{className:`card-title`,children:`Gate pulse`}),J(`p`,{className:`card-sub`,children:`Work that passed its quality gates`})]})}),J($e,{value:i,label:`pass rate`}),J(`ul`,{className:`pulse-list`,children:[e.slice(0,3).map((e,t)=>J(`li`,{className:`pulse-item`,children:[J(`span`,{className:`pulse-name`,children:e.workflow||`workflow`}),J(Q,{text:`${e.merged||0}/${e.runs||0}`,kind:(e.merged||0)===(e.runs||0)?`ok`:(e.parked||0)>0?`warn`:`info`})]},t)),r>0&&J(`li`,{className:`pulse-item`,children:[J(`span`,{className:`pulse-name`,children:`Parked, awaiting you`}),J(Q,{text:String(r),kind:`warn`})]})]})]})}}let k=null;if(c){let e=c?.tokens_by_day||[],t=e.reduce((e,t)=>e+(t.tokens||0),0);if(!e.length)k=J(`div`,{className:`card`,children:[J(`div`,{className:`card-head`,children:J(`h2`,{className:`card-title`,children:`Token outlook`})}),J(ct,{title:`Nothing spent yet`,detail:`Usage appears here once Archie runs its first task.`})]});else{let n=t/e.length,r=Math.round(n*30),i=e.slice(-7).reduce((e,t)=>e+(t.tokens||0),0);k=J(`div`,{className:`card`,children:[J(`div`,{className:`card-head`,children:J(`div`,{children:[J(`h2`,{className:`card-title`,children:`Token outlook`}),J(`p`,{className:`card-sub`,children:`Next 30 days at the current rate`})]})}),J(`div`,{className:`forecast-value`,children:Ze(r)}),J(`div`,{className:`forecast-note`,children:[`Based on `,Ze(Math.round(n)),` per day over `,e.length,` days`]}),J(et,{segments:[{label:`Last 7 days (${Ze(i)})`,value:i,kind:`info`},{label:`Earlier (${Ze(t-i)})`,value:Math.max(t-i,0),kind:`idle`}]})]})}}return J(S,{children:[J(`div`,{className:`hero`,children:[J(`div`,{children:[J(`h1`,{className:`hero-title`,children:x}),J(`p`,{className:`hero-sub`,children:`Your agent's control room — what it is working on, what needs you, and what it is spending.`})]}),J(`div`,{className:`hero-actions`,children:J(`div`,{className:`hero-actions-inner`,children:C})})]}),J(`div`,{className:`dash-section`,children:[J(`div`,{className:`dash-section-head`,children:J(`h2`,{className:`dash-section-title`,children:`Health`})}),J(`div`,{className:`dash-top ${D?`dash-top-standalone`:``}`,children:[J(`div`,{children:T}),J(`div`,{children:O})]})]}),J(`div`,{className:`dash-section`,children:[J(`div`,{className:`dash-section-head`,children:[J(`h2`,{className:`dash-section-title`,children:`Throughput`}),J(`span`,{className:`dash-section-note`,children:`Across all repositories`})]}),J(`div`,{className:`grid grid-4`,children:w})]}),J(`div`,{className:`dash-section`,children:[J(`div`,{className:`dash-section-head`,children:J(`h2`,{className:`dash-section-title`,children:`Right now`})}),J(`div`,{className:`dash-split`,children:[J(`div`,{children:k}),J(`div`,{className:`card`,children:[J(`div`,{className:`card-head`,children:[J(`div`,{children:[J(`h2`,{className:`card-title`,children:`Live activity`}),J(`p`,{className:`card-sub`,children:`Last 50, newest first`})]}),J(Q,{text:n,kind:i})]}),J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Event`}),J(`th`,{children:`Task`}),J(`th`,{children:`Detail`}),J(`th`,{children:`When`})]})}),J(`tbody`,{children:e.length?e.map((e,t)=>{let n=lt(e,o),r=n>0,i=nt(e),a=()=>{r&&(location.hash=`#/tasks?task=${encodeURIComponent(n)}`)};return J(`tr`,{className:r?`activity-row`:``,role:r?`link`:void 0,tabIndex:r?`0`:void 0,title:r?`Open task details`:void 0,onClick:r?a:void 0,onKeyDown:r?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())}:void 0,children:[J(`td`,{className:`strong`,children:J(`span`,{children:e.kind||e.type||`event`})}),J(`td`,{className:`mono`,children:r?`#${n}`:`—`}),J(`td`,{className:`activity-detail`,children:J(`span`,{title:i.truncated?i.full:void 0,children:i.text})}),J(`td`,{children:X(e.at||Date.now())})]},t)}):J(`tr`,{children:J(`td`,{colSpan:`4`,children:J(ct,{title:`Waiting for activity`,detail:`Events appear here as Archie works.`})})})})]})})]})]})]})]})}function pt(){return J(ft,{})}function mt(e,t){let n=e.title||`untitled task`;return{"aria-expanded":String(t),"aria-controls":`task-timeline-${e.id}`,"aria-label":`${t?`Collapse`:`Expand`} timeline for ${n}`}}function ht(){return new Set([`needs_you`,...Ke()])}function gt(e){let t=e?.get?.(`status`)||``;return ht().has(t)?t:``}function _t(e,t){return t?t===`needs_you`?qe().has(e.status):e.status===t:!0}function vt(e){return String(e||`event`).replaceAll(`_`,` `).replace(/\b\w/g,e=>e.toUpperCase())}function yt(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return``;if(t<1e3)return`${Math.round(t)} ms`;let n=t/1e3;if(n<60)return`${n.toFixed(+(n<10))} s`;let r=Math.round(n),i=Math.floor(r/60),a=r%60;if(i<60)return a===0?`${i} min`:`${i} min ${a} s`;let o=Math.floor(i/60),s=i-o*60;return s===0?`${o} h`:`${o} h ${s} min`}function bt(e){let t=Number(e);return!Number.isFinite(t)||t<=0?``:t.toLocaleString(`en-US`)}function xt(e={}){let t=e.data||{},n=e.stage||`unknown stage`,r=e.workflow?`${e.workflow} workflow`:``;if(e.kind===`stage_start`)return{title:`Started stage: ${n}`,detail:r};if(e.kind===`stage_finish`){let e=yt(t.duration_ms),i=[r,e&&`ran for ${e}`].filter(Boolean).join(` · `);return{title:t.interrupted?`Stage interrupted: ${n}`:t.error?`Stage failed: ${n}`:`Finished stage: ${n}`,detail:[i,t.error].filter(Boolean).join(` — `)}}if(e.kind===`task_retried`){let n=Number(t.retry_count);return{title:Number.isFinite(n)&&n>0?`Retry ${n}`:`Retry requested`,detail:[t.previous_stage&&`after ${t.previous_stage}`,t.previous_reason].filter(Boolean).join(`: `)||e.detail||``}}if(e.kind===`agent_finish`){let r=bt(t.iterations),i=bt(t.tokens),a=Number(t.cached_tokens)||0,o=bt((Number(t.prompt_tokens)||0)-a),s=bt(t.completion_tokens),c=bt(t.cached_tokens),l=[r&&`${r} iterations`,i&&`${i} tokens`,o&&`${o} fresh prompt`,s&&`${s} completion`,c&&`${c} cached`,t.model].filter(Boolean);return{title:`Agent ${t.status||`finished`}: ${n}`,detail:l.join(` · `)||e.detail||``}}if(e.kind===`config_captured`)return{title:`Configuration captured`,detail:`The effective task-runtime configuration for this run.`};if(e.kind===`changes_captured`){let e=Number(t.totals?.files);return{title:`Change capture recorded`,detail:[Number.isFinite(e)&&e>0?`${e} file${e===1?``:`s`} changed`:``,t.captured_after?`captured after ${t.captured_after}`:``].filter(Boolean).join(` · `)}}return{title:vt(e.kind||e.type),detail:e.detail||``}}var St=[{value:``,label:`All levels`},{value:`ERROR`,label:`Errors`},{value:`WARN,ERROR`,label:`Warnings and errors`},{value:`INFO,WARN,ERROR`,label:`Info and above`},{value:`DEBUG`,label:`Debug only`}];function Ct(e){switch((e||``).toUpperCase()){case`ERROR`:return`danger`;case`WARN`:return`warn`;case`DEBUG`:return`idle`;default:return`info`}}function wt({entry:e}){let t=e.fields||{};return J(`div`,{className:`log-row log-${Ct(e.level)}`,children:[J(`span`,{className:`log-time mono`,children:Et(e.time)}),J(`span`,{className:`log-level`,children:(e.level||`info`).toUpperCase()}),J(`span`,{className:`log-body`,children:[J(`span`,{className:`log-msg`,children:e.message||e.msg||``}),Object.entries(t).map(([e,t])=>J(`span`,{className:`log-field`,children:[J(`span`,{className:`log-field-key`,children:e}),String(Tt(t))]},e))]})]})}function Tt(e){return e==null?``:typeof e==`object`?JSON.stringify(e):e}function Et(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`--:--:--`:t.toTimeString().slice(0,8)}function Dt(e,t){return`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`)}var Ot={level:``,stage:``};function kt(e,t,n=Ot){let r=n||Ot;return[e,Number(t)||0,r.level||``,r.stage||``].join(`|`)}function At({filters:e,onFilterChange:t,stages:n,attempt:r}){let i=n=>t?.({...e,...n}),a=Number(r)||0;return J(`div`,{className:`log-filters task-log-filters`,children:[J(`span`,{className:`task-log-attempt`,children:a>0?`Attempt ${a}`:`Current attempt`}),t?J(S,{children:[J(`label`,{className:`task-log-filter`,children:[J(`span`,{className:`task-log-filter-label`,children:`Level`}),J(`select`,{className:`task-filter`,value:e.level,"aria-label":`Filter log entries by level`,onChange:e=>i({level:e.target.value}),children:St.map(e=>J(`option`,{value:e.value,children:e.label},e.value))})]}),J(`label`,{className:`task-log-filter`,children:[J(`span`,{className:`task-log-filter-label`,children:`Stage`}),J(`select`,{className:`task-filter`,value:e.stage,"aria-label":`Filter log entries by stage`,onChange:e=>i({stage:e.target.value}),children:[J(`option`,{value:``,children:`All stages`}),(n||[]).map(e=>J(`option`,{value:e,children:e},e))]})]}),e.stage?J(`p`,{className:`task-log-filter-note`,children:`A stage filter matches only log lines that record a stage. Agent and tool output carries none, so it is not shown while this filter is set.`}):null,!e.stage&&!(n||[]).length?J(`p`,{className:`task-log-filter-note`,children:`This attempt recorded no stage names, so the stage filter has nothing to match.`}):null]}):null]})}function jt({text:e}){return J(`p`,{className:`visually-hidden`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:e})}function Mt({state:e,onRetry:t,taskId:n,attempt:r,filters:i=Ot,onFilterChange:a,stages:o=[]}){let s=Number(r)||Number(e?.attempt)||0,c,l;if(e===void 0)c=`Loading this attempt's log`,l=J(`div`,{className:`task-log-loading`,children:`Loading attempt log…`});else if(e===null)c=`This attempt's log could not be loaded`,l=J(`div`,{className:`task-log-error`,children:[J(`div`,{className:`task-timeline-detail`,children:`Could not load this attempt's log.`}),J(`button`,{className:`btn`,onClick:t,children:`Retry`})]});else if(e.found===!1&&!e.disabled)c=`No log recorded for this attempt`,l=J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:`No log recorded for this attempt`}),J(`div`,{children:`This attempt produced no output, or it has not started writing yet.`})]});else if(e.disabled)c=`This dashboard cannot read task logs`,l=J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:`No persisted log for this attempt`}),J(`div`,{children:`This dashboard cannot read task logs. The service that owns the log files is not reporting a log reader.`})]});else{let t=e.entries||[],r=n==null?null:Dt(n,s||null),i=r?J(`a`,{className:`btn btn-small task-log-download`,href:r,download:!0,children:`Download log`}):null;t.length?(c=`${t.length} log entr${t.length===1?`y`:`ies`} shown`,l=J(S,{children:[J(`div`,{className:`log-list task-log-list`,children:t.map((e,t)=>J(wt,{entry:e},t))}),i]})):(c=`This attempt's log has no entries matching the current filter`,l=J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:`Nothing recorded`}),J(`div`,{children:`This attempt's log file has no entries matching the current filter.`}),i]}))}return J(S,{children:[J(At,{filters:i,onFilterChange:a,stages:o,attempt:s}),J(jt,{text:c}),l]})}function Nt(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0}function Pt(){return Nt()?`auto`:`smooth`}function Ft({kind:e,message:t}){return e===`session-expired`?J(`span`,{className:`task-action-error task-action-error-session`,children:[`Your session has expired.`,` `,J(`button`,{className:`button btn btn-small`,type:`button`,onClick:()=>window.location.reload(),children:`Reload to sign in`})]}):e===`refused`?J(`span`,{className:`task-action-error task-action-error-refused`,children:[t,` — you can't do that.`]}):J(`span`,{className:`task-action-error task-action-error-broken`,children:[t,` — try again, or check the daemon.`]})}function It({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function Lt({taskId:e,attempt:t,state:n,onLoad:r,onRetry:i}){let a=G(r);return a.current=r,W(()=>{n===void 0&&a.current()},[n]),J(Mt,{state:n,taskId:e,attempt:t,onRetry:i})}function Rt({query:e}){let[t,n]=U(null),[r,i]=U(null),[a,o]=U(()=>gt(e)),[s,c]=U(``),l=Number(e.get(`task`)),u=Number.isFinite(l)&&l>0?l:null,[d,f]=U(u),[p,m]=U(u!==null),[h,g]=U(new Map),[_,v]=U(new Map),y=G(new Set),[b,x]=U(new Set),[C,w]=U(new Map),[T,E]=U(new Set),D=async()=>{try{i(null);let e=await q.tasks();return n(e),d&&e.some(e=>String(e.id)===String(d))&&(h.has(d)||O(d)),e}catch(e){return i(String(e.message||e)),n(null),null}};W(()=>{D()},[]);let O=async e=>{try{let t=await q.task(e);g(n=>new Map(n).set(e,t||[]))}catch{g(t=>new Map(t).set(e,null))}},k=async(e,t,{force:n=!1}={})=>{let r=kt(e,t);if(!(y.current.has(r)&&!n)){y.current.add(r),n&&v(e=>{let t=new Map(e);return t.delete(r),t});try{let n=await q.taskLogs(e,{attempt:t||void 0,limit:500});v(e=>new Map(e).set(r,n))}catch{v(e=>new Map(e).set(r,null))}}},A=e=>{g(t=>{let n=new Map(t);return n.delete(e),n})},j=async(e,t)=>{w(t=>{let n=new Map(t);return n.delete(e),n}),E(t=>new Set(t).add(e));try{await q.taskAction(e,t),E(t=>{let n=new Set(t);return n.delete(e),n}),t===`archive`&&f(null),A(e);let n=await D();Array.isArray(n)&&n.find(t=>String(t.id)===String(e))&&d===e&&O(e)}catch(t){E(t=>{let n=new Set(t);return n.delete(e),n}),w(n=>new Map(n).set(e,je(t)))}};W(()=>{p&&d&&t&&(m(!1),requestAnimationFrame(()=>{let e=document.getElementById(`task-row-${d}`);e&&(e.focus({preventScroll:!0}),e.scrollIntoView?.({block:`center`,behavior:Pt()}))}))},[p,d,t]);let M=(e,t)=>{t&&t.stopPropagation();let n=d!==e;f(n?e:null),n&&O(e)},N=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},P=()=>{if(!t)return null;let e=t.length,n={};for(let e of t)n[e.status]=(n[e.status]||0)+1;let r=n.running||0,i=(n.waiting_human||0)+(n.parked||0),a=(n.merged||0)+(n.pr_open||0);return J(`div`,{className:`grid grid-4 task-summary`,children:[J(Z,{label:`Total tasks`,value:e,compare:e?`Everything archied has ever picked up`:`No tasks yet`}),J(Z,{label:`Working now`,value:r,compare:e?`${r} of ${e} in progress`:`Nothing running`}),J(Z,{label:`Needs you`,value:i,compare:i?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),J(Z,{label:`Delivered`,value:a,compare:e?`${Math.round(a/e*100)}% of all tasks`:`No tasks yet`})]})},F=e=>{let t=C.get(e.id),n=t?Ft(t):null,r=T.has(e.id),i=e=>e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``,a=(e.actions||[]).map(t=>{let n=Je(t);if(!n)return null;let a=e.title||`this task`,o=n.confirm?n.confirm.replaceAll(`{title}`,a):void 0,s=[`button`,`btn`,`btn-small`,i(n.kind)].filter(Boolean).join(` `);if(n.kind===`link`){if(t===`open_pr`)return I(e,`pull_request`,e.pr_number,n.label);if(t===`open_issue`)return I(e,`issue`,e.issue_number,n.label)}return J(`button`,{className:s,type:`button`,disabled:r,onClick:n=>{n.stopPropagation(),!(o&&!window.confirm(o))&&j(e.id,t)},children:n.label},t)}).filter(Boolean);return!a.length&&!n?`—`:J(`div`,{className:`task-actions`,children:[n,a]})},I=(e,t,n,r)=>{let i=t===`issue`?e.issue_url:e.pr_url;return!i||!n||t===`issue`&&e.source===`chat`?J(`button`,{className:`btn btn-small`,type:`button`,disabled:!0,title:`${r} is unavailable`,children:r}):J(`a`,{className:`btn btn-small`,href:i,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:r})},L=e=>{let t=e.repo_url;return t?J(`a`,{className:`task-source-link`,href:t,target:`_blank`,rel:`noreferrer`,title:`Open ${e.owner}/${e.repo} on the forge`,onClick:e=>e.stopPropagation(),children:[e.owner,`/`,e.repo]}):null},ee=e=>{let t=e.issue_url;return e.source===`chat`||!t||!e.issue_number?null:J(`a`,{className:`task-source-link`,href:t,target:`_blank`,rel:`noreferrer`,title:`Open issue #${e.issue_number} on the forge`,onClick:e=>e.stopPropagation(),children:[`#`,e.issue_number]})},R=e=>{let t=kt(e.id,e.attempt),n=h.get(e.id),r=b.has(e.id);return J(`tr`,{className:`task-timeline-row`,id:`task-timeline-${e.id}`,children:J(`td`,{colSpan:8,children:[J(`div`,{className:`task-detail-actions`,children:[J(`div`,{className:`task-decision-title`,children:`Available actions`}),F(e)]}),e.status===`waiting_human`&&e.plan&&J(`div`,{className:`task-decision`,children:[J(`div`,{className:`task-decision-title`,children:`Decision required`}),J(`div`,{className:`task-decision-plan`,children:e.plan})]}),e.status===`parked`&&e.park_reason&&J(`div`,{className:`task-decision`,children:[J(`div`,{className:`task-decision-title`,children:`Park reason`}),J(`div`,{className:`task-decision-plan`,children:e.park_reason})]}),n===void 0?J(`div`,{className:`task-timeline-loading`,children:`Loading timeline…`}):n===null?J(`div`,{className:`task-timeline-error`,children:[J(`div`,{className:`task-timeline-title`,children:`Could not load timeline`}),J(`div`,{className:`task-timeline-detail`,children:`archied did not answer for this task's events. It may be restarting — retry, or check the daemon.`}),J(`button`,{className:`btn`,onClick:()=>O(e.id),children:`Retry`})]}):n.length?J(`ul`,{className:`task-timeline`,children:n.map((e,t)=>{let n=xt(e);return J(`li`,{className:`task-timeline-entry`,children:[J(`span`,{className:`task-timeline-dot`}),J(`div`,{children:[J(`div`,{className:`task-timeline-kind`,children:n.title}),n.detail&&J(`div`,{className:`task-timeline-detail`,children:n.detail}),J(`div`,{className:`task-timeline-when`,children:X(e.at)})]})]},t)})}):J(It,{title:`No events yet`,detail:`This task has not recorded any transitions.`}),J(`div`,{className:`task-logs-section`,children:[J(`div`,{className:`task-decision-title`,children:[`Attempt log`,J(`button`,{className:`btn btn-small`,onClick:()=>N(e.id),style:{marginLeft:`10px`},children:r?`Hide`:`Show`})]}),r&&J(Lt,{taskId:e.id,attempt:e.attempt,state:_.has(t)?_.get(t):void 0,onLoad:()=>k(e.id,e.attempt),onRetry:()=>k(e.id,e.attempt,{force:!0})})]})]})})};return J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Tasks`}),J(`p`,{className:`page-sub`,children:`Every issue archied has picked up, and where it stands.`})]}),J(`div`,{className:`page-actions`,children:J(`button`,{className:`btn`,onClick:D,children:`Refresh`})})]}),r?J(`div`,{className:`grid grid-4 task-summary`,children:J(`div`,{className:`card`,children:J(It,{title:`Cannot reach archied`,detail:r})})}):P(),J(`div`,{className:`card`,children:[J(`div`,{className:`card-head`,children:[J(`div`,{children:[J(`h2`,{className:`card-title`,children:`All tasks`}),J(`p`,{className:`card-sub`,children:`Click a row for its timeline`})]}),J(`div`,{className:`task-filters`,children:[J(`input`,{className:`task-search`,type:`search`,placeholder:`Search by title or repo…`,value:s,onInput:e=>c(e.target.value.trim().toLowerCase())}),J(`select`,{className:`task-filter`,value:a,onChange:e=>o(e.target.value),children:[J(`option`,{value:``,children:`All statuses`}),J(`option`,{value:`needs_you`,children:`Needs you`}),Ke().map(e=>J(`option`,{value:e,children:We(e)},e))]})]})]}),J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[`Repo`,`Issue`,`Title`,`Status`,`Workflow`,`Stage`,`Last activity`,`Action`].map(e=>J(`th`,{children:e},e))})}),J(`tbody`,{children:(()=>{if(r)return J(`tr`,{children:J(`td`,{colSpan:8,children:J(It,{title:`Cannot reach archied`,detail:r})})});if(!t)return J(`tr`,{children:J(`td`,{colSpan:8,children:J(`div`,{className:`task-timeline-loading`,children:`Loading tasks...`})})});if(!t.length)return J(`tr`,{children:J(`td`,{colSpan:8,children:J(It,{title:`No tasks yet`,detail:`Tasks appear here once archied picks up an issue to work.`})})});let e=t.filter(e=>_t(e,a)?!s||`${e.title} ${e.repo}`.toLowerCase().includes(s):!1);return e.length?e.map(e=>{let t=d===e.id,n=`task-timeline-${e.id}`;return J(S,{children:[J(`tr`,{className:`task-row`,id:`task-row-${e.id}`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),M(e.id,t))},onClick:t=>M(e.id,t),...mt(e,t),children:[J(`td`,{className:`mono`,"data-label":`Repository`,children:[J(`button`,{className:`task-expand`,type:`button`,"aria-expanded":String(t),"aria-controls":n,"aria-label":`${t?`Collapse`:`Expand`} timeline for ${e.title||`untitled task`}`,onClick:t=>M(e.id,t),children:t?`−`:`+`}),L(e)??`${e.owner}/${e.repo}`]}),J(`td`,{className:`mono`,"data-label":`Issue`,children:ee(e)??`#${e.issue_number}`}),J(`td`,{className:`strong`,"data-label":`Title`,children:J(`a`,{className:`task-detail-link`,href:`#/tasks/${e.id}`,title:`Open the run detail for this task`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:e.title||`(untitled)`})}),J(`td`,{"data-label":`Status`,children:J(Q,{text:We(e.status),kind:Ge(e.status)})}),J(`td`,{"data-label":`Workflow`,children:e.workflow||`—`}),J(`td`,{"data-label":`Stage`,children:e.stage||`—`}),J(`td`,{"data-label":`Last activity`,title:e.created_at?`Created ${X(e.created_at)}`:``,children:X(e.updated_at)}),J(`td`,{"data-label":`Actions`,children:F(e)})]}),t&&R(e)]},e.id)}):J(`tr`,{children:J(`td`,{colSpan:8,children:J(It,{title:`No matching tasks`,detail:`Try a different search or status filter.`})})})})()})]})})]})]})}function zt(e){return J(Rt,{query:e})}function Bt(e,t){return`${e}-tab-${t}`}function Vt(e,t){return`${e}-panel-${t}`}function Ht({tabs:e,active:t,onSelect:n,prefix:r=`run`,label:i=`Run detail views`}){let a=G([]),o=t=>{let r=e[t];r&&(n?.(r.id),a.current[t]?.focus?.())};return J(`div`,{className:`tab-bar`,role:`tablist`,"aria-label":i,onKeyDown:n=>{let r=e.findIndex(e=>e.id===t);if(r<0)return;let i;if(n.key===`ArrowRight`)i=(r+1)%e.length;else if(n.key===`ArrowLeft`)i=(r-1+e.length)%e.length;else if(n.key===`Home`)i=0;else if(n.key===`End`)i=e.length-1;else return;n.preventDefault(),o(i)},children:e.map((e,i)=>{let o=e.id===t;return J(`button`,{ref:e=>{a.current[i]=e},id:Bt(r,e.id),className:`tab${o?` is-selected`:``}`,type:`button`,role:`tab`,"aria-selected":o,"aria-controls":Vt(r,e.id),tabIndex:o?0:-1,onClick:()=>n?.(e.id),children:e.label},e.id)})})}var Ut={ok:{label:`ok`,kind:`ok`},failed:{label:`failed`,kind:`danger`},interrupted:{label:`interrupted`,kind:`warn`},running:{label:`running`,kind:`info`},unknown:{label:`unknown`,kind:`idle`}};function Wt(e){return Ut[e]||{label:e||`unknown`,kind:`idle`}}function Gt(e,t,n){return(e||[]).filter(e=>e&&e.kind===`agent_finish`&&Number(e.attempt)===Number(t)&&(e.stage||``)===(n||``)).map(e=>xt(e))}function Kt(e){let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?`start time not recorded`:`started ${t.toISOString().replace(`T`,` `).slice(0,16)} UTC`}function qt({stage:e,attemptNumber:t,events:n}){let r=Wt(e.status),i=yt(e.duration_ms),a=Gt(n,t,e.name);return J(`li`,{className:`run-stage`,"data-status":e.status||`unknown`,children:[J(`span`,{className:`run-stage-node`,"aria-hidden":`true`}),J(`div`,{className:`run-stage-body`,children:[J(`div`,{className:`run-stage-head`,children:[J(`span`,{className:`run-stage-name mono`,children:e.name||`(unnamed stage)`}),J(Q,{text:r.label,kind:r.kind}),J(`span`,{className:`run-stage-duration`,children:i?`ran for ${i}`:`duration not recorded`})]}),e.error?J(`div`,{className:`run-stage-error`,children:e.error}):null,a.map((e,t)=>J(`div`,{className:`run-agent-report`,children:[J(`span`,{className:`run-agent-report-label`,children:`Agent's own report, not verified by archie: `}),[e.title,e.detail].filter(Boolean).join(` · `)]},t))]})]})}function Jt({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function Yt({count:e}){let t=Number(e)||0;return t?J(`p`,{className:`run-rail-note`,children:[t,` event`,t===1?``:`s`,` on this task predate attempt attribution and cannot be assigned to a run.`]}):null}function Xt({state:e,attemptNumber:t,events:n,onRetry:r}){if(e===void 0)return J(`div`,{className:`run-loading`,children:`Loading this task's attempts…`});if(e===null)return J(`div`,{className:`run-error`,children:[J(`div`,{className:`run-error-title`,children:`Could not load this task's attempts`}),J(`div`,{className:`run-error-detail`,children:`archied did not answer for this task's run history. It may be restarting — retry, or check the daemon.`}),r?J(`button`,{className:`btn`,type:`button`,onClick:r,children:`Retry`}):null]});let i=e?.attempts||[];if(!i.length)return J(S,{children:[J(Jt,{title:`No attempts recorded`,detail:`This task has no recorded run. An attempt is written when a stage event is emitted, and none exist here.`}),J(Yt,{count:e?.unattributed_events})]});let a=i.find(e=>Number(e.attempt)===Number(t));if(!a)return J(S,{children:[J(Jt,{title:`Attempt ${t} is not recorded for this task`,detail:`This task recorded attempt ${i.map(e=>e.attempt).join(`, `)}.`}),J(Yt,{count:e?.unattributed_events})]});let o=a.stages||[],s=Wt(a.status);return J(`div`,{className:`run-rail`,children:[J(`div`,{className:`run-rail-head`,children:[J(`span`,{className:`run-rail-attempt`,children:[`Attempt `,a.attempt]}),J(Q,{text:s.label,kind:s.kind}),J(`span`,{className:`run-rail-when`,children:Kt(a.started_at)})]}),o.length?J(`ol`,{className:`run-stages`,"aria-label":`Stages recorded in attempt ${a.attempt}`,children:o.map((e,t)=>J(qt,{stage:e,attemptNumber:a.attempt,events:n},`${e.seq??t}:${e.name}`))}):J(Jt,{title:`No stages recorded for this attempt`,detail:`The attempt exists, but nothing recorded a stage for it.`}),J(`p`,{className:`run-rail-legend`,children:[J(`strong`,{children:`ok`}),` means the stage returned without error. Archie records no exit code and does not verify that the work was correct, so this is a progress status, not a check result.`]}),J(Yt,{count:e?.unattributed_events})]})}var Zt={added:`Added`,modified:`Modified`,deleted:`Deleted`,renamed:`Renamed`,typechange:`Type changed`};function Qt(e){return Zt[e]||e||`unknown`}function $t(e,t){let n=e?.repo_url||t?.repo_url||``,r=t&&String(t.pr_number??``)!==``&&String(t.pr_number)===String(e?.pr_number??``);return{repo:n,pr:e?.pr_url||r&&t.pr_url||``}}function en(e={}){let t=Number(e.files)||0,n=[`${t} file${t===1?``:`s`}`];return e.additions&&n.push(`+${e.additions}`),e.deletions&&n.push(`−${e.deletions}`),n.join(` · `)}function tn({capture:e}){let t=e.files||[],n=Number(e.totals?.files)||t.length;return t.length?J(S,{children:[J(`table`,{className:`table run-changes-table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Path`}),J(`th`,{children:`Change`}),J(`th`,{className:`run-changes-count`,children:`Added`}),J(`th`,{className:`run-changes-count`,children:`Deleted`})]})}),J(`tbody`,{children:t.map((e,t)=>J(`tr`,{children:[J(`td`,{className:`mono run-changes-path`,children:[e.old_path?J(`span`,{className:`run-changes-old`,children:[e.old_path,` → `]}):null,e.path]}),J(`td`,{children:[Qt(e.status),e.binary?J(`span`,{className:`run-changes-hint`,children:`no textual hunks`}):null]}),J(`td`,{className:`run-changes-count mono`,children:e.additions?`+${e.additions}`:`—`}),J(`td`,{className:`run-changes-count mono`,children:e.deletions?`−${e.deletions}`:`—`})]},`${e.path}:${t}`))})]}),e.truncated?J(`p`,{className:`run-changes-note`,children:[`Showing the first `,t.length,` of `,n,` files. The totals above cover every file in this capture.`]}):null]}):J(`div`,{className:`run-changes-empty`,children:[`This capture recorded no file entries`,n?`, though its totals cover ${n} file${n===1?``:`s`}`:``,`.`]})}function nn({capture:e,task:t}){let n=$t(e,t),r=e.pr_number;return J(`section`,{className:`run-capture`,children:[J(`div`,{className:`run-capture-head`,children:[J(`span`,{className:`run-capture-when`,children:[e.captured_after?`Captured after ${e.captured_after}`:`Captured`,e.stage?` in stage ${e.stage}`:``]}),J(`span`,{className:`run-capture-at`,children:e.captured_at?X(e.captured_at):``})]}),J(`div`,{className:`run-capture-meta`,children:[J(`span`,{className:`mono`,children:n.repo?J(`a`,{className:`run-capture-link`,href:n.repo,target:`_blank`,rel:`noreferrer`,children:[e.owner,`/`,e.repo]}):`${e.owner||``}/${e.repo||``}`}),e.branch?J(`span`,{className:`mono run-capture-branch`,children:[e.branch,e.base?` → ${e.base}`:``]}):null,e.head_sha?J(`span`,{className:`mono run-capture-sha`,children:String(e.head_sha).slice(0,8)}):null,r?n.pr?J(`a`,{className:`run-capture-link`,href:n.pr,target:`_blank`,rel:`noreferrer`,children:[`PR #`,r]}):J(`span`,{className:`mono`,children:[`PR #`,r]}):null,J(`span`,{className:`run-capture-totals`,children:en(e.totals)})]}),J(tn,{capture:e})]})}function rn({state:e,task:t,onRetry:n}){if(e===void 0)return J(`div`,{className:`run-loading`,children:`Loading changed files…`});if(e===null)return J(`div`,{className:`run-error`,children:[J(`div`,{className:`run-error-title`,children:`Could not load this attempt's changed files`}),J(`div`,{className:`run-error-detail`,children:`archied did not answer for this attempt. It may be restarting — retry, or check the daemon.`}),n?J(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]});let r=e.captures||[];return e.found===!0&&!r.length?J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:`A change capture was recorded but could not be read`}),J(`div`,{children:`This attempt has a change capture event, but this dashboard could not decode its payload. That is a read failure, not a statement about what the attempt changed.`})]}):!e.found||!r.length?J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:`No change capture was recorded for this attempt`}),J(`div`,{children:`Archie records what an attempt changed when it commits or pushes that work. Nothing was recorded here — the attempt may predate capture, or it produced no commit. This is not the same as "no files changed".`})]}):J(`div`,{className:`run-changes`,children:r.map((e,n)=>J(nn,{capture:e,task:t},`${e.captured_at||``}:${n}`))})}function an(e,t){return(e||[]).find(e=>e&&e.kind===`config_captured`&&Number(e.attempt)===Number(t))||null}function on({events:e,attempt:t,onRetry:n}){if(e===void 0)return J(`div`,{className:`run-loading`,children:`Loading this task's events…`});if(e===null)return J(`div`,{className:`run-error`,children:[J(`div`,{className:`run-error-title`,children:`Could not load this task's events`}),J(`div`,{className:`run-error-detail`,children:`The configuration is recorded as an event on the task, so it cannot be shown while the event stream is unreadable. archied did not answer — retry, or check the daemon.`}),n?J(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]});let r=an(e,t);if(!r)return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:`Not captured for this run`}),J(`div`,{children:[`Archie records the effective configuration when it dispatches an attempt. Attempt `,t,` `,`has no such record — it predates the record, or the capture did not run. Nothing here says the run used the defaults.`]})]});let i=r.data||{},a=i.schema||``,o=i.document;return J(`div`,{className:`run-config`,children:[J(`p`,{className:`run-config-scope`,children:[`This is attempt `,r.attempt,`'s effective task-runtime configuration: a non-secret subset covering bot identity, models, limits, budgets, dispatch, diff cap, notifications, forge host and tool policy. It is not the dashboard configuration view — providers, repositories, identities, credentials and lock state are not part of it.`]}),J(`div`,{className:`run-config-when`,children:[`Captured `,r.at||`at an unrecorded time`,r.stage?` in stage ${r.stage}`:``]}),a===`archie/task-config@1`?J(`pre`,{className:`run-json`,children:JSON.stringify(o??{},null,2)}):J(S,{children:[J(`div`,{className:`run-config-unknown`,children:[`Recorded in an unknown schema`,a?` (${a})`:``,`. The raw payload is shown verbatim; nothing here reinterprets it.`]}),J(`pre`,{className:`run-json`,children:JSON.stringify(i,null,2)})]})]})}function sn({state:e,attempt:t,onRetry:n}){return e===void 0?J(`div`,{className:`run-loading`,children:`Loading the stored record…`}):e===null?J(`div`,{className:`run-error`,children:[J(`div`,{className:`run-error-title`,children:`Could not load the stored record`}),J(`div`,{className:`run-error-detail`,children:`archied did not answer for this task's debug view. It may be restarting — retry, or check the daemon.`}),n?J(`button`,{className:`btn`,type:`button`,onClick:n,children:`Retry`}):null]}):J(`div`,{className:`run-debug`,children:[J(`p`,{className:`run-debug-note`,children:[`The stored task record and its events, verbatim. Events are unfiltered on purpose: this is every event the task has, and each one carries the attempt it belongs to. Attempt `,t,` `,`is the one selected above.`]}),J(`pre`,{className:`run-json`,children:JSON.stringify(e,null,2)})]})}var cn=[{id:`stages`,label:`Stages`},{id:`log`,label:`Log`},{id:`changes`,label:`Changed files`},{id:`config`,label:`Configuration`},{id:`debug`,label:`Debug`}],ln=`run`,un=new Set(cn.map(e=>e.id));function dn(e){let t=String(e??``).trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return Number.isSafeInteger(n)&&n>0?n:null}function fn(e){let t=e?.get?.(`tab`)||``;return un.has(t)?t:cn[0].id}function pn(e){let t=e?.get?.(`attempt`);if(t==null||t===``)return null;let n=Number(t);return Number.isInteger(n)&&n>0?n:null}function mn(e,t,n){let r=new URLSearchParams;return r.set(`tab`,t||cn[0].id),n&&r.set(`attempt`,String(n)),`#/tasks/${e}?${r.toString()}`}function hn(e,t,n){try{window.history.replaceState(null,``,`${location.pathname}${location.search}${mn(e,t,n)}`)}catch{}}function gn(e,t){return`${e}|${Number(t)||0}`}function _n({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function vn({id:e}){return J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Task not found`}),J(`p`,{className:`page-sub`,children:[`No task with id `,e,` in this deployment.`]})]}),J(`div`,{className:`page-actions`,children:J(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`})})]}),J(`div`,{className:`card`,children:J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:[`Nothing is recorded for task `,e]}),J(`div`,{children:`archied answered that this task does not exist, so there is no run history to show.`})]})})]})}function yn({raw:e}){return J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Not a task id`}),J(`p`,{className:`page-sub`,children:`The run view addresses one task by its id: #/tasks/42`})]}),J(`div`,{className:`page-actions`,children:J(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`})})]}),J(`div`,{className:`card`,children:J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:[`“`,e,`” is not a task id`]}),J(`div`,{children:`A task id is a positive whole number. Nothing was requested.`})]})})]})}function bn({attempts:e,selected:t,onSelect:n}){let r=e?.attempts||[];return r.length?J(`div`,{className:`run-attempts`,role:`group`,"aria-label":`Attempts of this task`,children:r.map(e=>{let r=Wt(e.status),i=Number(e.attempt)===Number(t);return J(`button`,{type:`button`,className:`run-attempt${i?` is-selected`:``}`,"aria-pressed":i,onClick:()=>n(e.attempt),children:[J(`span`,{className:`run-attempt-id`,children:[`Attempt `,e.attempt]}),J(Q,{text:r.label,kind:r.kind}),J(`span`,{className:`run-attempt-meta`,children:[(e.stages||[]).length,` stage`,(e.stages||[]).length===1?``:`s`]})]},e.attempt)})}):null}function xn({id:e,query:t}){let[n,r]=U(()=>fn(t)),[i,a]=U(()=>pn(t)),[o,s]=U(void 0),[c,l]=U(void 0),[u,d]=U(!1),[f,p]=U(void 0),[m,h]=U(Ot),[g,_]=U(new Map),[v,y]=U(new Map),[b,x]=U(new Map),[S,C]=U(!1),[w,T]=U(null),[E,D]=U(0),O=G(new Set),k=Array.isArray(o)&&o.find(t=>String(t.id)===String(e))||null,A=Number(c?.current_attempt)>0?Number(c.current_attempt):null,j=i??A,M=(c?.attempts||[]).find(e=>Number(e.attempt)===Number(j)),N=[...new Set((M?.stages||[]).map(e=>e.name).filter(Boolean))],P=(e,t,n,{force:r=!1}={})=>{O.current.has(e)&&!r||(O.current.add(e),n(t=>new Map(t).set(e,void 0)),t().then(t=>n(n=>new Map(n).set(e,t))).catch(()=>n(t=>new Map(t).set(e,null))))},F=()=>{s(void 0),q.tasks().then(e=>s(e)).catch(()=>s(null))},I=()=>{l(void 0),d(!1),q.taskAttempts(e).then(e=>l(e)).catch(e=>{e?.status===404&&d(!0),l(null)})},L=()=>{p(void 0),q.task(e).then(e=>p(e||[])).catch(()=>p(null))},ee=(t,n)=>P(kt(e,t,m),()=>q.taskLogs(e,{attempt:t||void 0,level:m.level,stage:m.stage,limit:500}),_,n),R=(t,n)=>P(gn(e,t),()=>q.taskChanges(e,{attempt:t}),y,n),te=(t,n)=>P(gn(e,t),()=>q.taskDebug(e,{attempt:t}),x,n),z=()=>{O.current=new Set,_(new Map),y(new Map),x(new Map),F(),I(),L(),D(e=>e+1)};W(()=>{F(),I(),L()},[]),W(()=>{j!=null&&(n===`log`?ee(j):n===`changes`?R(j):n===`debug`&&te(j))},[n,j,m,E]),W(()=>{hn(e,n,j)},[e,n,j]);let ne=async()=>{let t=k?.title||`task ${e}`;if(window.confirm(`Start a new run for "${t}"? This is a new attempt, and the previous attempt's commits are discarded.`)){T(null),C(!0);try{await q.taskAction(e,`retry`),O.current=new Set,_(new Map),y(new Map),x(new Map),a(null),F(),I(),L(),D(e=>e+1)}catch(e){T(je(e))}finally{C(!1)}}};if(u)return J(vn,{id:e});let re=j==null?null:kt(e,j,m),ie=gn(e,j),B=gn(e,j),V=()=>{if(n===`stages`)return J(Xt,{state:c,attemptNumber:j,events:f,onRetry:I});if(c===void 0)return J(`div`,{className:`run-loading`,children:`Loading this task's attempts…`});if(c===null)return J(`div`,{className:`run-error`,children:[J(`div`,{className:`run-error-title`,children:`Could not load this task's attempts`}),J(`div`,{className:`run-error-detail`,children:`This panel reads one attempt, and the task's run history could not be read.`}),J(`button`,{className:`btn`,type:`button`,onClick:I,children:`Retry`})]});if(j==null)return J(_n,{title:`No attempt recorded`,detail:`This task has no recorded run, so there is nothing to read for an attempt.`});switch(n){case`log`:return J(Mt,{state:re&&g.has(re)?g.get(re):void 0,attempt:j,stages:N,filters:m,onFilterChange:h,taskId:e,onRetry:()=>ee(j,{force:!0})});case`changes`:return J(rn,{state:v.has(ie)?v.get(ie):void 0,task:k,onRetry:()=>R(j,{force:!0})});case`config`:return J(on,{events:f,attempt:j,onRetry:L});case`debug`:return J(sn,{state:b.has(B)?b.get(B):void 0,attempt:j,onRetry:()=>te(j,{force:!0})});default:return J(Xt,{state:c,attemptNumber:j,events:f,onRetry:I})}},ae=Je(`retry`),oe=!!(ae&&(k?.actions||[]).includes(`retry`));return J(`div`,{className:`run-page`,children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:k?.title||`Task #${e}`}),J(`p`,{className:`page-sub`,children:[`One run of task `,e,k?.workflow?` · ${k.workflow} workflow`:``,k?.repo?` · ${k.owner}/${k.repo}`:``]})]}),J(`div`,{className:`page-actions`,children:[J(`a`,{className:`btn`,href:`#/tasks`,children:`Back to tasks`}),J(`button`,{className:`btn`,type:`button`,onClick:z,children:`Refresh`})]})]}),J(`div`,{className:`run-meta`,children:[J(`span`,{className:`run-meta-item`,children:[J(`span`,{className:`run-meta-label`,children:`Task status`}),o===void 0?J(`span`,{className:`run-meta-muted`,children:`loading…`}):k?J(Q,{text:We(k.status),kind:Ge(k.status)}):J(`span`,{className:`run-meta-muted`,children:`not read`})]}),J(`span`,{className:`run-meta-item`,children:[J(`span`,{className:`run-meta-label`,children:`Attempt`}),J(`span`,{className:`run-meta-value`,children:c===null?`run history unreadable`:c===void 0?`loading…`:j==null?`none recorded`:`attempt ${j} of ${A??j}`})]}),k?.repo_url?J(`a`,{className:`run-meta-link`,href:k.repo_url,target:`_blank`,rel:`noreferrer`,children:[k.owner,`/`,k.repo]}):null,k?.issue_url&&k.issue_number?J(`a`,{className:`run-meta-link`,href:k.issue_url,target:`_blank`,rel:`noreferrer`,children:[`Issue #`,k.issue_number]}):null,k?.pr_url&&k.pr_number?J(`a`,{className:`run-meta-link`,href:k.pr_url,target:`_blank`,rel:`noreferrer`,children:[`PR #`,k.pr_number]}):null]}),o===null?J(`p`,{className:`run-note`,children:`The task list could not be read, so this page cannot show the task's current status or its operator controls. The run history below comes from the task's own endpoints.`}):null,Array.isArray(o)&&!k?J(`p`,{className:`run-note`,children:[`Task `,e,` is not among the tasks this dashboard lists (the list covers the 100 most recently updated). Its recorded attempts are shown below; the Debug tab holds the stored record verbatim.`]}):null,J(`section`,{className:`run-restart`,"aria-label":`Start a new run`,children:[J(`button`,{className:`btn ${ae?.kind===`primary`?`btn-primary`:``}`,type:`button`,disabled:!oe||S,title:`Retry this task as a new run`,onClick:ne,children:S?`Starting…`:`Start a new run`}),J(`p`,{className:`run-restart-copy`,children:`Starts a new attempt for this task: a fresh worktree reset onto the base branch. The previous attempt's commits are discarded — they are not carried into the new run.`}),!oe&&o!==void 0?J(`p`,{className:`run-restart-unavailable`,children:k?`A new run can only start from a parked task. This task is ${We(k.status)}.`:`This task's operator controls could not be read, so a new run cannot be started from here.`}):null,w?J(`p`,{className:`run-restart-error run-restart-error-${w.kind}`,children:w.kind===`session-expired`?`Your session has expired. Reload to sign in.`:w.kind===`refused`?`${w.message} — this run cannot be restarted from here.`:`${w.message} — try again, or check the daemon.`}):null]}),J(bn,{attempts:c,selected:j,onSelect:e=>a(e)}),J(`div`,{className:`card run-card`,children:[J(Ht,{tabs:cn,active:n,onSelect:r,prefix:ln}),J(`div`,{className:`run-panel`,role:`tabpanel`,id:Vt(ln,n),"aria-labelledby":Bt(ln,n),tabIndex:0,children:V()})]})]})}function Sn(e,t){let n=t?.id,r=dn(n);return r===null?J(yn,{raw:n??``}):J(xn,{id:r,query:e},r)}function Cn({title:e,detail:t}){return J(`div`,{class:`empty`,children:[J(`div`,{class:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function wn(e){return J(Tn,{query:e})}function Tn(){let[e,t]=U([]),[n,r]=U(``),[i,a]=U(null),o=async()=>{try{let e=await q.skills();t(e?.skills||[]),a(null)}catch(e){t([]),a(String(e.message||e))}};W(()=>{o()},[]);let s=(e,t)=>!t||`${e.name} ${e.description}`.toLowerCase().includes(t),c=_e(()=>e.filter(e=>s(e,n)),[e,n]);return J(`div`,{children:[J(`div`,{class:`page-head`,children:[J(`div`,{children:[J(`h1`,{class:`page-title`,children:`Skills`}),J(`p`,{class:`page-sub`,children:`What Archie can do, in plain language.`})]}),J(`div`,{class:`page-actions`,children:J(`button`,{class:`btn`,onClick:o,children:`Refresh`})})]}),J(`div`,{class:`card`,children:[J(`div`,{class:`card-head`,children:[J(`div`,{children:[J(`h2`,{class:`card-title`,children:`Catalogue`}),J(`p`,{class:`card-sub`,children:`Project, shared, and user-global skills`})]}),J(`input`,{class:`skill-search`,type:`search`,placeholder:`Search skills…`,onInput:e=>r(e.target.value.trim().toLowerCase())})]}),J(`div`,{class:`grid grid-2`,children:i?J(Cn,{title:`Cannot reach archied`,detail:i}):e.length?c.length?c.map(e=>J(`div`,{class:`card skill-card`,children:[J(`div`,{class:`card-head`,children:[J(`h3`,{class:`card-title`,children:e.name||`Untitled skill`}),e.workflow&&J(Q,{text:e.workflow,kind:`info`})]}),J(`p`,{class:`skill-desc`,children:e.description||`No description provided.`}),J(`div`,{class:`skill-source`,children:e.source||`Unknown source`})]},e.name)):J(Cn,{title:`No skills match`,detail:`Nothing found for "${n}".`}):J(Cn,{title:`No skills discovered yet`,detail:`Skills live as SKILL.md files under project, shared, or user-global .agents/skills// directories. Add one and refresh to make it available.`})})]})]})}var En={bootstrap:`Bootstrap`,implement:`Implement`,tdd:`TDD`,feasibility:`Feasibility check`};function Dn(e){return En[e]?En[e]:e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown`}function On(e,t){return t?Math.round(e/t*100):0}function kn(e){if(!e)return`—`;if(e<1e3)return`${e} ms`;let t=e/1e3;return t<60?`${t.toFixed(1)} s`:`${(t/60).toFixed(1)} min`}function An({title:e,detail:t}){return J(`div`,{class:`empty`,children:[J(`div`,{class:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function jn({fraction:e,kind:t=`ok`}){let n=Math.min(100,Math.max(0,e));return J(`div`,{class:`wf-bar`,children:J(`div`,{class:`wf-bar-fill wf-bar-${t}`,style:{width:`${n}%`}})})}function Mn(e){return J(Nn,{query:e})}function Nn(){let[e,t]=U([]),[n,r]=U([]),[i,a]=U([]),[o,s]=U(null),c=async()=>{try{let e=await q.workflows();t(e?.definitions||[]),r(e?.workflows||[]),a(e?.stages||[]),s(null)}catch(e){s(String(e.message||e))}};return W(()=>{c()},[]),J(`div`,{children:[J(`div`,{class:`page-head`,children:[J(`div`,{children:[J(`h1`,{class:`page-title`,children:`Workflows`}),J(`p`,{class:`page-sub`,children:`Run outcomes and spend per workflow, and where stages get stuck.`})]}),J(`div`,{class:`page-actions`,children:J(`button`,{class:`btn`,onClick:c,children:`Refresh`})})]}),J(Pn,{definitions:e}),o?J(`div`,{class:`card`,children:J(An,{title:`Cannot reach archied`,detail:o})}):J(S,{children:[J(Fn,{workflows:n,definitions:e}),J(In,{stages:i})]})]})}function Pn({definitions:e}){if(!e.length)return null;let t=e.filter(e=>e.enabled)[0]?.id||``,[n,r]=U(``),[i,a]=U(``),[o,s]=U(t),[c,l]=U(``),[u,d]=U(``),[f,p]=U(!1),[m,h]=U(``);return W(()=>{!o&&t&&s(t)},[t,o]),J(`div`,{class:`card`,children:[J(`div`,{class:`card-head`,children:J(`div`,{children:[J(`h2`,{class:`card-title`,children:`Start work`}),J(`p`,{class:`card-sub`,children:`This enters Archie’s normal admitted task queue.`})]})}),J(`form`,{class:`wf-form`,onSubmit:async e=>{e.preventDefault(),p(!0),h(``);try{let e=await q.workRequest({identity:n,repository:i,workflow:o,title:c,instructions:u});h(`Queued task #${e.task_id}.`),r(``),a(``),s(t),l(``),d(``)}catch(e){h(String(e.message||e))}finally{p(!1)}},children:[J(`input`,{placeholder:`Identity`,required:!0,value:n,onInput:e=>r(e.target.value)}),J(`input`,{placeholder:`owner/repository`,required:!0,value:i,onInput:e=>a(e.target.value)}),J(`select`,{required:!0,value:o,onInput:e=>s(e.target.value),children:e.filter(e=>e.enabled).map(e=>J(`option`,{value:e.id,children:Dn(e.name||e.id)},e.id))}),J(`input`,{placeholder:`Short task title`,required:!0,value:c,onInput:e=>l(e.target.value)}),J(`textarea`,{placeholder:`Instructions for the work`,required:!0,rows:3,value:u,onInput:e=>d(e.target.value)}),J(`button`,{class:`btn`,type:`submit`,disabled:f,children:`Start work`}),m&&J(`p`,{class:`card-sub`,children:m})]})]})}function Fn({workflows:e,definitions:t}){let n=new Map(e.map(e=>[e.workflow,e])),r=t.map(e=>({...e,...n.get(e.id)||{workflow:e.id,runs:0,merged:0}}));return r.length?J(`div`,{class:`card`,children:[J(`div`,{class:`card-head`,children:J(`div`,{children:[J(`h2`,{class:`card-title`,children:`Per workflow`}),J(`p`,{class:`card-sub`,children:`Success rate is merged tasks over all runs`})]})}),J(`div`,{class:`table-scroll`,children:J(`table`,{class:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Workflow`}),J(`th`,{children:`Origin`}),J(`th`,{children:`Runs`}),J(`th`,{children:`Success rate`}),J(`th`,{children:`Avg tokens`}),J(`th`,{children:`Avg steps`})]})}),J(`tbody`,{children:r.map(e=>{let t=On(e.merged,e.runs);return J(`tr`,{children:[J(`td`,{class:`strong`,children:Dn(e.workflow)}),J(`td`,{class:`mono`,children:e.origin||`registry`}),J(`td`,{children:`${e.runs} run${e.runs===1?``:`s`}`}),J(`td`,{children:[J(`div`,{class:`wf-rate`,children:[t,`%`,J(`span`,{class:`wf-rate-sub`,children:[e.merged,` of `,e.runs,` merged`]})]}),J(jn,{fraction:t,kind:t>=50?`ok`:`warn`})]}),J(`td`,{class:`mono`,children:e.avg_tokens?e.avg_tokens.toLocaleString():`—`}),J(`td`,{class:`mono`,children:e.avg_steps?e.avg_steps.toFixed(1):`—`})]},e.workflow)})})]})})]}):J(`div`,{class:`card`,children:[J(`div`,{class:`card-head`,children:J(`div`,{children:J(`h2`,{class:`card-title`,children:`Per workflow`})})}),J(An,{title:`No workflow runs yet`,detail:`Stats appear here once a task has run through a workflow.`})]})}function In({stages:e}){if(!e.length)return J(`div`,{class:`card wf-stage-card`,children:[J(`div`,{class:`card-head`,children:J(`div`,{children:J(`h2`,{class:`card-title`,children:`Per stage`})})}),J(An,{title:`No stage data yet`,detail:`Stage timing and failures appear here once workflows have run.`})]});let t=Math.max(...e.map(e=>e.avg_ms||0),1),n=[...e].sort((e,t)=>(t.avg_ms||0)-(e.avg_ms||0)),r=[...e].filter(e=>e.errors>0).sort((e,t)=>t.errors-e.errors);return J(`div`,{class:`grid grid-2 wf-stage-card`,children:[J(`div`,{class:`card`,children:[J(`div`,{class:`card-head`,children:J(`div`,{children:[J(`h2`,{class:`card-title`,children:`Slowest stages`}),J(`p`,{class:`card-sub`,children:`Average duration, this workflow's stages`})]})}),J(`div`,{class:`table-scroll`,children:J(`table`,{class:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Workflow`}),J(`th`,{children:`Stage`}),J(`th`,{children:`Runs`}),J(`th`,{children:`Avg duration`})]})}),J(`tbody`,{children:n.map((e,n)=>J(`tr`,{children:[J(`td`,{children:Dn(e.workflow)}),J(`td`,{class:`strong`,children:e.stage}),J(`td`,{children:e.runs}),J(`td`,{children:[J(`div`,{class:`wf-rate`,children:kn(e.avg_ms)}),J(jn,{fraction:On(e.avg_ms,t),kind:`info`})]})]},n))})]})})]}),J(`div`,{class:`card`,children:[J(`div`,{class:`card-head`,children:J(`div`,{children:[J(`h2`,{class:`card-title`,children:`Most failures`}),J(`p`,{class:`card-sub`,children:`Stages that error out, over their runs`})]})}),r.length?J(`div`,{class:`table-scroll`,children:J(`table`,{class:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Workflow`}),J(`th`,{children:`Stage`}),J(`th`,{children:`Failures`})]})}),J(`tbody`,{children:r.map((e,t)=>J(`tr`,{children:[J(`td`,{children:Dn(e.workflow)}),J(`td`,{class:`strong`,children:e.stage}),J(`td`,{children:[J(`div`,{class:`wf-rate`,children:[e.errors,` of `,e.runs]}),J(jn,{fraction:On(e.errors,e.runs),kind:`danger`})]})]},t))})]})}):J(An,{title:`No failures recorded`,detail:`Every stage has completed cleanly so far.`})]})]})}function Ln({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function Rn(e,t){return e===`running`?`ok`:e===`failed`||e===`degraded`?`warn`:`idle`}function zn(){let[e,t]=U([]),[n,r]=U(null),i=async()=>{try{let e=await q.channels();t(e?.channels||[]),r(null)}catch(e){r(String(e.message||e))}};return W(()=>{i()},[]),J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Channels`}),J(`p`,{className:`page-sub`,children:`The conversational front-ends Archie can be reached through.`})]}),J(`div`,{className:`page-actions`,children:J(`button`,{className:`btn`,onClick:i,children:`Refresh`})})]}),J(`div`,{className:`grid grid-2`,children:n?J(Ln,{title:`Cannot reach archied`,detail:n}):e.length===0?J(Ln,{title:`No channels configured`,detail:`Configure [chat.telegram] or [chat.webhook_addr] in config.toml to talk to Archie outside the dashboard.`}):e.map(e=>J(`div`,{className:`card channel-card`,children:[J(`div`,{className:`card-head`,children:[J(`h3`,{className:`card-title`,children:e.name}),J(Q,{text:e.state||(e.configured?`configured`:`stopped`),kind:Rn(e.state,e.configured)})]}),J(`p`,{className:`channel-desc`,children:e.description}),J(`p`,{className:`channel-detail`,children:e.detail}),e.reload_supported?J(`button`,{className:`btn`,onClick:async t=>{t.currentTarget.disabled=!0;try{await q.channelReload(e.id||e.name.toLowerCase()),await i()}catch{}finally{t.currentTarget&&(t.currentTarget.disabled=!1)}},children:`Reload`}):J(`p`,{className:`channel-detail`,children:`Reload requires a daemon restart for this adapter.`})]},e.id||e.name))})]})}function Bn(e){return J(zn,{query:e})}function Vn({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function Hn(e){return J(Un,{query:e})}function Un({query:e}){let[t,n]=U([]),[r,i]=U(null),a=async()=>{try{let e=await q.curators();n(e?.curators||[]),i(null)}catch(e){i(String(e.message||e))}};return W(()=>{a()},[]),J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Curators`}),J(`p`,{className:`page-sub`,children:`Background agents that maintain memory and skills: what ran, and why.`})]}),J(`div`,{className:`page-actions`,children:J(`button`,{className:`btn`,onClick:a,children:`Refresh`})})]}),J(`div`,{className:`grid grid-2`,children:r?J(Vn,{title:`Cannot reach archied`,detail:r}):t.length?t.map(e=>J(Gn,{curator:e},e.name)):J(Vn,{title:`No curators registered`,detail:`Curators are background agent loops that maintain memory and skills. None are registered on this daemon.`})})]})}function Wn(e){switch(e){case`healthy`:return`ok`;case`degraded`:return`warn`;case`unhealthy`:return`danger`;default:return`idle`}}function Gn({curator:e}){let t=e.recent_actions||[];return J(`div`,{className:`card curator-card`,children:[J(`div`,{className:`card-head`,children:[J(`h3`,{className:`card-title`,children:e.name}),J(Q,{text:e.health?.status||`unknown`,kind:Wn(e.health?.status)})]}),e.health?.message&&J(`p`,{className:`curator-health-message`,children:e.health.message}),J(`p`,{className:`curator-meta`,children:e.last_run_at?`Last ran ${X(e.last_run_at)} · ${e.last_run_actions} action${e.last_run_actions===1?``:`s`}`:`Has not run yet`}),t.length?J(`ul`,{className:`curator-actions`,children:t.map((e,t)=>J(`li`,{className:`curator-action`,children:[J(`div`,{className:`curator-action-head`,children:[J(`span`,{className:`curator-action-type`,children:e.type||`action`}),J(`span`,{className:`curator-action-time`,children:X(e.at)})]}),e.detail&&J(`p`,{className:`curator-action-detail`,children:e.detail}),e.reason&&J(`p`,{className:`curator-action-reason`,children:[`Why: `,e.reason]})]},t))}):J(`p`,{className:`curator-meta`,children:`No recorded activity yet.`})]})}function Kn(e){return e==null||e===``?`—`:String(e)}function qn({label:e,value:t,opts:n}){let r=Kn(t),[i,a]=U(!1),[o,s]=U(``),[c,l]=U(null),[u,d]=U(!1),[f,p]=U(!1),m=n?.key;if(!m)return J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,title:n?.hint,children:e}),J(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r})]});let h=n.locked?.[m];if(h)return J(`div`,{className:`kv is-locked`,children:[J(`span`,{className:`kv-label`,title:n.hint,children:e}),J(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),J(`span`,{className:`kv-note`,children:h})]});if(n.editable===!1)return J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,title:n.hint,children:e}),J(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r})]});let g=n.overridden?.includes(m),_=()=>{s(String(n.raw??``)),l(null),a(!0)},v=async()=>{p(!0),l(null);try{await q.configReset(m),n.onSaved?.()}catch(e){l(String(e.message||e))}finally{p(!1)}},y=async()=>{let e=Jn(n.type,o);if(e.error){l(e.error);return}d(!0),l(null);try{await(n.save||(e=>q.configUpdate({[m]:e})))(e.value),a(!1),n.onSaved?.()}catch(e){l(String(e.message||e))}finally{d(!1)}};if(i){let t=G(null);W(()=>{t.current&&t.current.focus()},[]);let r=e=>{e.key===`Enter`&&(e.preventDefault(),y()),e.key===`Escape`&&a(!1)},i;return i=n.type===`bool`?J(`select`,{className:`kv-input`,value:o,onChange:e=>s(e.target.value),onKeyDown:r,ref:t,children:[J(`option`,{value:`true`,children:`true`}),J(`option`,{value:`false`,children:`false`})]}):n.type===`enum`?J(`select`,{className:`kv-input`,value:o,onChange:e=>s(e.target.value),onKeyDown:r,ref:t,children:(n.options||[]).map(e=>J(`option`,{value:e,children:e},e))}):J(`input`,{className:`kv-input`,type:`text`,value:o,onInput:e=>s(e.target.value),onKeyDown:r,ref:t}),J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,title:n.hint,children:e}),i,J(`div`,{className:`kv-actions`,children:[J(`button`,{className:`kv-save`,type:`button`,onClick:y,disabled:u,children:`Save`}),J(`button`,{className:`kv-cancel`,type:`button`,onClick:()=>a(!1),disabled:u,children:`Cancel`})]}),c&&J(`span`,{className:`kv-note is-error`,children:c})]})}return J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,title:n.hint,children:e}),J(`span`,{className:`kv-value mono ${r===`—`?`is-empty`:``}`,title:r,children:r}),J(`div`,{className:`kv-actions`,children:[g&&J(`span`,{className:`kv-flag`,title:`Set from the dashboard; this shadows the value in the config file`,children:`overridden`}),J(`button`,{className:`kv-btn`,type:`button`,title:`Edit ${e}`,onClick:_,children:`Edit`}),g&&J(`button`,{className:`kv-btn`,type:`button`,title:`Discard the dashboard value and fall back to the config file`,onClick:v,disabled:f,children:`Reset`})]}),c&&J(`span`,{className:`kv-note is-error`,children:c})]})}function Jn(e,t){switch(e){case`int`:{let e=parseInt(t,10);return Number.isNaN(e)?{error:`Enter a whole number`}:{value:e}}case`bool`:return{value:t===`true`};default:return{value:t}}}function Yn({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function Xn({sub:e,title:t,children:n}){return J(`div`,{className:`card cfg-section`,children:[J(`div`,{className:`card-head`,children:J(`div`,{children:[J(`h2`,{className:`card-title`,children:t||`Update status`}),J(`p`,{className:`card-sub`,children:e})]})}),n]})}var Zn={ok:`OK`,update_available:`Update available`,drift:`Drift`,unknown:`Unknown`},Qn={ok:`ok`,update_available:`info`,drift:`danger`,unknown:`idle`};function $n({components:e}){return!e||!e.length?J(Xn,{sub:`How each component is deployed, and whether what's running matches what's installed.`,children:J(Yn,{title:`No components reported`,detail:`The configured update-check command returned nothing.`})}):J(Xn,{sub:`How each component is deployed, and whether what's running matches what's installed. Hover a row for the exact versions compared.`,children:J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Component`}),J(`th`,{children:`Install type`}),J(`th`,{children:`Running`}),J(`th`,{children:`Latest available`}),J(`th`,{children:`Status`})]})}),J(`tbody`,{children:e.map(e=>J(`tr`,{title:[`Installed claim: ${e.installed_claim||`unknown`}`,`Running: ${e.running_version||`not observed`}`,e.reference?`Reference: ${e.reference}`:null].filter(Boolean).join(` +`),children:[J(`td`,{className:`strong`,children:e.label||e.id}),J(`td`,{className:`mono`,children:e.install_type||`—`}),J(`td`,{className:`mono`,children:e.running_version||`—`}),J(`td`,{className:`mono`,children:e.latest_available||`—`}),J(`td`,{children:J(Q,{text:Zn[e.status]||e.status,kind:Qn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function $({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function er({title:e,sub:t,children:n}){return J(`div`,{className:`card cfg-section`,children:[J(`div`,{className:`card-head`,children:J(`div`,{children:[J(`h2`,{className:`card-title`,children:e}),J(`p`,{className:`card-sub`,children:t})]})}),n]})}function tr({origins:e}){return e?.length?J(er,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:J(`div`,{className:`kv-list`,children:e.map((e,t)=>J(qn,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):J(er,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:J($,{title:`Source provenance is unavailable.`})})}function nr(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function rr({data:e,error:t}){if(t)return J(er,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:J($,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return J(er,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,children:[J(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?J(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??We(e.id),n=e.kind??Ge(e.id);return J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,children:e.id}),J(`span`,{className:`kv-value`,children:J(Q,{text:t,kind:n})})]},e.id)})}):J($,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),J(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?J(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=nr(e.kind);return J(`div`,{className:`kv`,children:[J(`span`,{className:`kv-label`,children:e.id}),J(`span`,{className:`kv-value`,children:J(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):J($,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function ir({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=U(!1),[o,s]=U(null),[c,l]=U(!!e[t]);return r?J(`td`,{children:[J(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:c,onChange:async r=>{let i=r.target.checked;l(i),a(!0),s(null);try{await q.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){l(!i),s(String(e.message||e))}finally{a(!1)}},disabled:i}),o&&J(`span`,{className:`kv-note is-error`,children:o})]}):J(`td`,{children:c?`yes`:`no`})}function ar({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=U(String(e[t]??0)),[o,s]=U(null),[c,l]=U(!1);return r?J(`td`,{children:[J(`input`,{className:`kv-input`,type:`text`,value:i,onChange:e=>a(e.target.value),onBlur:async()=>{let r=parseInt(i,10);if(Number.isNaN(r)){s(`Enter a whole number`);return}l(!0),s(null);try{await q.configRepoUpdate(e.owner,e.name,t,r),n?.()}catch(e){s(String(e.message||e))}finally{l(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:c}),o&&J(`span`,{className:`kv-note is-error`,children:o})]}):J(`td`,{className:`mono`,children:i})}function or({repos:e,onSaved:t,editable:n=!0}){if(!e?.length)return J(er,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:J($,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let r=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return J(er,{title:`Repositories`,sub:`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, not the file config.toml directly.`,children:J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Repository`}),J(`th`,{children:`Base branch`}),J(`th`,{children:`Ecosystem`}),J(`th`,{children:`Quality gate`}),J(`th`,{children:`Protected paths`}),J(`th`,{children:`Concurrent`}),J(`th`,{children:`Max retries`}),J(`th`,{children:`Self-review`})]})}),J(`tbody`,{children:e.map((e,i)=>J(`tr`,{children:[J(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),J(`td`,{className:`mono`,children:e.base}),J(`td`,{children:e.ecosystem||`go`}),J(`td`,{className:`mono`,children:r(e.gate)}),J(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),J(ir,{r:e,field:`allow_concurrent`,onSaved:t,editable:n}),J(ar,{r:e,field:`max_retries`,onSaved:t,editable:n}),J(ir,{r:e,field:`review_enabled`,onSaved:t,editable:n})]},i))})]})})})}function sr(e){return e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown role`}function cr({models:e,providers:t}){let n=Object.entries(e||{}),r=Object.entries(t||{});return J(er,{title:`Models & providers`,sub:`Which model handles each stage of work, and which LLM providers are wired up. Only the environment variable NAME is shown, never its value.`,children:[J(`h3`,{className:`cfg-subhead`,children:`Model roles`}),n.length?J(`div`,{className:`kv-list`,children:n.map(([e,t])=>J(qn,{label:sr(e),value:t},e))}):J($,{title:`No model roles configured`,detail:`Assign a model to at least one role (e.g. "builder") in [models].`}),J(`h3`,{className:`cfg-subhead`,children:`Providers`}),r.length?J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[J(`th`,{children:`Provider`}),J(`th`,{children:`Class`}),J(`th`,{children:`Base URL`}),J(`th`,{children:`API key env var`}),J(`th`,{children:`Status`})]})}),J(`tbody`,{children:r.map(([e,t])=>J(`tr`,{children:[J(`td`,{className:`strong`,children:e}),J(`td`,{children:t.class}),J(`td`,{className:`mono`,children:t.base_url||`default`}),J(`td`,{className:`mono`,children:t.api_key_env||`—`}),J(`td`,{children:t.configured?J(Q,{text:`configured`,kind:`ok`}):J(Q,{text:`missing credentials`,kind:`warn`})})]},e))})]})}):J($,{title:`No providers configured`,detail:`Add a [providers.] entry so a model role above has something to run on.`})]})}function lr(){let[e,t]=U(null),[n,r]=U(null),[i,a]=U(null),[o,s]=U(null),[c,l]=U(!1),[u,d]=U(null),[f,p]=U(null),m=()=>{h(),g(),_()},h=async()=>{try{let e=await q.config();t(e),r(null)}catch(e){r(String(e.message||e))}},g=async()=>{try{let e=await q.version();a(e?.components||[]),s(null),l(!1)}catch(e){e?.status===501?l(!0):s(String(e.message||e))}},_=async()=>{try{let e=await q.taskMeta();d(e),p(null)}catch(e){p(String(e.message||e))}};return W(()=>{m()},[]),J(`div`,{className:`cfg-page`,children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Configuration`}),J(`p`,{className:`page-sub`,children:`What archied is actually running with right now.`})]}),J(`div`,{className:`page-actions`,children:J(`button`,{className:`btn`,onClick:m,children:`Refresh`})})]}),J(`div`,{children:!c&&(o?J(`div`,{className:`card`,children:J($,{title:`Update status unavailable`,detail:o})}):i?J($n,{components:i}):null)}),J(`div`,{children:J(rr,{data:u,error:f})}),J(`div`,{children:n?J(`div`,{className:`card`,children:J($,{title:`Cannot reach archied`,detail:n})}):!e||Object.keys(e).length===0?J(`div`,{className:`card`,children:J($,{title:`No configuration loaded`,detail:`archied is running without a config file wired into the dashboard, so there is nothing to show.`})}):J(S,{children:[e.reload?.overlay_unavailable&&J(`div`,{className:`card cfg-notice`,children:J(`p`,{children:[`The runtime config overlay is not in effect: `,e.reload.overlay_unavailable]})}),e.reload?.last_error&&J(`div`,{className:`card cfg-notice`,children:J(`p`,{children:[`The last config reload failed; the running config is unchanged: `,e.reload.last_error]})}),(e.schema||[]).map((t,n)=>{let r=t.fields.filter(e=>e.type!==`structured`);return r.length?J(er,{title:t.label,sub:t.description,children:J(`div`,{className:`kv-list`,children:r.map(t=>J(qn,{label:t.label,value:t.value,opts:{key:t.key,type:t.type,options:t.options,raw:t.value,hint:t.description,editable:t.editable&&e.editable!==!1,locked:e.locked||{},overridden:e.overridden||[],onSaved:h}},t.key))})},n):null}),J(or,{repos:e.repositories,onSaved:h,editable:e.editable!==!1}),J(cr,{models:e.models,providers:e.providers}),J(tr,{origins:e.provenance})]})})]})}function ur(e){return J(lr,{query:e})}function dr({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function fr(e){return`${e.time||``}|${e.level||``}|${e.message||e.msg||``}|${JSON.stringify(e.fields||{})}`}function pr(){let[e,t]=U({level:``,component:``,q:``}),[n,r]=U(!1),[i,a]=U([]),[o,s]=U([]),c=G(new Map),[l,u]=U(0),[d,f]=U(!1),[p,m]=U(`connecting`),[h,g]=U(`Refreshing…`),_=G(null),v=G(null),y=async()=>{g(`Refreshing…`);try{let t=await q.logs({level:e.level,component:e.component,q:e.q,limit:500});a(e=>{let n=t.components||[];return e.length===n.length&&e.every((e,t)=>e===n[t])?e:n}),f(!!t.disabled);let n=t.disabled?`Durable history unavailable; live daemon logs continue.`:t.truncated?`showing the most recent matches from ${t.file}`:t.file||``;g(n),s(t.entries||[])}catch{g(`Cannot read logs`)}};W(()=>{y()},[e]),W(()=>{let e=Pe(e=>{if(b.current)return;let t=e;S.current(t)&&(c.current.set(fr(t),t),t.fields?.component&&a(e=>e.includes(t.fields.component)?e:[...e,t.fields.component]),u(e=>e+1))},e=>{m(e)});return()=>e()},[]);let b=G(n);b.current=n;let x=t=>{if(e.level&&!e.level.split(`,`).includes((t.level||``).toUpperCase())||e.component&&t.fields?.component!==e.component)return!1;if(e.q){let n=e.q.toLowerCase();if(!`${t.message||t.msg||``} ${JSON.stringify(t.fields||{})}`.toLowerCase().includes(n))return!1}return!0},S=G(x);S.current=x;let C=_e(()=>{let e=new Map;for(let t of o)e.set(fr(t),t);for(let[t,n]of c.current)e.set(t,n);return[...e.values()].filter(x).slice(-1e3)},[o,l,e]);return W(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[C]),J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Logs`}),J(`p`,{className:`page-sub`,children:`What Archie has been doing, newest last.`})]}),J(`div`,{className:`page-actions`,children:[J(`button`,{className:`btn ${n?`btn-primary`:``}`,onClick:()=>r(!n),children:n?`Resume`:`Pause`}),J(`button`,{className:`btn`,onClick:y,children:`Refresh`})]})]}),J(`div`,{className:`card`,children:[J(`div`,{className:`card-head`,children:[J(`div`,{className:`log-filters`,children:[J(`select`,{className:`log-select`,value:e.level,onChange:e=>t(t=>({...t,level:e.target.value})),children:St.map(e=>J(`option`,{value:e.value,children:e.label},e.value))}),J(`select`,{className:`log-select`,value:e.component,onChange:e=>t(t=>({...t,component:e.target.value})),children:[J(`option`,{value:``,children:`All components`}),i.map(e=>J(`option`,{value:e,children:e},e))]}),J(`input`,{className:`log-search`,type:`search`,placeholder:`Search messages and fields…`,onInput:e=>{let n=e.target.value;v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{t(e=>({...e,q:n}))},250)}})]}),J(`div`,{className:`log-status`,children:[J(`span`,{className:`log-meta`,children:h}),J(Q,{text:p,kind:p===`live`?`ok`:`warn`})]})]}),J(`div`,{className:`log-list`,ref:_,children:h===`Cannot read logs`?J(dr,{title:`Cannot read logs`}):C.length?C.map(e=>J(wt,{entry:e},fr(e))):J(dr,{title:d?`Durable history unavailable`:`Nothing matches`,detail:d?`Live daemon logs will appear here while this page is open.`:`Try a wider level or clear the search.`})})]})]})}function mr(e){return J(pr,{query:e})}function hr({capture:e,expanded:t,onToggle:n}){return J(S,{children:[J(`tr`,{className:`capture-row`,tabIndex:`0`,"aria-expanded":String(t),onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(e))},children:[J(`td`,{className:`mono`,children:e.source||`(unknown)`}),J(`td`,{title:e.received_at||``,children:X(e.received_at)}),J(`td`,{children:J(Q,{text:`Unbound`,kind:`idle`})}),J(`td`,{className:`mono`,children:e.content_type||`—`}),J(`td`,{children:J(`button`,{className:`btn btn-small`,type:`button`,children:t?`Hide`:`View`})})]}),t&&J(gr,{capture:e})]})}function gr({capture:e}){return J(`tr`,{className:`capture-detail-row`,children:J(`td`,{colSpan:`5`,children:J(`div`,{className:`capture-detail`,children:[J(`div`,{className:`capture-detail-section`,children:[J(`div`,{className:`capture-detail-title`,children:`Payload`}),J(_r,{raw:e.body})]}),J(`div`,{className:`capture-detail-section`,children:[J(`div`,{className:`capture-detail-title`,children:`Headers`}),J(_r,{raw:e.headers})]})]})})})}function _r({raw:e}){return e?J(`pre`,{className:`capture-payload`,children:vr(e)}):J(`div`,{className:`capture-empty`,children:`(empty)`})}function vr(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function yr({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function br(e){return J(xr,{query:e})}function xr({query:e}){let[t,n]=U([]),[r,i]=U(null),[a,o]=U(null),[s,c]=U(!0),[l,u]=U({text:`connecting`,kind:`idle`}),d=async()=>{try{let e=await q.captures(100);c(e.enabled!==!1),n(e.captures||[]),o(null)}catch(e){o(String(e.message||e))}};return W(()=>{d();let e=Ne(e=>{e.kind===`capture`&&d()},e=>{u({text:e,kind:e===`live`?`ok`:`warn`})});return()=>e()},[]),J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Event inspector`}),J(`p`,{className:`page-sub`,children:`Real inbound payloads archie has captured, most recent first.`})]}),J(`div`,{className:`page-actions`,children:[J(Q,{text:l.text,kind:l.kind}),J(`button`,{className:`btn`,onClick:d,children:`Refresh`})]})]}),J(`div`,{className:`card`,children:a?J(yr,{title:`Cannot reach archied`,detail:a}):s?t.length?J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[`Source`,`Received`,`Binding`,`Content type`,``].map((e,t)=>J(`th`,{children:e},t))})}),J(`tbody`,{children:t.map(e=>J(hr,{capture:e,expanded:r===e.id,onToggle:()=>i(r===e.id?null:e.id)},e.id))})]})}):J(yr,{title:`No captures yet`,detail:`Point a webhook at /webhooks/capture/ and it will show up here.`}):J(yr,{title:`Capture is not configured`,detail:`This deployment has no capture storage wired up.`})})]})}var Sr=[`string`,`number`,`bool`,`object`,`array`,`any`];function Cr(e){if(e==null)return`any`;if(Array.isArray(e))return`array`;switch(typeof e){case`string`:return`string`;case`number`:return`number`;case`boolean`:return`bool`;case`object`:return`object`;default:return`any`}}function wr(e,t){return e?`${e}.${t}`:t}function Tr(e,t){return`${e}[${t}]`}function Er({value:e,path:t=``,name:n=``,onPick:r}){return typeof e==`object`&&e?J(`ul`,{className:`mapping-tree-list`,children:(Array.isArray(e)?e.map((e,n)=>[String(n),e,Tr(t,n)]):Object.entries(e).map(([e,n])=>[e,n,wr(t,e)])).map(([e,t,n])=>J(`li`,{className:`mapping-tree-item`,children:[J(`span`,{className:`mapping-tree-key`,onClick:i=>{i.stopPropagation(),r&&r({path:n,type:Cr(t),name:e})},children:e}),J(Er,{value:t,path:n,name:e,onPick:r})]},n))}):J(`span`,{className:`mapping-tree-value`,onClick:i=>{i.stopPropagation(),r&&r({path:t,type:Cr(e),name:n})},children:JSON.stringify(e)})}function Dr({fields:e,preview:t,onRemove:n,onNameChange:r,onTypeChange:i,onRequiredChange:a}){if(!e.length)return J(`div`,{className:`mapping-empty-fields`,children:`Click a value in the payload to bind a field.`});let o=new Map((t?.failures||[]).map(e=>[e.field_name,e]));return J(`table`,{className:`table mapping-fields-table`,children:[J(`thead`,{children:J(`tr`,{children:[`Field name`,`Path`,`Type`,`Required`,`Preview`,``].map((e,t)=>J(`th`,{children:e},t))})}),J(`tbody`,{children:e.map((e,s)=>J(`tr`,{children:[J(`td`,{children:J(`input`,{className:`mapping-input`,value:e.name,onInput:e=>r?.(s,e.target.value)})}),J(`td`,{className:`mono`,children:e.path}),J(`td`,{children:J(`select`,{className:`mapping-select`,value:e.type,onChange:e=>i?.(s,e.target.value),children:Sr.map(e=>J(`option`,{value:e,children:e},e))})}),J(`td`,{children:J(`input`,{type:`checkbox`,checked:e.required,onChange:e=>a?.(s,e.target.checked)})}),J(`td`,{children:J(Or,{field:e,preview:t,failureByField:o})}),J(`td`,{children:J(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>n?.(s),children:`Remove`})})]},s))})]})}function Or({field:e,preview:t,failureByField:n}){if(!t)return J(Q,{text:`not previewed`,kind:`idle`});let r=n.get(e.name);return r?J(Q,{text:r.reason,kind:`danger`}):Object.prototype.hasOwnProperty.call(t.values||{},e.name)?J(Q,{text:JSON.stringify(t.values[e.name]),kind:`ok`}):J(Q,{text:`skipped (optional)`,kind:`idle`})}function kr({mapping:e,onEdit:t,onDelete:n}){return J(`tr`,{children:[J(`td`,{children:e.name}),J(`td`,{className:`mono`,children:e.source_hint||`—`}),J(`td`,{children:String(e.fields?.length??0)}),J(`td`,{children:[J(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>t?.(e),children:`Edit`}),J(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>n?.(e),children:`Delete`})]})]})}function Ar({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function jr(e){return J(Mr,{query:e})}function Mr({query:e}){let[t,n]=U([]),[r,i]=U([]),[a,o]=U(null),[s,c]=U(null),l=async()=>{try{let[e,t]=await Promise.all([q.mappings(),q.captures(100)]);n(e.mappings||[]),i(t.captures||[]),o(null)}catch(e){o(String(e.message||e))}};W(()=>{l()},[]);let u=()=>{c({id:null,name:``,sourceHint:``,fields:[],captureId:null,payload:null,payloadError:null,preview:null,actionError:null})},d=e=>{c({id:e.id,name:e.name,sourceHint:e.source_hint||``,fields:(e.fields||[]).map(e=>({...e})),captureId:null,payload:null,payloadError:null,preview:null,actionError:null})},f=async e=>{if(window.confirm(`Delete mapping "${e.name}"?`))try{await q.mappingDelete(e.id),await l()}catch(e){o(String(e.message||e))}},p=e=>{let t=r.find(t=>String(t.id)===String(e));c(e=>{let n={...e,captureId:t?t.id:null,preview:null};if(!t)n.payload=null,n.payloadError=null;else try{n.payload=JSON.parse(t.body),n.payloadError=null}catch{n.payload=null,n.payloadError=`This capture's body is not valid JSON, so its fields cannot be mapped by path.`}return n})},m=({path:e,type:t,name:n})=>{c(r=>{let i=new Set(r.fields.map(e=>e.name)),a=n||`field`,o=1;for(;i.has(a);)a=`${n||`field`}_${++o}`;let s=[...r.fields,{name:a,path:e,type:t,required:!0}];return{...r,fields:s,preview:null}})},h=e=>{c(t=>{let n=t.fields.slice();return n.splice(e,1),{...t,fields:n,preview:null}})},g=(e,t)=>{c(n=>{let r=n.fields.slice();return r[e]={...r[e],...t},{...n,fields:r,preview:null}})};return s?J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:J(`h1`,{className:`page-title`,children:s.id?`Edit mapping`:`New mapping`})}),J(`div`,{className:`page-actions`,children:[J(`button`,{className:`btn`,type:`button`,onClick:()=>{c(null)},children:`Cancel`}),J(`button`,{className:`btn btn-primary`,type:`button`,onClick:async()=>{let e={name:s.name,source_hint:s.sourceHint,fields:s.fields};try{s.id?await q.mappingUpdate(s.id,e):await q.mappingCreate(e),c(null),await l()}catch(e){c(t=>({...t,actionError:String(e.message||e)}))}},children:`Save`})]})]}),s.actionError&&J(`div`,{className:`mapping-error`,children:s.actionError}),J(`div`,{className:`card mapping-form`,children:[J(`label`,{className:`mapping-form-row`,children:[`Name`,J(`input`,{className:`mapping-input`,value:s.name,onInput:e=>c(t=>({...t,name:e.target.value}))})]}),J(`label`,{className:`mapping-form-row`,children:[`Source hint (organisational only)`,J(`input`,{className:`mapping-input`,value:s.sourceHint,onInput:e=>c(t=>({...t,sourceHint:e.target.value}))})]}),J(`label`,{className:`mapping-form-row`,children:[`Preview against captured event`,J(`select`,{className:`mapping-select`,value:s.captureId||``,onChange:e=>p(e.target.value),children:[J(`option`,{value:``,children:`— pick a captured event —`}),r.map(e=>J(`option`,{value:e.id,children:[e.source||`(unknown)`,` — `,e.received_at||``]},e.id))]})]})]}),J(`div`,{className:`card mapping-fields`,children:[J(`div`,{className:`mapping-section-title`,children:`Bound fields`}),J(Dr,{fields:s.fields,preview:s.preview,onRemove:h,onNameChange:(e,t)=>g(e,{name:t}),onTypeChange:(e,t)=>g(e,{type:t}),onRequiredChange:(e,t)=>g(e,{required:t})}),J(`button`,{className:`btn`,type:`button`,onClick:async()=>{if(!s.captureId){c(e=>({...e,actionError:`Pick a captured event to preview against.`}));return}try{let e=await q.mappingPreview(s.captureId,s.fields);c(t=>({...t,preview:e,actionError:null}))}catch(e){c(t=>({...t,actionError:String(e.message||e)}))}},children:`Preview`})]}),J(`div`,{className:`card mapping-payload`,children:[J(`div`,{className:`mapping-section-title`,children:`Payload — click a value to bind it`}),s.payloadError?J(`div`,{className:`mapping-error`,children:s.payloadError}):s.payload===null?J(`div`,{className:`mapping-empty-fields`,children:`Pick a captured event above to see its payload.`}):J(Er,{value:s.payload,onPick:m})]})]}):J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Field mappings`}),J(`p`,{className:`page-sub`,children:`Bind named fields to JSON paths from a real captured event, ready for a playbook binding.`})]}),J(`div`,{className:`page-actions`,children:J(`button`,{className:`btn btn-primary`,type:`button`,onClick:u,children:`New mapping`})})]}),a?J(Ar,{title:`Cannot reach archied`,detail:a}):t.length?J(`div`,{className:`card`,children:J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[`Name`,`Source hint`,`Fields`,``].map((e,t)=>J(`th`,{children:e},t))})}),J(`tbody`,{children:t.map(e=>J(kr,{mapping:e,onEdit:()=>d(e),onDelete:()=>f(e)},e.id))})]})})}):J(Ar,{title:`No mappings yet`,detail:`Create one from a captured event to reuse fields in a future playbook binding.`})]})}var Nr={draft:`draft`,pending_approval:`pending approval`,armed:`armed`},Pr={draft:`idle`,pending_approval:`warn`,armed:`ok`};function Fr({status:e}){return J(Q,{text:Nr[e]||e,kind:Pr[e]||`idle`})}function Ir({binding:e,onEdit:t,onApprove:n,onDelete:r}){let i=e.owner&&e.repo?`${e.owner}/${e.repo}`:`—`;return J(`tr`,{children:[J(`td`,{children:e.name}),J(`td`,{className:`mono`,children:e.matcher?.source||`—`}),J(`td`,{children:e.workflow}),J(`td`,{className:`mono`,children:i}),J(`td`,{children:J(Fr,{status:e.status})}),J(`td`,{children:[J(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>t?.(e),children:`Edit`}),e.status===`pending_approval`&&J(`button`,{className:`btn btn-small btn-primary`,type:`button`,onClick:()=>n?.(e),children:`Approve`}),J(`button`,{className:`btn btn-small`,type:`button`,onClick:()=>r?.(e),children:`Delete`})]})]})}function Lr({title:e,detail:t}){return J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:e}),t&&J(`div`,{children:t})]})}function Rr(e){return J(Br,{query:e})}function zr(){return{id:null,name:``,source:``,mappingId:``,workflow:``,owner:``,repo:``,secret:``,actionError:null}}function Br({query:e}){let[t,n]=U([]),[r,i]=U([]),[a,o]=U([]),[s,c]=U(null),[l,u]=U(null),d=async()=>{try{let[e,t,r]=await Promise.all([q.bindings(),q.mappings(),q.workflows()]);n(e.bindings||[]),i(t.mappings||[]),o((r.definitions||[]).filter(e=>e.enabled)),c(null)}catch(e){c(String(e.message||e))}};W(()=>{d()},[]);let f=()=>{u(zr())},p=e=>{u({id:e.id,name:e.name,source:e.matcher?.source||``,mappingId:e.mapping_id?String(e.mapping_id):``,workflow:e.workflow||``,owner:e.owner||``,repo:e.repo||``,secret:``,actionError:null})},m=()=>u(null),h=async()=>{let e={name:l.name,matcher:{source:l.source},mapping_id:Number(l.mappingId)||0,workflow:l.workflow,owner:l.owner,repo:l.repo,secret:l.secret};try{l.id?await q.bindingUpdate(l.id,e):await q.bindingCreate(e),u(null),await d()}catch(e){u(t=>({...t,actionError:String(e.message||e)}))}},g=async e=>{try{await q.bindingApprove(e.id),await d()}catch(e){c(String(e.message||e))}},_=async e=>{if(window.confirm(`Delete binding "${e.name}"?`))try{await q.bindingDelete(e.id),await d()}catch(e){c(String(e.message||e))}};return l?J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:J(`h1`,{className:`page-title`,children:l.id?`Edit binding`:`New binding`})}),J(`div`,{className:`page-actions`,children:[J(`button`,{className:`btn`,type:`button`,onClick:m,children:`Cancel`}),J(`button`,{className:`btn btn-primary`,type:`button`,onClick:h,children:`Save`})]})]}),l.actionError&&J(`div`,{className:`binding-error`,children:l.actionError}),J(`div`,{className:`card binding-form`,children:[J(`label`,{className:`binding-form-row`,children:[`Name`,J(`input`,{className:`binding-input`,value:l.name,onInput:e=>u(t=>({...t,name:e.target.value}))})]}),J(`label`,{className:`binding-form-row`,children:[`Source (the path segment senders POST to, e.g. "sentry")`,J(`input`,{className:`binding-input`,value:l.source,onInput:e=>u(t=>({...t,source:e.target.value}))})]}),J(`label`,{className:`binding-form-row`,children:[`Field mapping`,J(`select`,{className:`binding-select`,value:l.mappingId,onChange:e=>u(t=>({...t,mappingId:e.target.value})),children:[J(`option`,{value:``,children:`— pick a saved mapping —`}),r.map(e=>J(`option`,{value:e.id,children:e.name},e.id))]})]}),J(`label`,{className:`binding-form-row`,children:[`Workflow`,J(`select`,{className:`binding-select`,value:l.workflow,onChange:e=>u(t=>({...t,workflow:e.target.value})),children:[J(`option`,{value:``,children:`— pick a workflow —`}),a.map(e=>J(`option`,{value:e.id,children:e.name},e.id))]})]}),J(`label`,{className:`binding-form-row`,children:[`Repo pin -- owner (optional; leave both blank for the single-configured-repo default)`,J(`input`,{className:`binding-input`,value:l.owner,onInput:e=>u(t=>({...t,owner:e.target.value}))})]}),J(`label`,{className:`binding-form-row`,children:[`Repo pin -- repo`,J(`input`,{className:`binding-input`,value:l.repo,onInput:e=>u(t=>({...t,repo:e.target.value}))})]}),J(`label`,{className:`binding-form-row`,children:[`Shared secret (`,l.id?`leave blank to keep the current secret`:`senders sign with this via HMAC-SHA256`,`)`,J(`input`,{className:`binding-input`,type:`password`,value:l.secret,onInput:e=>u(t=>({...t,secret:e.target.value}))})]})]})]}):J(`div`,{children:[J(`div`,{className:`page-head`,children:[J(`div`,{children:[J(`h1`,{className:`page-title`,children:`Playbook bindings`}),J(`p`,{className:`page-sub`,children:`Tie a matcher, a field mapping, and a workflow together. New and edited bindings need explicit approval before they can fire.`})]}),J(`div`,{className:`page-actions`,children:J(`button`,{className:`btn btn-primary`,type:`button`,onClick:f,children:`New binding`})})]}),s?J(Lr,{title:`Cannot reach archied`,detail:s}):t.length?J(`div`,{className:`card`,children:J(`div`,{className:`table-scroll`,children:J(`table`,{className:`table`,children:[J(`thead`,{children:J(`tr`,{children:[`Name`,`Source`,`Workflow`,`Repo pin`,`Status`,``].map((e,t)=>J(`th`,{children:e},t))})}),J(`tbody`,{children:t.map(e=>J(Ir,{binding:e,onEdit:()=>p(e),onApprove:()=>g(e),onDelete:()=>_(e)},e.id))})]})})}):J(Lr,{title:`No bindings yet`,detail:`Create one from a saved field mapping to turn a captured webhook into a workflow.`})]})}var Vr=/(!\[[^\]]*\]\((?:https?:\/\/[^\s)]+|data:image\/[^\s)]+|\/[^\s)]+)\)|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|`[^`]+`|\[[^\]]+\]\((?:https?:\/\/[^\s)]+|\/[^\s)]+)\)|\*[^*]+\*|_[^_]+_)/g;function Hr(e){let t=[],n=0,r=0;for(let i of String(e).matchAll(Vr)){i.index>n&&t.push(e.slice(n,i.index));let a=i[0];if(a.startsWith(`![`)){let e=a.match(/^!\[([^\]]*)\]\((.+)\)$/);e&&t.push(J(`img`,{className:`chat-media-img`,src:e[2],alt:e[1]||`Image`,loading:`lazy`},r++))}else if(a.startsWith(`~~`))t.push(J(`del`,{children:a.slice(2,-2)},r++));else if(a.startsWith(`**`)||a.startsWith(`__`))t.push(J(`strong`,{children:a.slice(2,-2)},r++));else if(a.startsWith("`"))t.push(J(`code`,{children:a.slice(1,-1)},r++));else if(a.startsWith(`[`)){let e=a.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+|\/[^\s)]+)\)$/);e&&t.push(J(`a`,{href:e[2],target:`_blank`,rel:`noreferrer`,children:e[1]},r++))}else t.push(J(`em`,{children:a.slice(1,-1)},r++));n=i.index+a.length}return n{i.length&&(n.push(J(`p`,{children:Hr(i.join(` `))},s++)),i=[])},l=()=>{if(!a)return;let e=a.items.map((e,t)=>J(`li`,{children:Hr(e)},t));n.push(a.tag===`ol`?J(`ol`,{children:e},s++):J(`ul`,{children:e},s++)),a=null};for(let e=0;eJ(`th`,{children:Hr(e)},t))})}),J(`tbody`,{children:t.map((e,t)=>J(`tr`,{children:e.map((e,t)=>J(`td`,{children:Hr(e)},t))},t))})]},s++));continue}if(!t.trim()){c(),l();continue}let f=t.match(/^(#{1,3})\s+(.+)$/);if(f){c(),l();let e=`h${f[1].length}`;n.push(J(e,{children:Hr(f[2])},s++));continue}let p=t.match(/^\s*[-*]\s+(.+)$/),m=t.match(/^\s*\d+[.)]\s+(.+)$/);if(p||m){c();let e=m?`ol`:`ul`;(!a||a.tag!==e)&&(l(),a={tag:e,items:[]}),a.items.push((p||m)[1]);continue}if(t.startsWith(`>`)){c(),l(),n.push(J(`blockquote`,{children:Hr(t.replace(/^>\s?/,``))},s++));continue}i.push(t)}return c(),l(),o&&n.push(J(`pre`,{children:J(`code`,{children:o.join(` +`)})},s++)),J(`div`,{className:t,children:n})}function Wr(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function Gr(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Kr=`archie.web.chat.channel`;function qr(){let e=localStorage.getItem(Kr);return e||(e=Ee(),localStorage.setItem(Kr,e)),e}function Jr(e){return{text:e,sourceID:Ee()}}function Yr(e){return{...e}}function Xr(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?Yr(e.turn):Jr(r),isRetry:n}}function Zr({scrollTop:e,viewportHeight:t,optionTop:n,optionHeight:r}){if(r>=t||ne+t?i-t:e}function Qr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function $r(e,t){if(!t)return`Archie`;let n=(e||[]).find(e=>e.session_id===t);return n?Qr(n):`Archie`}function ei(){return location.hash.slice(1)||`/`}function ti({open:e=!0}){let[t,n]=U([]),[r,i]=U(``),[a,o]=U([]),[s,c]=U(``),[l,u]=U(`Ready`),[d,f]=U(!1),[p,m]=U({}),[h,g]=U(``),[_,v]=U(``),[y,b]=U(``),[x,C]=U([]),[w,T]=U([]),[E,D]=U(0),[O,k]=U(!1),[A,j]=U(null),M=G(null),N=G(null),P=G(null),F=G(null),I=G(null),L=G(null),ee=G(d);ee.current=d,W(()=>{let e=e=>{let t=L.current;t?.open&&(e.target instanceof Node&&t.contains(e.target)||(t.open=!1))};return document.addEventListener(`pointerdown`,e),document.addEventListener(`focusin`,e),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`focusin`,e)}},[]),W(()=>{e&&N.current?.focus()},[e]),W(()=>{if(!O)return;let e=I.current,t=e?.children?.[E];!e||!t||(e.scrollTop=Zr({scrollTop:e.scrollTop,viewportHeight:e.clientHeight,optionTop:t.offsetTop,optionHeight:t.offsetHeight}))},[E,O]),W(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight)},[a,A]),W(()=>{R().catch(e=>{u(e.message||`Chat unavailable`)});let e=()=>{P.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),P.current?.abort()}},[]);async function R(){let e=await q.chatSessions(),t=e.sessions||[];n(t),m(e),g(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;v(a),b(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);C(o),!r&&t[0]&&await te(t[0].session_id,e,t)}async function te(e,t,n){let r=t||p;i(e),o([]),j(null);let a=r.active_personas?.[e]||r.active_persona||``;g(a);try{await q.chatMessage(qr(),`/resume ${e}`);let[t,n]=await Promise.all([q.chatMessages(e),q.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});o(i)}catch(e){u(e.message||`Could not load session messages`)}}async function z(e){if(r)try{u(`Working…`);let t=await q.chatMessage(qr(),e);t.session_id&&i(t.session_id),u(t.reply||`Session updated`),await R(),(t.session_id||r)&&await te(t.session_id||r),F.current&&(F.current.open=!1)}catch(e){u(e.message||`Session action failed`)}}function ne(e,t){let n=window.prompt(t);n?.trim()&&z(`${e} ${n.trim()}`)}function re(e){let t=e.target.value;g(t),!(!r||!t)&&q.chatPersona(r,t).then(()=>{m(e=>({...e,active_personas:{...e.active_personas||{},[r]:t}})),u(`Personality: ${t}`)}).catch(e=>{u(e.message||`Failed to set personality`)})}async function ie(e){let t=e.target.value;if(v(t),t)try{let e=await q.chatMessage(qr(),`/model --provider ${t}`);u(e.reply||`Provider updated`),await R()}catch(e){u(`Provider update failed: ${e.message||e}`)}}async function B(e){let t=e.target.value;if(b(t),t)try{let e=await q.chatMessage(qr(),`/model ${t}`);u(e.reply||`Model updated`),await R()}catch(e){u(`Model update failed: ${e.message||e}`)}}function V(){c(`/new`),ce({textOverride:`/new`})}function ae(e){let t=e.target.value;c(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=x.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){T(t),D(0),k(!0);return}}k(!1),T([])}function oe(e){let t=w[e];if(!t||!N.current)return;let n=N.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.search(/(?:^|\s)\/[^\s]*$/),o=a<0?r.length:a+ +(r[a]===` `),s=`${r.slice(0,o)}${t.command} ${i}`;c(s),k(!1);let l=o+t.command.length+1;setTimeout(()=>{n.focus(),n.setSelectionRange(l,l)},0)}function se(e){if(O&&w.length){if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&w.some(e=>e.command===s.trim())){e.preventDefault(),k(!1),ce();return}if(e.key===`ArrowDown`){e.preventDefault(),D(e=>(e+1)%w.length);return}if(e.key===`ArrowUp`){e.preventDefault(),D(e=>(e+w.length-1)%w.length);return}if(e.key===`Enter`&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey){e.preventDefault(),oe(E);return}if(e.key===`Escape`){e.preventDefault(),k(!1);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ce())}async function ce(e=null){let t=e?.textOverride,{text:n,turn:r,isRetry:a}=Xr(e,t===void 0?s:t);if(!n||ee.current)return;k(!1),f(!0),u(a?`Retrying…`:`Thinking…`),a||(o(e=>[...e,{from:`web`,text:n}]),c(``));let l=[];j({text:``,tools:[],isError:!1,turn:r,isRetry:a});let d=``,p=!1,m=!1,h=null;try{let e=new AbortController;P.current=e,h=setTimeout(()=>{m=!0,e.abort()},12e4);let t=(await q.chatStream({channel_id:qr(),source_id:r.sourceID,text:r.text,page:ei()},{signal:e.signal})).body.getReader(),n=new TextDecoder,a=``;for(;;){let{value:e,done:r}=await t.read();a+=n.decode(e||new Uint8Array,{stream:!r});let o=a.split(` -`);o=a.pop()||``;for(let e of a){let t=e.split(` -`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&r(n.session_id),n.type===`delta`&&(f+=n.text,A(e=>e?{...e,text:f}:null)),n.type===`tool`&&(u=[...u,n],A(e=>e?{...e,tools:u}:null)),n.type===`navigate`&&(u=[...u,n],A(e=>e?{...e,tools:u}:null)),n.type===`done`&&(p=!0,f||=n.text),n.type===`error`)throw Error(n.text)}if(i)break}if(!p)throw Error(`chat stream ended before completion`);a(e=>[...e,{from:`assistant`,text:f,tool_calls:u}]),A(null),l(`Ready`),await L()}catch(e){if(e.name===`AbortError`&&!m)A({text:`Turn stopped.`,tools:u,isError:!1,turn:i,isRetry:c}),l(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;A({text:t,tools:u,isError:!0,turn:Yr(i),isRetry:c}),l(`Error — retry available`)}}finally{clearTimeout(h),N.current=null,d(!1),M.current&&M.current.focus()}}function oe(){l(`Stopping…`),n&&J.chatCancel(n).catch(()=>{}),N.current?.abort()}let se=f.models_by_provider||{},U=g&&se[g]?se[g]:f.models||[];return Y(`div`,{className:`chat-panel-content`,children:[Y(`div`,{className:`chat-bar`,children:[Y(`label`,{className:`chat-session-switch`,children:[Y(`span`,{className:`sr-only`,children:`Conversation`}),Y(`select`,{value:n,onChange:e=>R(e.target.value),disabled:!e.length,children:e.length?e.map(e=>Y(`option`,{value:e.session_id,children:Zr(e)},e.session_id)):Y(`option`,{value:``,children:`No conversations yet`})})]}),Y(`button`,{className:`icon-btn chat-new`,type:`button`,title:`New chat`,"aria-label":`New chat`,onClick:ie,children:`+`}),Y(`details`,{className:`chat-settings`,children:[Y(`summary`,{"aria-label":`Chat settings`,title:`Chat settings`,children:Y(`span`,{"aria-hidden":`true`,children:`⚙`})}),Y(`div`,{className:`chat-settings-body`,children:[Y(`span`,{className:`chat-status`,children:c}),Y(`label`,{children:[`Personality`,Y(`select`,{className:`chat-select`,"aria-label":`Personality`,value:m,onChange:te,children:[Y(`option`,{value:``,children:`Default`}),(f.personas||[]).map(e=>Y(`option`,{value:e,children:e},e))]})]}),(f.providers||[]).length>0&&Y(`label`,{children:[`Provider`,Y(`select`,{className:`chat-select`,"aria-label":`Provider`,value:g,onChange:ne,children:[Y(`option`,{value:``,children:`Default`}),(f.providers||[]).map(e=>Y(`option`,{value:e,children:e},e))]})]}),Y(`label`,{children:[`Model`,Y(`select`,{className:`chat-select`,"aria-label":`Model`,value:v,onChange:re,children:[Y(`option`,{value:``,children:`Default`}),U.map(e=>Y(`option`,{value:e,children:e},e))]})]})]})]})]}),Y(`div`,{className:`chat-layout`,children:Y(`section`,{className:`chat-workspace`,children:[Y(`div`,{className:`chat-workspace-head`,children:[Y(`details`,{className:`chat-command-help`,children:[Y(`summary`,{children:[`Available commands (`,b.length,`)`]}),Y(`div`,{className:`chat-command-list`,children:b.length?b.map(e=>Y(`div`,{className:`chat-command-item`,children:[Y(`code`,{children:e.usage||e.command}),Y(`span`,{children:e.description||``})]},e.command)):Y(`span`,{children:`Send a message to begin.`})})]}),Y(`details`,{className:`chat-session-tools`,ref:P,hidden:!n,children:[Y(`summary`,{children:`Session actions`}),Y(`div`,{className:`chat-session-tool-list`,children:[Y(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/retry`),children:`Retry`}),Y(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/undo`),children:`Undo`}),Y(`button`,{className:`btn`,type:`button`,onClick:()=>ee(`/title`,`Session title`),children:`Rename`}),Y(`button`,{className:`btn`,type:`button`,onClick:()=>ee(`/branch`,`Branch name (optional)`),children:`Branch`}),Y(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/compress --preview`),children:`Preview compression`})]})]})]}),Y(`div`,{className:`chat-transcript`,ref:j,children:!i.length&&!k?Y(`div`,{className:`chat-empty-state`,children:[Y(`span`,{className:`chat-empty-mark`,children:`A`}),Y(`h2`,{children:`What are we working on?`}),Y(`p`,{children:`Ask Archie anything, or start with one of these prompts.`}),Y(`div`,{className:`chat-prompt-grid`,children:[Y(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{s(`Summarise active tasks`),M.current?.focus()},children:`Summarise active tasks`}),Y(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{s(`Show running agents`),M.current?.focus()},children:`Show running agents`}),Y(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{s(`Check system status`),M.current?.focus()},children:`Check system status`})]})]}):Y(S,{children:[i.map((e,t)=>{let n=e.from??e.From??``,r=e.text??e.Text??``,i=n!==`web`,a=e.tool_calls||e.ToolCalls||[];return Y(`div`,{className:`chat-bubble-row ${i?`assistant`:`user`}`,children:Y(`div`,{className:`chat-bubble`,children:[Y(`div`,{className:`chat-bubble-meta`,children:i?`Archie`:`You`}),i?Y(S,{children:[a.length>0&&Y(`div`,{className:`chat-tools`,children:a.map((e,t)=>{if(e.path)return Y(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[Y(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),Y(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.Name||e.tool||`tool`,r=e.parameters||e.Parameters||``,i=e.summary||e.Summary||e.text||e.err||e.Err||`done`;return Y(`div`,{className:`chat-tool ${e.err||e.Err||e.failed?`failed`:``}`,children:[Y(`span`,{className:`chat-tool-icon`,children:`🔧`}),Y(`span`,{className:`chat-tool-name`,children:n}),r&&Y(`code`,{className:`chat-tool-parameters`,children:r}),Y(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),Y(Ur,{text:r})]}):Y(`div`,{className:`chat-bubble-text`,children:r})]})},t)}),k&&Y(`div`,{className:`chat-bubble-row assistant`,children:Y(`div`,{className:`chat-bubble`,children:[Y(`div`,{className:`chat-bubble-meta`,children:`Archie`}),k.tools?.length>0&&Y(`div`,{className:`chat-tools`,children:k.tools.map((e,t)=>{if(e.path)return Y(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[Y(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),Y(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.tool||`tool`,r=e.parameters||``,i=e.summary||e.text||(e.failed?`failed`:`running…`);return Y(`div`,{className:`chat-tool ${e.failed?`failed`:``}`,children:[Y(`span`,{className:`chat-tool-icon`,children:`🔧`}),Y(`span`,{className:`chat-tool-name`,children:n}),r&&Y(`code`,{className:`chat-tool-parameters`,children:r}),Y(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),Y(Ur,{text:k.text||`…`}),k.isError&&Y(`button`,{className:`btn chat-retry`,type:`button`,onClick:()=>H({turn:k.turn}),children:`Retry`})]})})]})}),Y(`div`,{className:`chat-compose`,children:Y(`div`,{className:`chat-composer-shell`,children:[Y(`textarea`,{ref:M,className:`chat-composer`,rows:3,placeholder:`Message Archie, or type / for commands`,"aria-label":`Message Archie`,disabled:u,value:o,onInput:B,onKeyDown:ae}),D&&C.length>0&&Y(`div`,{className:`chat-command-menu`,ref:F,role:`listbox`,"aria-label":`Commands`,children:C.map((e,t)=>Y(`button`,{type:`button`,role:`option`,"aria-selected":String(t===T),className:`chat-command-option`,onMouseDown:e=>e.preventDefault(),onClick:()=>V(t),children:[Y(`code`,{children:e.command}),Y(`span`,{children:e.description||e.usage||``})]},e.command))}),Y(`div`,{className:`chat-compose-actions`,children:[Y(`span`,{className:`chat-hint`,children:`Enter to send · Shift+Enter for a new line`}),Y(`button`,{className:`btn`,type:`button`,disabled:!u,onClick:oe,children:`Stop`}),Y(`button`,{className:`btn btn-primary`,type:`button`,disabled:u||!o.trim(),onClick:()=>H(),children:`Send`})]})]})})]})})]})}function ei(e,t){let n=ni(t);for(let t of e){let e=ri(t.path,n);if(e)return{route:t,params:e}}return null}function ti(e){return e?.navPath||e?.path||`/`}function ni(e){let t=String(e??`/`).split(`?`,1)[0].split(`#`,1)[0];return t?t.length>1&&t.endsWith(`/`)?t.slice(0,-1):t:`/`}function ri(e,t){let n=String(e).split(`/`),r=String(t).split(`/`);if(n.length!==r.length)return null;let i={};for(let e=0;et.nav!==!1&&!e.includes(t.path))}function li({activePath:e,hidden:t,onNavigate:n,theme:r,onToggleTheme:i}){let[a,o]=W(!1),s=K(null),c=()=>o(!1);return Y(`header`,{className:`topbar`,children:[Y(`div`,{className:`brand`,children:[Y(`span`,{className:`brand-mark`,children:`A`}),`Archie`]}),Y(`nav`,{className:`nav`,children:ci(t).map(t=>Y(`a`,{className:`nav-item`,href:`#${t.path}`,"aria-current":t.path===e?`page`:void 0,"aria-disabled":t.soon||void 0,title:t.soon?`Coming soon`:void 0,onClick:e=>{t.soon?e.preventDefault():n(t.path)},children:[Y(X,{name:t.icon}),Y(`span`,{className:`nav-label`,children:t.label}),t.soon?Y(`span`,{className:`nav-soon`,children:`soon`}):null]},t.path))}),Y(`div`,{className:`topbar-end`,children:[Y(`div`,{className:`topbar-search${a?` is-open`:``}`,children:[Y(`span`,{className:`topbar-search-icon`,"aria-hidden":`true`,children:Y(X,{name:`search`,size:15})}),Y(`button`,{className:`icon-btn mobile-search-toggle`,type:`button`,"aria-label":`Open Jump to navigation`,"aria-expanded":a?`true`:`false`,onClick:()=>{o(!0),s.current?.focus()},children:Y(X,{name:`search`,size:15})}),Y(`input`,{ref:s,type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),c(),e.target.blur();return}if(e.key!==`Enter`)return;let t=e.target.value.trim().toLowerCase(),r=ii.find(e=>e.nav!==!1&&!e.soon&&e.label.toLowerCase().startsWith(t));r&&(n(r.path),e.target.value=``,e.target.blur(),c())}})]}),Y(`button`,{className:`icon-btn`,title:`Documentation`,"aria-label":`Documentation`,children:Y(X,{name:`help`})}),Y(`button`,{className:`icon-btn`,title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onClick:i,children:Y(X,{name:r===`dark`?`moon`:`sun`})}),Y(`div`,{className:`avatar`,title:`Signed in locally`,children:`A`})]})]})}var ui=`chat-panel`;function di(){let[e,t]=W(!1),n=K(null),r=_e(()=>{t(!1),n.current?.focus()},[]);return G(()=>{if(!e)return;let t=e=>{e.defaultPrevented||e.key!==`Escape`||r()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,r]),Y(`div`,{className:`chat-dock${e?` is-open`:``}`,children:[Y(`aside`,{className:`chat-drawer${e?` is-open`:``}`,id:ui,"aria-label":`Chat with Archie`,"aria-hidden":e?void 0:`true`,children:Y(`div`,{className:`chat-drawer-panel`,children:[Y(`div`,{className:`chat-drawer-head`,children:[Y(`strong`,{children:`Archie`}),Y(`button`,{className:`icon-btn chat-drawer-close`,"aria-label":`Close chat`,title:`Close chat`,onClick:r,children:Y(X,{name:`close`})})]}),Y($r,{})]})}),Y(`button`,{ref:n,type:`button`,className:`chat-fab`,"aria-label":e?`Close chat`:`Chat with Archie`,title:e?`Close chat`:`Chat with Archie`,"aria-expanded":e?`true`:`false`,"aria-controls":ui,onClick:()=>e?r():t(!0),children:[Y(`span`,{className:`chat-fab-icon chat-fab-icon-open`,"aria-hidden":`true`,children:Y(X,{name:`chat`,size:22})}),Y(`span`,{className:`chat-fab-icon chat-fab-icon-close`,"aria-hidden":`true`,children:Y(X,{name:`close`,size:22})})]})]})}function fi({label:e}){return Y(`div`,{children:[Y(`div`,{className:`page-head`,children:Y(`div`,{children:Y(`h1`,{className:`page-title`,children:e})})}),Y(`div`,{className:`card`,children:Y(`div`,{className:`empty`,children:[Y(`div`,{className:`empty-title`,children:`${e} is not built yet`}),Y(`div`,{children:`This section is next up. Nothing is broken.`})]})})]})}function pi({view:e,search:t,params:n}){return e(t,n)}var mi=null,hi=null;function gi(e){if(!mi)return;let[t,n=``]=String(e).split(`?`,2),r=ei(ii,t),i=r?.route||ii[0],a=r?.params||{};ie(i.view?Y(pi,{view:i.view,search:new URLSearchParams(n),params:a},`${i.path}|${Object.values(a).join(`/`)}`):Y(fi,{label:i.label}),mi)}function _i(e){let[t]=String(e).split(`?`,2),n=ei(ii,t)?.route||ii[0];mi?.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`)),hi?.setActive(ti(n)),gi(e)}function vi(e){location.hash===`#${e}`?_i(e):location.hash=e}window.addEventListener(`hashchange`,()=>_i(location.hash.slice(1)||`/`));function yi(){let[e,t]=W(`/`),[n,r]=W(oi),[i,a]=W([]),o=_e(e=>{mi=e,hi={setActive:t}},[]);return G(()=>{si(n)},[n]),G(()=>{J.capabilities().then(e=>a(Pe(e?.sections,ii))).catch(()=>{})},[]),G(()=>{He().then(()=>gi(location.hash.slice(1)||`/`))},[]),Y(S,{children:[Y(`div`,{className:`shell`,children:[Y(li,{activePath:e,hidden:i,onNavigate:vi,theme:n,onToggleTheme:()=>r(e=>e===`dark`?`light`:`dark`)}),Y(`main`,{className:`main`,ref:o})]}),Y(di,{})]})}si(oi()),ie(Y(yi,{}),document.getElementById(`app`)),_i(location.hash.slice(1)||`/`); \ No newline at end of file +`);a=o.pop()||``;for(let e of o){let t=e.split(` +`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&i(n.session_id),n.type===`delta`&&(d+=n.text,j(e=>e?{...e,text:d}:null)),n.type===`tool`&&(l=[...l,n],j(e=>e?{...e,tools:l}:null)),n.type===`navigate`&&(l=[...l,n],j(e=>e?{...e,tools:l}:null)),n.type===`done`&&(p=!0,d||=n.text),n.type===`error`)throw Error(n.text)}if(r)break}if(!p)throw Error(`chat stream ended before completion`);o(e=>[...e,{from:`assistant`,text:d,tool_calls:l}]),j(null),u(`Ready`),await R()}catch(e){if(e.name===`AbortError`&&!m)j({text:`Turn stopped.`,tools:l,isError:!1,turn:r,isRetry:a}),u(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;j({text:t,tools:l,isError:!0,turn:Yr(r),isRetry:a}),u(`Error — retry available`)}}finally{clearTimeout(h),P.current=null,f(!1),N.current&&N.current.focus()}}function H(){u(`Stopping…`),r&&q.chatCancel(r).catch(()=>{}),P.current?.abort()}let le=p.models_by_provider||{},ue=_&&le[_]?le[_]:p.models||[];return J(`div`,{className:`chat-panel-content`,children:[J(`div`,{className:`chat-drawer-head`,children:[J(`strong`,{className:`chat-panel-title`,children:$r(t,r)}),J(`div`,{className:`chat-head-actions`,children:J(`button`,{className:`icon-btn chat-new`,type:`button`,title:`New chat`,"aria-label":`New chat`,onClick:V,children:J(Y,{name:`message-circle-plus`})})})]}),J(`div`,{className:`chat-bar`,children:[J(`label`,{className:`chat-session-switch`,children:[J(`span`,{className:`sr-only`,children:`Conversation`}),J(`select`,{value:r,onChange:e=>te(e.target.value),disabled:!t.length,children:t.length?t.map(e=>J(`option`,{value:e.session_id,children:Qr(e)},e.session_id)):J(`option`,{value:``,children:`No conversations yet`})})]}),J(`details`,{className:`chat-settings`,ref:L,children:[J(`summary`,{"aria-label":`Chat settings`,title:`Chat settings`,children:J(`span`,{"aria-hidden":`true`,children:`⚙`})}),J(`div`,{className:`chat-settings-body`,children:[J(`span`,{className:`chat-status`,children:l}),J(`label`,{children:[`Personality`,J(`select`,{className:`chat-select`,"aria-label":`Personality`,value:h,onChange:re,children:[J(`option`,{value:``,children:`Default`}),(p.personas||[]).map(e=>J(`option`,{value:e,children:e},e))]})]}),(p.providers||[]).length>0&&J(`label`,{children:[`Provider`,J(`select`,{className:`chat-select`,"aria-label":`Provider`,value:_,onChange:ie,children:[J(`option`,{value:``,children:`Default`}),(p.providers||[]).map(e=>J(`option`,{value:e,children:e},e))]})]}),J(`label`,{children:[`Model`,J(`select`,{className:`chat-select`,"aria-label":`Model`,value:y,onChange:B,children:[J(`option`,{value:``,children:`Default`}),ue.map(e=>J(`option`,{value:e,children:e},e))]})]})]})]})]}),J(`div`,{className:`chat-layout`,children:J(`section`,{className:`chat-workspace`,children:[J(`div`,{className:`chat-workspace-head`,children:J(`details`,{className:`chat-session-tools`,ref:F,hidden:!r,children:[J(`summary`,{children:`Session actions`}),J(`div`,{className:`chat-session-tool-list`,children:[J(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/retry`),children:`Retry`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/undo`),children:`Undo`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>ne(`/title`,`Session title`),children:`Rename`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>ne(`/branch`,`Branch name (optional)`),children:`Branch`}),J(`button`,{className:`btn`,type:`button`,onClick:()=>z(`/compress --preview`),children:`Preview compression`})]})]})}),J(`div`,{className:`chat-transcript`,ref:M,children:!a.length&&!A?J(`div`,{className:`chat-empty-state`,children:[J(`span`,{className:`chat-empty-mark`,children:`A`}),J(`h2`,{children:`What are we working on?`}),J(`p`,{children:`Ask Archie anything, or start with one of these prompts.`}),J(`div`,{className:`chat-prompt-grid`,children:[J(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Summarise active tasks`),N.current?.focus()},children:`Summarise active tasks`}),J(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Show running agents`),N.current?.focus()},children:`Show running agents`}),J(`button`,{className:`chat-prompt`,type:`button`,onClick:()=>{c(`Check system status`),N.current?.focus()},children:`Check system status`})]})]}):J(S,{children:[a.map((e,t)=>{let n=e.from??e.From??``,r=e.text??e.Text??``,i=n!==`web`,a=e.tool_calls||e.ToolCalls||[];return J(`div`,{className:`chat-bubble-row ${i?`assistant`:`user`}`,children:J(`div`,{className:`chat-bubble`,children:i?J(S,{children:[a.length>0&&J(`div`,{className:`chat-tools`,children:a.map((e,t)=>{if(e.path)return J(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[J(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),J(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.Name||e.tool||`tool`,r=e.parameters||e.Parameters||``,i=e.summary||e.Summary||e.text||e.err||e.Err||`done`;return J(`div`,{className:`chat-tool ${e.err||e.Err||e.failed?`failed`:``}`,children:[J(`span`,{className:`chat-tool-icon`,children:`🔧`}),J(`span`,{className:`chat-tool-name`,children:n}),r&&J(`code`,{className:`chat-tool-parameters`,children:r}),J(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),J(Ur,{text:r})]}):J(`div`,{className:`chat-bubble-text`,children:r})})},t)}),A&&J(`div`,{className:`chat-bubble-row assistant`,children:J(`div`,{className:`chat-bubble`,children:[A.tools?.length>0&&J(`div`,{className:`chat-tools`,children:A.tools.map((e,t)=>{if(e.path)return J(`a`,{className:`chat-nav-chip`,href:`#${e.path}`,title:`Go to ${e.label||e.path}`,children:[J(`span`,{className:`chat-nav-chip-icon`,"aria-hidden":`true`,children:`↗`}),J(`span`,{className:`chat-nav-chip-label`,children:e.label||e.path})]},t);let n=e.name||e.tool||`tool`,r=e.parameters||``,i=e.summary||e.text||(e.failed?`failed`:`running…`);return J(`div`,{className:`chat-tool ${e.failed?`failed`:``}`,children:[J(`span`,{className:`chat-tool-icon`,children:`🔧`}),J(`span`,{className:`chat-tool-name`,children:n}),r&&J(`code`,{className:`chat-tool-parameters`,children:r}),J(`span`,{className:`chat-tool-summary`,children:i})]},t)})}),J(Ur,{text:A.text||`…`}),A.isError&&J(`button`,{className:`btn chat-retry`,type:`button`,onClick:()=>ce({turn:A.turn}),children:`Retry`})]})})]})}),J(`div`,{className:`chat-compose`,children:J(`div`,{className:`chat-composer-shell`,children:[J(`textarea`,{ref:N,className:`chat-composer`,rows:3,placeholder:`Message Archie, or type / for commands`,"aria-label":`Message Archie`,value:s,onInput:ae,onKeyDown:se}),O&&w.length>0&&J(`div`,{className:`chat-command-menu`,ref:I,role:`listbox`,"aria-label":`Commands`,children:w.map((e,t)=>J(`button`,{type:`button`,role:`option`,"aria-selected":String(t===E),className:`chat-command-option`,onMouseDown:e=>e.preventDefault(),onClick:()=>oe(t),children:[J(`code`,{children:e.command}),J(`span`,{children:e.description||e.usage||``})]},e.command))}),J(`div`,{className:`chat-compose-actions`,children:[d&&J(`button`,{className:`btn`,type:`button`,onClick:H,children:`Stop`}),J(`button`,{className:`btn btn-primary`,type:`button`,disabled:d||!s.trim(),onClick:()=>ce(),children:`Send`})]})]})})]})})]})}function ni(e,t){let n=ii(t);for(let t of e){let e=ai(t.path,n);if(e)return{route:t,params:e}}return null}function ri(e){return e?.navPath||e?.path||`/`}function ii(e){let t=String(e??`/`).split(`?`,1)[0].split(`#`,1)[0];return t?t.length>1&&t.endsWith(`/`)?t.slice(0,-1):t:`/`}function ai(e,t){let n=String(e).split(`/`),r=String(t).split(`/`);if(n.length!==r.length)return null;let i={};for(let e=0;et.nav!==!1&&!e.includes(t.path))}function di({activePath:e,hidden:t,onNavigate:n,theme:r,onToggleTheme:i}){let[a,o]=U(!1),s=G(null),c=()=>o(!1);return J(`header`,{className:`topbar`,children:[J(`div`,{className:`brand`,children:[J(`span`,{className:`brand-mark`,children:`A`}),`Archie`]}),J(`nav`,{className:`nav`,children:ui(t).map(t=>J(`a`,{className:`nav-item`,href:`#${t.path}`,"aria-current":t.path===e?`page`:void 0,"aria-disabled":t.soon||void 0,title:t.soon?`Coming soon`:void 0,onClick:e=>{t.soon?e.preventDefault():n(t.path)},children:[J(Y,{name:t.icon}),J(`span`,{className:`nav-label`,children:t.label}),t.soon?J(`span`,{className:`nav-soon`,children:`soon`}):null]},t.path))}),J(`div`,{className:`topbar-end`,children:[J(`div`,{className:`topbar-search${a?` is-open`:``}`,children:[J(`span`,{className:`topbar-search-icon`,"aria-hidden":`true`,children:J(Y,{name:`search`,size:15})}),J(`button`,{className:`icon-btn mobile-search-toggle`,type:`button`,"aria-label":`Open Jump to navigation`,"aria-expanded":a?`true`:`false`,onClick:()=>{o(!0),s.current?.focus()},children:J(Y,{name:`search`,size:15})}),J(`input`,{ref:s,type:`search`,placeholder:`Jump to…`,"aria-label":`Jump to a section`,onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),c(),e.target.blur();return}if(e.key!==`Enter`)return;let t=e.target.value.trim().toLowerCase(),r=oi.find(e=>e.nav!==!1&&!e.soon&&e.label.toLowerCase().startsWith(t));r&&(n(r.path),e.target.value=``,e.target.blur(),c())}})]}),J(`button`,{className:`icon-btn`,title:`Documentation`,"aria-label":`Documentation`,children:J(Y,{name:`help`})}),J(`button`,{className:`icon-btn`,title:`Toggle light and dark`,"aria-label":`Toggle light and dark`,onClick:i,children:J(Y,{name:r===`dark`?`moon`:`sun`})}),J(`div`,{className:`avatar`,title:`Signed in locally`,children:`A`})]})]})}var fi=`chat-panel`;function pi(){let[e,t]=U(!1),n=G(null),r=ve(()=>{t(!1),n.current?.focus()},[]);return W(()=>{if(!e)return;let t=e=>{e.defaultPrevented||e.key!==`Escape`||r()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,r]),J(`div`,{className:`chat-dock${e?` is-open`:``}`,children:[J(`aside`,{className:`chat-drawer${e?` is-open`:``}`,id:fi,"aria-label":`Chat with Archie`,"aria-hidden":e?void 0:`true`,children:J(`div`,{className:`chat-drawer-panel`,children:J(ti,{open:e})})}),J(`button`,{ref:n,type:`button`,className:`chat-fab`,"aria-label":e?`Close chat`:`Chat with Archie`,title:e?`Close chat`:`Chat with Archie`,"aria-expanded":e?`true`:`false`,"aria-controls":fi,onClick:()=>e?r():t(!0),children:[J(`span`,{className:`chat-fab-icon chat-fab-icon-open`,"aria-hidden":`true`,children:J(Y,{name:`chat`,size:22})}),J(`span`,{className:`chat-fab-icon chat-fab-icon-close`,"aria-hidden":`true`,children:J(Y,{name:`close`,size:22})})]})]})}function mi({label:e}){return J(`div`,{children:[J(`div`,{className:`page-head`,children:J(`div`,{children:J(`h1`,{className:`page-title`,children:e})})}),J(`div`,{className:`card`,children:J(`div`,{className:`empty`,children:[J(`div`,{className:`empty-title`,children:`${e} is not built yet`}),J(`div`,{children:`This section is next up. Nothing is broken.`})]})})]})}function hi({view:e,search:t,params:n}){return e(t,n)}var gi=null,_i=null;function vi(e){if(!gi)return;let[t,n=``]=String(e).split(`?`,2),r=ni(oi,t),i=r?.route||oi[0],a=r?.params||{};ie(i.view?J(hi,{view:i.view,search:new URLSearchParams(n),params:a},`${i.path}|${Object.values(a).join(`/`)}`):J(mi,{label:i.label}),gi)}function yi(e){let[t]=String(e).split(`?`,2),n=ni(oi,t)?.route||oi[0];gi?.firstElementChild?.dispatchEvent(new CustomEvent(`archie:teardown`)),_i?.setActive(ri(n)),vi(e)}function bi(e){location.hash===`#${e}`?yi(e):location.hash=e}window.addEventListener(`hashchange`,()=>yi(location.hash.slice(1)||`/`));function xi(){let[e,t]=U(`/`),[n,r]=U(ci),[i,a]=U([]),o=ve(e=>{gi=e,_i={setActive:t}},[]);return W(()=>{li(n)},[n]),W(()=>{q.capabilities().then(e=>a(Fe(e?.sections,oi))).catch(()=>{})},[]),W(()=>{Ue().then(()=>vi(location.hash.slice(1)||`/`))},[]),J(S,{children:[J(`div`,{className:`shell`,children:[J(di,{activePath:e,hidden:i,onNavigate:bi,theme:n,onToggleTheme:()=>r(e=>e===`dark`?`light`:`dark`)}),J(`main`,{className:`main`,ref:o})]}),J(pi,{})]})}li(ci()),ie(J(xi,{}),document.getElementById(`app`)),yi(location.hash.slice(1)||`/`); \ No newline at end of file diff --git a/ui/src/base/icons.jsx b/ui/src/base/icons.jsx index 22ff1f7f6..e166266a5 100644 --- a/ui/src/base/icons.jsx +++ b/ui/src/base/icons.jsx @@ -32,6 +32,7 @@ const paths = { trendDown: '', check: '', close: '', + "message-circle-plus": '', help: '', }; diff --git a/ui/src/chat/chat-render.jsx b/ui/src/chat/chat-render.jsx index 263fa373d..aa912a0b5 100644 --- a/ui/src/chat/chat-render.jsx +++ b/ui/src/chat/chat-render.jsx @@ -10,3 +10,14 @@ export function sessionTitle(session) { return session.title || session.branch_name || `Conversation ${session.session_id.slice(0, 8)}`; } + +/** + * panelTitle names the launcher panel's header. The panel is small and the + * session switcher sits below it, so the header says which conversation is + * open rather than repeating the product name. + */ +export function panelTitle(sessions, currentSession) { + if (!currentSession) return "Archie"; + const session = (sessions || []).find((item) => item.session_id === currentSession); + return session ? sessionTitle(session) : "Archie"; +} diff --git a/ui/src/chat/chat.css b/ui/src/chat/chat.css index f8de3807a..3be932fb8 100644 --- a/ui/src/chat/chat.css +++ b/ui/src/chat/chat.css @@ -3,7 +3,10 @@ (archie-core-hesx). */ .chat-panel-content { display: grid; - grid-template-rows: auto minmax(0, 1fr); + /* header, bar, then the conversation takes the rest: without the third + track the transcript sized to its content and left the composer floating + above dead space. */ + grid-template-rows: auto auto minmax(0, 1fr); flex: 1 1 auto; min-height: 0; overflow: hidden; @@ -203,18 +206,17 @@ .chat-nav-chip-icon { font-size: .8rem; line-height: 1; } .chat-compose { padding: var(--sp-3); border-top: 1px solid var(--border); } -.chat-composer-shell { position: relative; padding: .7rem .8rem .55rem; background: var(--surface-hover); border: 1px solid var(--border-strong); border-radius: .9rem; } -.chat-composer { width: 100%; min-height: 3.3rem; resize: vertical; box-sizing: border-box; background: transparent; color: var(--fg); border: 0; padding: .25rem 0; font: inherit; } +/* Text and actions share one row: the buttons sit at the right of the input, + not on a line of their own under it. */ +.chat-composer-shell { position: relative; display: flex; align-items: flex-end; gap: var(--sp-2); padding: .7rem .8rem; background: var(--surface-hover); border: 1px solid var(--border-strong); border-radius: .9rem; } +.chat-composer { flex: 1 1 auto; min-width: 0; min-height: 2.6rem; resize: none; box-sizing: border-box; background: transparent; color: var(--fg); border: 0; padding: .25rem 0; font: inherit; } .chat-composer:focus { outline: 0; } .chat-command-menu { position: absolute; z-index: 3; right: .8rem; bottom: calc(100% - .25rem); left: .8rem; display: grid; gap: .15rem; max-height: 18rem; overflow: auto; padding: .35rem; background: var(--surface); border: 1px solid var(--border-strong); border-radius: .7rem; box-shadow: 0 .7rem 2rem color-mix(in srgb, #000 30%, transparent); } .chat-command-menu[hidden] { display: none; } .chat-command-option { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr; gap: .65rem; align-items: center; padding: .5rem .6rem; text-align: left; color: var(--fg-muted); background: transparent; border: 1px solid transparent; border-radius: .45rem; cursor: pointer; } .chat-command-option:hover, .chat-command-option[aria-selected="true"] { color: var(--fg); background: var(--surface-hover); border-color: var(--border); } .chat-command-option code { color: var(--fg); } -/* The hint takes the whole first row so Stop and Send always sit together on - the second, rather than the hint pushing Send onto a line of its own. */ -.chat-compose-actions { margin-top: var(--sp-2); flex-wrap: wrap; row-gap: var(--sp-2); justify-content: flex-end; } -.chat-compose-actions .chat-hint { flex: 1 0 100%; font-size: var(--text-xs); color: var(--fg-muted); } +.chat-compose-actions { display: flex; align-items: center; flex: none; gap: var(--sp-2); } .chat-hint, .chat-empty { color: var(--fg-muted); font-size: .78rem; } .chat-command-help { color: var(--fg-muted); font-size: .78rem; margin-right: auto; } .chat-command-help summary { cursor: pointer; } diff --git a/ui/src/chat/chat.jsx b/ui/src/chat/chat.jsx index 4d9618510..b2807066a 100644 --- a/ui/src/chat/chat.jsx +++ b/ui/src/chat/chat.jsx @@ -1,10 +1,12 @@ import { h, Fragment } from "preact"; import { useState, useEffect, useRef } from "preact/hooks"; import { api } from "../base/api.jsx"; +import { Icon } from "../base/icons.jsx"; import { ChatMarkdown } from "./markdown.jsx"; import { channelID } from "./chat-state.jsx"; import { newChatTurn, retryChatTurn, resolveTurn } from "./chat-retry.jsx"; -import { sessionTitle } from "./chat-render.jsx"; +import { commandScrollTop } from "./command-scroll.js"; +import { panelTitle, sessionTitle } from "./chat-render.jsx"; import "./chat.css"; @@ -12,7 +14,7 @@ function currentPage() { return location.hash.slice(1) || "/"; } -export function ChatApp() { +export function ChatApp({ open = true }) { const [sessions, setSessions] = useState([]); const [currentSession, setCurrentSession] = useState(""); const [messages, setMessages] = useState([]); @@ -38,9 +40,46 @@ export function ChatApp() { const activeControllerRef = useRef(null); const sessionToolsRef = useRef(null); const commandMenuRef = useRef(null); + const settingsRef = useRef(null); const isSendingRef = useRef(isSending); isSendingRef.current = isSending; + useEffect(() => { + const closeSettings = (event) => { + const details = settingsRef.current; + if (!details?.open) return; + if (event.target instanceof Node && details.contains(event.target)) return; + details.open = false; + }; + document.addEventListener("pointerdown", closeSettings); + document.addEventListener("focusin", closeSettings); + return () => { + document.removeEventListener("pointerdown", closeSettings); + document.removeEventListener("focusin", closeSettings); + }; + }, []); + + // The panel stays mounted so the session survives navigation, so opening it + // is a prop change rather than a mount: focus the composer on that edge. + useEffect(() => { + if (open) composerRef.current?.focus(); + }, [open]); + + // Arrow keys move the palette selection; the list scrolls so the highlight + // stays visible once the matches run past the visible rows. + useEffect(() => { + if (!isCommandMenuOpen) return; + const menu = commandMenuRef.current; + const option = menu?.children?.[commandSelection]; + if (!menu || !option) return; + menu.scrollTop = commandScrollTop({ + scrollTop: menu.scrollTop, + viewportHeight: menu.clientHeight, + optionTop: option.offsetTop, + optionHeight: option.offsetHeight, + }); + }, [commandSelection, isCommandMenuOpen]); + // Auto scroll transcript to bottom on new messages or streaming tokens useEffect(() => { if (transcriptRef.current) { @@ -400,6 +439,15 @@ export function ChatApp() { return (
+
+ {panelTitle(sessions, currentSession)} +
+ +
+
+
- - -
+
@@ -487,21 +531,6 @@ export function ChatApp() {
-
- Available commands ({commandSpecs.length}) -
- {!commandSpecs.length ? ( - Send a message to begin. - ) : ( - commandSpecs.map((spec) => ( -
- {spec.usage || spec.command} - {spec.description || ""} -
- )) - )} -
-
-
{isAssistant ? "Archie" : "You"}
{isAssistant ? ( {tools.length > 0 && ( @@ -665,7 +693,6 @@ export function ChatApp() { {streamingTurn && (
-
Archie
{streamingTurn.tools?.length > 0 && (
{streamingTurn.tools.map((tool, tIdx) => { @@ -732,7 +759,6 @@ export function ChatApp() { rows={3} placeholder="Message Archie, or type / for commands" aria-label="Message Archie" - disabled={isSending} value={composerText} onInput={handleComposerInput} onKeyDown={handleComposerKeyDown} @@ -761,15 +787,11 @@ export function ChatApp() {
)}
- Enter to send · Shift+Enter for a new line - + {isSending && ( + + )} -
- + {/* ChatApp owns the header: the title is the open conversation. It + carries no close button -- the launcher stays visible and is the + one control that opens and closes the panel. */} +