feat(webui): port the dashboard (Phases 3-5)
Every page from the deleted Preact dashboard, rebuilt in Vue 3 + shadcn-vue.
The navigation restructure landed earlier on this branch; this is the surfaces
behind it, and the two are now one app.
Dashboard, Tasks (list and detail), Configuration split six ways, Logs,
Inspector, Mappings, Bindings, Workflows, Skills, Curators, Channels, chat.
Components, not files: docs/prds/dashboard-port-brief.md requires one
component, one job, one file, with shared state in a module beside it. So a
page file composes and holds nothing, and a shape repeated across panes becomes
its own component (LogRow, PageHeader, PanelLoading, WorkflowBar).
Behaviour that had to survive, because each was a fix:
- Live activity's detail is clamped to one line with the payload on the title.
Unclamped, one row made the dashboard 7,481px tall.
- Each health card takes its own height. Equalising left a mostly-empty box
taking a quarter of the first screen once setup was done.
- Tasks: `tab`/`attempt` live in the query string and are written with
router.replace, so a tab click adds no history entry and does not remount.
The list's deep-link reveal honours prefers-reduced-motion.
- LOG_LEVELS is a wire contract (the server matches that CSV server-side), used
unchanged by both log panes.
- The chat panel's Phase 5 list: a FAB that is the only toggle, a morph whose
scale, radius and position interpolate together, no scrim, no close button,
Escape returning focus to the launcher, Stop only while streaming.
- Unconfigured is not broken. A 501 on /api/version or the log stream renders
what is true ("Not configured on this deployment") rather than blank, and a
read-only Configuration says so instead of offering controls that cannot work.
Three things the port decided rather than carried:
- Button gains an `attention` variant and Badge the five status tones, in the
project's own cva. The pill's dot did not come across: the Badge's shape is
the affordance, and the same tone now covers a trend indicator.
- The icon module is not ported. Its name-to-glyph lookup is the pattern
shadcn-vue's rules call out as wrong, so icons come from @lucide/vue at the
call site. The five bespoke glyphs have no consumer yet and become components
if a page draws them.
- The theme control left the topbar for /system/appearance, per the approved
navigation design. ThemeToggle.vue and Placeholder.vue are deleted rather
than orphaned: every route now resolves to a real page.
Also fixes the bundle freshness check failing on the first build after every
change. ui/dist is committed, so nothing ignores it and Tailwind's content
detection scanned it, making each build an input to the next.
This commit is contained in:
276 files changed
+12888
-563
No files matched your search
@@ -148,54 +148,67 @@ Two decisions worth not re-litigating:
|
||||
In dependency order. Each is `git show e18fb8b2^:ui/src/<folder>/`. File counts
|
||||
verified against the deletion diff.
|
||||
|
||||
- [ ] **Dashboard** (5 files). Health row, Throughput tiles, Token outlook,
|
||||
Live activity table. Also the time-of-day `greeting()` and
|
||||
`taskIDForEvent`, the click-through from an activity row to its task.
|
||||
- [ ] **Tasks** (13 files — the largest). List, filters, row actions, detail
|
||||
page with tab bar, stage rail, changed files, attempt config, task logs,
|
||||
timeline, debug view. Two interaction contracts that are not visual:
|
||||
detail `tab`/`attempt` state lives in the query string and is written
|
||||
with `history.replaceState`, **not** `location.hash =`, so a tab click
|
||||
does not remount and refetch; and the list has a reduced-motion-aware
|
||||
scroll-to-row reveal for deep links.
|
||||
- [ ] **Chat** (8 files, `chat.jsx` alone is 810 lines). Phase 5 covers the
|
||||
launcher chrome; the content features are separate and none of them are
|
||||
chrome: session list and switching, persona selector, provider and model
|
||||
selectors (also driven by `/model` and persona slash commands), and
|
||||
**inline tool-call rendering in the transcript** — name, parameters,
|
||||
summary, and success-or-failure per call.
|
||||
- [ ] **Configuration** (5 files). The approved design splits it into
|
||||
`/system/*` routes — see `docs/prds/dashboard-navigation-groups.md` — so
|
||||
port into that shape directly rather than porting the monolith first.
|
||||
Content beyond layout: `RepositoriesCard`'s inline-editable cells
|
||||
(PATCH-on-blur with keyboard handling), `ModelsAndProvidersCard`,
|
||||
`ProvenanceCard`, `LifecycleCard`, and the **editable-vs-read-only dual
|
||||
mode** — `editable={false}` when the serving process only has a published
|
||||
config snapshot and the PATCH routes answer 503 (`archie-core-ymut`).
|
||||
That is architecture, not styling.
|
||||
- [ ] **Logs** (3 files). Filters, live tail, pause, the three empty states.
|
||||
- [ ] **Event inspector / captures** (3 files).
|
||||
- [ ] **Field mappings** (3 files), including the mapping editor.
|
||||
- [ ] **Playbook bindings** (3 files), including the binding editor.
|
||||
- [ ] **Workflows** (3 files).
|
||||
- [ ] **Skills**, **Curators**, **Channels** (2 files each). Capability-gated
|
||||
and hidden on the reference deployment, so they are easy to forget and
|
||||
easy to ship broken.
|
||||
Ported as named components, not as one file per page: see
|
||||
`docs/prds/dashboard-port-brief.md#componentisation`. A page file composes and
|
||||
holds nothing, shared state lives in a module beside it, and a lookup that maps
|
||||
a string to a component is not written.
|
||||
|
||||
- [x] **Dashboard.** Health row, Throughput tiles, Token outlook, Live activity
|
||||
table, the time-of-day `greeting()`, and the click-through from an
|
||||
activity row to its task. The setup panel branches on the state machine
|
||||
rather than on "is setup present", which had shown a 100% checklist where
|
||||
the complete state belongs.
|
||||
- [x] **Tasks.** List, filters, row actions, detail page with tab bar, stage
|
||||
rail, changed files, attempt config, task logs, timeline, debug view.
|
||||
Both interaction contracts survive: detail `tab`/`attempt` is written with
|
||||
`router.replace` (never a hash, and replace so a tab click adds no history
|
||||
entry and does not remount), and the list's reduced-motion-aware
|
||||
scroll-to-row reveal for deep links. `1q89`'s column priority is applied.
|
||||
One deliberate deviation: the list's inline timeline expansion is gone,
|
||||
since the row now opens `/tasks/:id` and that page owns the timeline; the
|
||||
phone layout's stacked cards are not reproduced and the table scrolls
|
||||
inside its own container instead.
|
||||
- [ ] **Chat.** In progress.
|
||||
- [x] **Configuration**, split into the six `/system/*` routes the approved
|
||||
design names, with the editable-vs-read-only dual mode intact: this
|
||||
composition serves a published snapshot, so the pages say they are
|
||||
read-only rather than rendering controls that cannot work.
|
||||
- [x] **Logs.** Filters, live tail, pause. A 503 on the stream renders as
|
||||
"Log stream unavailable" with the reason, not as a permanent
|
||||
"reconnecting".
|
||||
- [x] **Event inspector / captures.**
|
||||
- [x] **Field mappings**, including the mapping editor. Its `mappingPreview`
|
||||
`capture_id` is a number: the wire type is int64 and a JSON string is
|
||||
rejected.
|
||||
- [x] **Playbook bindings**, including the binding editor.
|
||||
- [x] **Workflows**, keeping the "No stage data yet" state and omitting the
|
||||
Start-work form when the endpoint serves no definitions (`3tij`).
|
||||
- [x] **Skills**, **Curators**, **Channels.** Capability-gated and hidden on the
|
||||
reference deployment, so all three were verified by their own empty state.
|
||||
|
||||
Every page was rendered against the running daemon at 1440x900 and 720px, with
|
||||
no horizontal page scroll at either width.
|
||||
|
||||
## Phase 4 — Navigation restructure
|
||||
|
||||
Approved in `docs/prds/dashboard-navigation-groups.md`; build it during the
|
||||
port rather than porting the flat bar first.
|
||||
|
||||
- [ ] Five top-level items: Dashboard, Work, Agent, Events, System.
|
||||
- [ ] Rename under their group: Inspector, Mappings, Bindings.
|
||||
- [ ] Per-item hover tooltips carrying a one-line description.
|
||||
- [ ] Configuration splits into `/system/{status,appearance,tasks,models,repos,advanced}`.
|
||||
- [ ] `/settings` redirects to `/system/status` — it is in bookmarks and in the
|
||||
- [x] Five top-level items: Dashboard, Work, Agent, Events, System.
|
||||
- [x] Rename under their group: Inspector, Mappings, Bindings.
|
||||
- [x] Per-item hover tooltips carrying a one-line description.
|
||||
- [x] Configuration splits into `/system/{status,appearance,tasks,models,repos,advanced}`.
|
||||
- [x] `/settings` redirects to `/system/status` — it is in bookmarks and in the
|
||||
Go route registry.
|
||||
- [ ] Add Logs to the nav. It was never in it.
|
||||
- [ ] Preserve the `soon:` entry treatment.
|
||||
- [ ] Update `dashboard_tools.go` for every new route in the same change.
|
||||
- [x] Add Logs to the nav. It was never in it.
|
||||
- [x] Preserve the `soon:` entry treatment.
|
||||
- [x] The theme control moves off the topbar and onto `/system/appearance`. Two
|
||||
switches for one preference is two places to look and one of them to be
|
||||
wrong; `components/topbar/ThemeToggle.vue` is deleted, not orphaned.
|
||||
- [x] Update `dashboard_tools.go` for every new route in the same change. The
|
||||
registry already carried all sixteen, so its parity test has been passing
|
||||
throughout; it is the check that a route cannot be added here and
|
||||
forgotten there.
|
||||
|
||||
## Phase 5 — Behaviour shipped today that a naive port loses
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
||||
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-x-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:"";--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-t:0;--scroll-fade-b:0;--scroll-fade-s:0;--scroll-fade-e:0;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}}}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-wght-normal.woff2)format("woff2-variations");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-vietnamese-wght-normal.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-wght-normal.woff2)format("woff2-variations");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@layer theme{:root,:host{--font-sans:"Geist Variable", sans-serif;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25 / 1.875);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-widest:.1em;--leading-snug:1.375;--leading-relaxed:1.625;--radius-xs:.125rem;--radius-md:10px;--radius-4xl:2rem;--blur-xl:24px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:"Geist Variable", sans-serif;--default-mono-font-family:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");fonLine truncated
|
||||
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){:root,:host{--shimmer-angle:20deg}*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-x-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:"";--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:none;--tw-animation-iteration-count:1;--tw-enter-blur:0;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-blur:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0;--scroll-fade-t:0;--scroll-fade-b:0;--scroll-fade-s:0;--scroll-fade-e:0;--scroll-fade-mask:initial;--shimmer-image:initial;--shimmer-text-fill:initial}}}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+460-52F,U+1C80-1C8A,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-cyrillic-wght-normal.woff2)format("woff2-variations");unicode-range:U+301,U+400-45F,U+490-491,U+4B0-4B1,U+2116}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-vietnamese-wght-normal.woff2)format("woff2-variations");unicode-range:U+102-103,U+110-111,U+128-129,U+168-169,U+1A0-1A1,U+1AF-1B0,U+300-301,U+303-304,U+308-309,U+323,U+329,U+1EA0-1EF9,U+20AB}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-ext-wght-normal.woff2)format("woff2-variations");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Geist Variable;font-style:normal;font-display:swap;font-weight:100 900;src:url(/assets/geist-latin-wght-normal.woff2)format("woff2-variations");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@layer theme{:root,:host{--font-sans:"Geist Variable", sans-serif;--color-black:#000;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-lg:32rem;--container-2xl:42rem;--container-3xl:48rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25 / 1.875);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-widest:.1em;--leading-tight:1.25;--leading-snug:1.375;--leading-normal:1.5;--leading-relaxed:1.625;--radius-xs:.125rem;--radius-md:10px;--radius-4xl:2rem;--shadow-md:0 4px 6px -1px #0000001a, 0 2px 4px -2px #0000001a;--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--blur-xs:4px;--blur-xl:24px;--default-transition-duration:.15Line truncated
|
||||
Vendored
+15
-8
@@ -1,13 +1,20 @@
|
||||
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(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 n=window.location.hash;if(n.startsWith(`#/`)){let e=n.slice(1);window.history.replaceState(null,``,e+window.location.search)}function r(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var i={},a=[],o=()=>{},s=()=>!1,c=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),l=e=>e.startsWith(`onUpdate:`),u=Object.assign,d=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},f=Object.prototype.hasOwnProperty,p=(e,t)=>f.call(e,t),m=Array.isArray,h=e=>T(e)===`[object Map]`,g=e=>T(e)===`[object Set]`,_=e=>T(e)===`[object Date]`,v=e=>T(e)===`[object RegExp]`,y=e=>typeof e==`function`,b=e=>typeof e==`string`,x=e=>typeof e==`symbol`,S=e=>typeof e==`object`&&!!e,C=e=>(S(e)||y(e))&&y(e.then)&&y(e.catch),w=Object.prototype.toString,T=e=>w.call(e),E=e=>T(e).slice(8,-1),D=e=>T(e)===`[object Object]`,ee=e=>b(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,te=r(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),ne=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},re=/-\w/g,O=ne(e=>e.replace(re,e=>e.slice(1).toUpperCase())),ie=/\B([A-Z])/g,ae=ne(e=>e.replace(ie,`-$1`).toLowerCase()),oe=ne(e=>e.charAt(0).toUpperCase()+e.slice(1)),k=ne(e=>e?`on${oe(e)}`:``),se=(e,t)=>!Object.is(e,t),ce=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},le=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},ue=e=>{let t=parseFloat(e);return isNaN(t)?e:t},de=e=>{let t=b(e)?Number(e):NaN;return isNaN(t)?e:t},fe,pe=()=>fe||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{},me=r(`Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol`);function A(e){if(m(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=b(r)?ve(r):A(r);if(i)for(let e in i)t[e]=i[e]}return t}if(b(e)||S(e))return e}var he=/;(?![^(]*\))/g,ge=/:([^]+)/,_e=/"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;function ve(e){let t={};return e.replace(_e,e=>e.startsWith(`/*`)?``:e).split(he).forEach(e=>{if(e){let n=e.split(ge);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function j(e){let t=``;if(b(e))t=e;else if(m(e))for(let n=0;n<e.length;n++){let r=j(e[n]);r&&(t+=r+` `)}else if(S(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}function ye(e){if(!e)return null;let{class:t,style:n}=e;return t&&!b(t)&&(e.class=j(t)),n&&(e.style=A(n)),e}var be=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,xe=r(be);be+``;function Se(e){return!!e||e===``}function Ce(e,t,n){if(e.length!==t.length)return!1;let r=!0;for(let i=0;r&&i<e.length;i++)r=De(e[i],t[i],n);return r}function we(e,t,n){if(e.size!==t.size)return!1;let r=Array.from(t),i=new Uint8Array(r.length);for(let t of e){let e=-1;for(let a=0;a<r.length;a++)if(!i[a]&&De(t,r[a],n)){e=a;break}if(e<0)return!1;i[e]=1}return!0}function Te(e,t,n){let r=h(e),i=h(t);if(r||i||(r=g(e),i=g(t),r||i))return r&&i?we(e,t,n):!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e){let i=e.hasOwnProperty(r),a=t.hasOwnProperty(r);if(i&&!a||!i&&a||!De(e[r],t[r],n))return!1}return String(e)===String(t)}function Ee(e,t,n,r){n||=[new Map,new Map];let[i,a]=n;if(i.has(e)||a.has(t))return i.get(e)===t&&a.get(t)===e;i.set(e,t),a.set(t,e);let o=r(e,t,n);return i.delete(e),a.delete(t),o}function De(e,t,n){if(e===t)return!0;let r=_(e),i=_(t);return r||i?r&&i?e.getTime()===t.getTime():!1:(r=x(e),i=x(t),r||i?e===t:(r=m(e),i=m(t),r||i?r&&i?Ee(e,t,n,Ce):!1:(r=S(e),i=S(t),r||i?!r||!i?!1:Ee(e,t,n,Te):String(e)===String(t))))}function Oe(e,t){return e.findIndex(e=>De(e,t))}var ke=e=>!!(e&&e.__v_isRef===!0),M=e=>b(e)?e:e==null?``:m(e)||S(e)&&(e.toString===w||!y(e.toString))?ke(e)?M(e.value):JSON.stringify(e,Ae,2):String(e),Ae=(e,t)=>ke(t)?Ae(e,t.value):h(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[je(t,r)+` =>`]=n,e),{})}:g(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>je(e))}:x(t)?je(t):SLine truncated
|
||||
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(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 n=window.location.hash;if(n.startsWith(`#/`)){let e=n.slice(1);window.history.replaceState(null,``,e+window.location.search)}function r(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var i={},a=[],o=()=>{},s=()=>!1,c=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),l=e=>e.startsWith(`onUpdate:`),u=Object.assign,d=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},f=Object.prototype.hasOwnProperty,p=(e,t)=>f.call(e,t),m=Array.isArray,h=e=>ee(e)===`[object Map]`,g=e=>ee(e)===`[object Set]`,_=e=>ee(e)===`[object Date]`,v=e=>ee(e)===`[object RegExp]`,y=e=>typeof e==`function`,b=e=>typeof e==`string`,x=e=>typeof e==`symbol`,S=e=>typeof e==`object`&&!!e,C=e=>(S(e)||y(e))&&y(e.then)&&y(e.catch),w=Object.prototype.toString,ee=e=>w.call(e),te=e=>ee(e).slice(8,-1),ne=e=>ee(e)===`[object Object]`,re=e=>b(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,ie=r(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),ae=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},oe=/-\w/g,se=ae(e=>e.replace(oe,e=>e.slice(1).toUpperCase())),ce=/\B([A-Z])/g,le=ae(e=>e.replace(ce,`-$1`).toLowerCase()),ue=ae(e=>e.charAt(0).toUpperCase()+e.slice(1)),T=ae(e=>e?`on${ue(e)}`:``),de=(e,t)=>!Object.is(e,t),fe=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},pe=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},me=e=>{let t=parseFloat(e);return isNaN(t)?e:t},he=e=>{let t=b(e)?Number(e):NaN;return isNaN(t)?e:t},ge,_e=()=>ge||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{},ve=r(`Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol`);function ye(e){if(m(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=b(r)?Ce(r):ye(r);if(i)for(let e in i)t[e]=i[e]}return t}if(b(e)||S(e))return e}var be=/;(?![^(]*\))/g,xe=/:([^]+)/,Se=/"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;function Ce(e){let t={};return e.replace(Se,e=>e.startsWith(`/*`)?``:e).split(be).forEach(e=>{if(e){let n=e.split(xe);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function E(e){let t=``;if(b(e))t=e;else if(m(e))for(let n=0;n<e.length;n++){let r=E(e[n]);r&&(t+=r+` `)}else if(S(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}function we(e){if(!e)return null;let{class:t,style:n}=e;return t&&!b(t)&&(e.class=E(t)),n&&(e.style=ye(n)),e}var Te=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,Ee=r(Te);Te+``;function De(e){return!!e||e===``}function Oe(e,t,n){if(e.length!==t.length)return!1;let r=!0;for(let i=0;r&&i<e.length;i++)r=Me(e[i],t[i],n);return r}function ke(e,t,n){if(e.size!==t.size)return!1;let r=Array.from(t),i=new Uint8Array(r.length);for(let t of e){let e=-1;for(let a=0;a<r.length;a++)if(!i[a]&&Me(t,r[a],n)){e=a;break}if(e<0)return!1;i[e]=1}return!0}function Ae(e,t,n){let r=h(e),i=h(t);if(r||i||(r=g(e),i=g(t),r||i))return r&&i?ke(e,t,n):!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e){let i=e.hasOwnProperty(r),a=t.hasOwnProperty(r);if(i&&!a||!i&&a||!Me(e[r],t[r],n))return!1}return String(e)===String(t)}function je(e,t,n,r){n||=[new Map,new Map];let[i,a]=n;if(i.has(e)||a.has(t))return i.get(e)===t&&a.get(t)===e;i.set(e,t),a.set(t,e);let o=r(e,t,n);return i.delete(e),a.delete(t),o}function Me(e,t,n){if(e===t)return!0;let r=_(e),i=_(t);return r||i?r&&i?e.getTime()===t.getTime():!1:(r=x(e),i=x(t),r||i?e===t:(r=m(e),i=m(t),r||i?r&&i?je(e,t,n,Oe):!1:(r=S(e),i=S(t),r||i?!r||!i?!1:je(e,t,n,Ae):String(e)===String(t))))}function Ne(e,t){return e.findIndex(e=>Me(e,t))}var Pe=e=>!!(e&&e.__v_isRef===!0),D=e=>b(e)?e:e==null?``:m(e)||S(e)&&(e.toString===w||!y(e.toString))?Pe(e)?D(e.value):JSON.stringify(e,Fe,2):String(e),Fe=(e,t)=>Pe(t)?Fe(e,t.value):h(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[Ie(t,r)+` =>`]=n,e),{})}:g(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>Ie(e))}Line truncated
|
||||
`&&(e.tagName===`PRE`||e.tagName===`TEXTAREA`)&&(n=n.slice(1));let{textContent:r}=e;r!==n&&r!==n.replace(/\r\n|\r/g,`
|
||||
`)&&(wi(e,0)||mi(),e.textContent=t.children)}if(d){if(_||b||!o||f&48){let t=e.tagName.includes(`-`),i=e.namespaceURI.includes(`svg`)?`svg`:e.namespaceURI.includes(`MathML`)?`mathml`:void 0;for(let a in d)if(_&&(a.endsWith(`value`)||a===`indeterminate`)||c(a)&&!te(a)||a[0]===`.`||t&&!te(a)||u&&u.includes(a)){if(xi(e,a,d[a]))continue;r(e,a,null,d[a],i,n)}}else if(d.onClick)r(e,`onClick`,null,d.onClick,void 0,n);else if(f&4&&rn(d.style))for(let e in d.style)d.style[e]}let x;(x=d&&d.onVnodeBeforeMount)&&As(x,n,t),h&&yr(t,null,n,`beforeMount`),((x=d&&d.onVnodeMounted)||h||l)&&as(()=>{x&&As(x,n,t),l&&g.enter(e),h&&yr(t,null,n,`mounted`)},i)}return e.nextSibling},m=(e,t,r,o,s,c,u)=>{u||=!!t.dynamicChildren;let d=t.children,p=d.length,m=!1;for(let t=0;t<p;t++){let h=u?d[t]:d[t]=Ds(d[t]),g=h.type===cs;e?(g&&!u&&t+1<p&&Ds(d[t+1]).type===cs&&(l(i(e.data.slice(h.children.length)),r,a(e)),e.data=h.children),e=f(e,h,o,s,c,u)):g&&!h.children?l(h.el=i(``),r):(m||(m=!0,wi(r,1)||mi()),n(null,h,r,null,o,s,_i(r),c))}return e},h=(e,t,n,r,i,s)=>{let{slotScopeIds:c}=t;c&&(i=i?i.concat(c):c);let d=o(e),f=m(a(e),t,d,n,r,i,s);return f&&vi(f)&&f.data===`]`?a(t.anchor=f):(mi(),l(t.anchor=u(`]`),d,f),f)},g=(e,t,r,i,c,l)=>{if(Ei(e,t)||mi(),t.el=null,l){let t=_(e);for(;;){let n=a(e);if(n&&n!==t)s(n);else break}}let u=a(e),d=o(e);return s(e),n(null,t,d,u,r,i,_i(d),c),r&&(r.vnode.el=t.el,vo(r,t.el)),u},_=(e,t=`[`,n=`]`)=>{let r=0;for(;e;)if(e=a(e),e&&vi(e)&&(e.data===t&&r++,e.data===n)){if(r===0)return a(e);r--}return e},v=(e,t,n)=>{let r=t.parentNode;r&&r.replaceChild(e,t);let i=n;for(;i;)i.vnode.el===t&&(i.vnode.el=i.subTree.el=e),i=i.parent},y=e=>e.nodeType===1&&e.tagName===`TEMPLATE`;return[d,f]}var bi=new Set([`src`,`srcset`,`href`,`poster`]);function xi(e,t,n){return bi.has(t)?e.getAttribute(t)===(n==null?null:`${n}`):!1}var Si=`data-allow-mismatch`,Ci={0:`text`,1:`children`,2:`class`,3:`style`,4:`attribute`};function wi(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(Si);)e=e.parentElement;return Ti(e&&e.getAttribute(Si),t)}function Ti(e,t){if(e==null)return!1;if(e===``)return!0;{let n=e.split(`,`);return t===0&&n.includes(`children`)?!0:n.includes(Ci[t])}}function Ei(e,t){return wi(e.parentElement,1)||Di(e)||Oi(t)}function Di(e){return e.nodeType===1&&Ti(e.getAttribute(Si),1)}function Oi({props:e}){let t=e&&e[Si];return typeof t==`string`&&Ti(t,1)}var ki=pe().requestIdleCallback||(e=>setTimeout(e,1)),Ai=pe().cancelIdleCallback||(e=>clearTimeout(e)),ji=(e=1e4)=>t=>{let n=ki(t,{timeout:e});return()=>Ai(n)};function Mi(e){let{top:t,left:n,bottom:r,right:i}=e.getBoundingClientRect(),{innerHeight:a,innerWidth:o}=window;return(t>0&&t<a||r>0&&r<a)&&(n>0&&n<o||i>0&&i<o)}var Ni=e=>(t,n)=>{let r=new IntersectionObserver(e=>{for(let n of e)if(n.isIntersecting){r.disconnect(),t();break}},e);return n(e=>{if(e instanceof Element){if(Mi(e))return t(),r.disconnect(),!1;r.observe(e)}}),()=>r.disconnect()},Pi=e=>t=>{if(e){let n=matchMedia(e);if(n.matches)t();else return n.addEventListener(`change`,t,{once:!0}),()=>n.removeEventListener(`change`,t)}},Fi=(e=[])=>(t,n)=>{b(e)&&(e=[e]);let r=!1,i=e=>{r||(r=!0,a(),t(),e.target.dispatchEvent(new e.constructor(e.type,e)))},a=()=>{n(t=>{for(let n of e)t.removeEventListener(n,i)})};return n(t=>{for(let n of e)t.addEventListener(n,i,{once:!0})}),a};function Ii(e,t){if(vi(e)&&e.data===`[`){let n=1,r=e.nextSibling;for(;r;){if(r.nodeType===1){if(t(r)===!1)break}else if(vi(r)){if(r.data===`]`){if(--n===0)break}else r.data===`[`&&n++}r=r.nextSibling}}else t(e)}var Li=e=>!!e.type.__asyncLoader;function Ri(e){y(e)&&(e={loader:e});let{loader:t,loadingComponent:n,errorComponent:r,delay:i=200,hydrate:a,timeout:o,suspensible:s=!0,onError:c}=e,l=null,u,d=0,f=()=>(d++,l=null,p()),p=()=>{let e;return l||(e=l=t().catch(e=>{if(e=e instanceof Error?e:Error(String(e)),c)return new Promise((t,n)=>{c(e,()=>t(f()),()=>n(e),d+1)});throw e}).then(t=>e!==l&&l?l:(t&&(t.__esModule||t[Symbol.toStringTag]===`Module`)&&(t=t.default),u=t,t)))};return R({name:`AsyncComponentWrapper`,__asyncLoader:p,__asyncHydrate(e,t,n){let r=e.isConnected,i=!1;(t.bu||=[]).push(()=>i=!0);let o=()=>{i||!e.parentNode||r&&!e.isConnected||n()},s=a?()=>{let n=a(o,t=>Ii(e,t));n&&(t.bum||=[]).push(n)}:o;u?s():p().then(()=>!t.isUnmounted&&s())},get __asyncResolved(){return u},setup(){let e=Ps;if(si(e),u)return()=>zi(u,e);let t=t=>{l=null,Gn(t,e,13,!r)};if(s&&e.suspense||Vs)return p().then(t=>()=>zi(t,e)).catch(e=>(t(e),()=>r?G(r,{error:e}):null));let a=P(!1),c=P(),d=P(!!i),f,m;return na(()=>{f!=null&&clearTimeout(f),m!=null&&clearTimeout(m)}),i&&(m=setTimeout(()=>{e.isUnmounted||(d.value=!1)},i)),o!=null&&(f=setTimeout(()=>{if(!e.isUnmounted&&!a.value&&!c.value){let e=Error(`Async component timed out after ${o}ms.`);t(e),c.value=e}},o)),p().then(()=>{e.isUnmounted||(a.value=!0,e.parent&&Bi(e.parent.vnode)&&e.parent.update())}).catch(n=>{if(e.isUnmounted){l=null;return}t(n),c.value=n}),()=>{if(a.value&&u)return zi(u,e);if(c.value&&r)return G(r,{error:c.value});if(n&&
Line truncated
|
||||
`))),e[Hl]=zl(i);let a=r||i.props&&i.props.type===`number`;ol(e,t?`change`:`input`,t=>{t.target.composing||e[Hl](Wl(e.value,n,a))}),(n||a)&&ol(e,`change`,()=>{e.value=Wl(e.value,n,a)}),t||(ol(e,`compositionstart`,Bl),ol(e,`compositionend`,Vl),ol(e,`change`,Vl))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[Ul];delete e[Ul],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[Hl](Wl(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Hl]=zl(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?ue(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},Kl={deep:!0,created(e,t,n){e[Hl]=zl(n),ol(e,`change`,()=>{let t=e._modelValue,n=Ql(e),r=e.checked,i=e[Hl];if(m(t)){let e=Oe(t,n),a=e!==-1;if(r&&!a)i(t.concat(n));else if(!r&&a){let n=[...t];n.splice(e,1),i(n)}}else if(g(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i($l(e,r))})},mounted:ql,beforeUpdate(e,t,n){e[Hl]=zl(n),ql(e,t,n)}};function ql(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(m(t))i=Oe(t,r.props.value)>-1;else if(g(t))i=t.has(r.props.value);else{if(t===n)return;i=De(t,$l(e,!0))}e.checked!==i&&(e.checked=i)}var Jl={created(e,{value:t},n){e.checked=De(t,n.props.value),e[Hl]=zl(n),ol(e,`change`,()=>{e[Hl](Ql(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Hl]=zl(r),t!==n&&(e.checked=De(t,r.props.value))}},Yl={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,ol(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?ue(Ql(e)):Ql(e)),r=e.multiple,i=r?g(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?m(i)?t.slice():t:i];try{e[Hl](i)}finally{er(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[Hl]=zl(r)},mounted(e,{value:t}){Zl(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[Hl]=zl(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!Xl(t,n[1],n[0]))&&Zl(e,t)}};function Xl(e,t,n){if(!n||m(e))return De(e,t);if(g(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function Zl(e,t){let n=e.multiple,r=m(t);if(!n||r||g(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=Ql(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):Oe(t,o)>-1}else a.selected=t.has(o)}else if(De(Ql(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function Ql(e){return`_value`in e?e._value:e.value}function $l(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var eu={created(e,t,n){nu(e,t,n,null,`created`)},mounted(e,t,n){nu(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){nu(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){nu(e,t,n,r,`updated`)}};function tu(e,t){switch(e){case`SELECT`:return Yl;case`TEXTAREA`:return Gl;default:switch(t){case`checkbox`:return Kl;case`radio`:return Jl;default:return Gl}}}function nu(e,t,n,r,i){let a=tu(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function ru(){Gl.getSSRProps=({value:e})=>({value:e}),Jl.getSSRProps=({value:e},t)=>{if(t.props&&De(t.props.value,e))return{checked:!0}},Kl.getSSRProps=({value:e},t)=>{if(m(e)){if(t.props&&Oe(e,t.props.value)>-1)return{checked:!0}}else if(g(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},eu.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=tu(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var iu=[`ctrl`,`shift`,`alt`,`meta`],au={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>iu.some(n=>e[`${n}Key`]&&!t.includes(n))},ou=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=au[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},su={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},cu=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=ae(n.key);if(t.some(e=>e===r||su[e]===r))return e(n)}))},lu=u({patchProp:vl},vc),uu,du=!1;function fu(){return uu||=Ro(lu)}function pu(){return uu=du?uu:zo(lu),du=!0,uu}var mu=((...e)=>{fu().render(...e)}),hu=((...e)=>{pu().hydrate(...e)}),gu=((...e)=>{let t=fu().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=yu(e);if(!r)return;let i=t._component;!y(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,vu(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t}),_u=((
Line truncated
|
||||
`)&&(Ai(e,0)||bi(),e.textContent=t.children)}if(d){if(_||b||!o||f&48){let t=e.tagName.includes(`-`),i=e.namespaceURI.includes(`svg`)?`svg`:e.namespaceURI.includes(`MathML`)?`mathml`:void 0;for(let a in d)if(_&&(a.endsWith(`value`)||a===`indeterminate`)||c(a)&&!ie(a)||a[0]===`.`||t&&!ie(a)||u&&u.includes(a)){if(Di(e,a,d[a]))continue;r(e,a,null,d[a],i,n)}}else if(d.onClick)r(e,`onClick`,null,d.onClick,void 0,n);else if(f&4&&ln(d.style))for(let e in d.style)d.style[e]}let x;(x=d&&d.onVnodeBeforeMount)&&Ps(x,n,t),h&&Tr(t,null,n,`beforeMount`),((x=d&&d.onVnodeMounted)||h||l)&&us(()=>{x&&Ps(x,n,t),l&&g.enter(e),h&&Tr(t,null,n,`mounted`)},i)}return e.nextSibling},m=(e,t,r,o,s,c,u)=>{u||=!!t.dynamicChildren;let d=t.children,p=d.length,m=!1;for(let t=0;t<p;t++){let h=u?d[t]:d[t]=js(d[t]),g=h.type===ps;e?(g&&!u&&t+1<p&&js(d[t+1]).type===ps&&(l(i(e.data.slice(h.children.length)),r,a(e)),e.data=h.children),e=f(e,h,o,s,c,u)):g&&!h.children?l(h.el=i(``),r):(m||(m=!0,Ai(r,1)||bi()),n(null,h,r,null,o,s,Ci(r),c))}return e},h=(e,t,n,r,i,s)=>{let{slotScopeIds:c}=t;c&&(i=i?i.concat(c):c);let d=o(e),f=m(a(e),t,d,n,r,i,s);return f&&wi(f)&&f.data===`]`?a(t.anchor=f):(bi(),l(t.anchor=u(`]`),d,f),f)},g=(e,t,r,i,c,l)=>{if(Mi(e,t)||bi(),t.el=null,l){let t=_(e);for(;;){let n=a(e);if(n&&n!==t)s(n);else break}}let u=a(e),d=o(e);return s(e),n(null,t,d,u,r,i,Ci(d),c),r&&(r.vnode.el=t.el,Co(r,t.el)),u},_=(e,t=`[`,n=`]`)=>{let r=0;for(;e;)if(e=a(e),e&&wi(e)&&(e.data===t&&r++,e.data===n)){if(r===0)return a(e);r--}return e},v=(e,t,n)=>{let r=t.parentNode;r&&r.replaceChild(e,t);let i=n;for(;i;)i.vnode.el===t&&(i.vnode.el=i.subTree.el=e),i=i.parent},y=e=>e.nodeType===1&&e.tagName===`TEMPLATE`;return[d,f]}var Ei=new Set([`src`,`srcset`,`href`,`poster`]);function Di(e,t,n){return Ei.has(t)?e.getAttribute(t)===(n==null?null:`${n}`):!1}var Oi=`data-allow-mismatch`,ki={0:`text`,1:`children`,2:`class`,3:`style`,4:`attribute`};function Ai(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(Oi);)e=e.parentElement;return ji(e&&e.getAttribute(Oi),t)}function ji(e,t){if(e==null)return!1;if(e===``)return!0;{let n=e.split(`,`);return t===0&&n.includes(`children`)?!0:n.includes(ki[t])}}function Mi(e,t){return Ai(e.parentElement,1)||Ni(e)||Pi(t)}function Ni(e){return e.nodeType===1&&ji(e.getAttribute(Oi),1)}function Pi({props:e}){let t=e&&e[Oi];return typeof t==`string`&&ji(t,1)}var Fi=_e().requestIdleCallback||(e=>setTimeout(e,1)),Ii=_e().cancelIdleCallback||(e=>clearTimeout(e)),Li=(e=1e4)=>t=>{let n=Fi(t,{timeout:e});return()=>Ii(n)};function Ri(e){let{top:t,left:n,bottom:r,right:i}=e.getBoundingClientRect(),{innerHeight:a,innerWidth:o}=window;return(t>0&&t<a||r>0&&r<a)&&(n>0&&n<o||i>0&&i<o)}var zi=e=>(t,n)=>{let r=new IntersectionObserver(e=>{for(let n of e)if(n.isIntersecting){r.disconnect(),t();break}},e);return n(e=>{if(e instanceof Element){if(Ri(e))return t(),r.disconnect(),!1;r.observe(e)}}),()=>r.disconnect()},Bi=e=>t=>{if(e){let n=matchMedia(e);if(n.matches)t();else return n.addEventListener(`change`,t,{once:!0}),()=>n.removeEventListener(`change`,t)}},Vi=(e=[])=>(t,n)=>{b(e)&&(e=[e]);let r=!1,i=e=>{r||(r=!0,a(),t(),e.target.dispatchEvent(new e.constructor(e.type,e)))},a=()=>{n(t=>{for(let n of e)t.removeEventListener(n,i)})};return n(t=>{for(let n of e)t.addEventListener(n,i,{once:!0})}),a};function Hi(e,t){if(wi(e)&&e.data===`[`){let n=1,r=e.nextSibling;for(;r;){if(r.nodeType===1){if(t(r)===!1)break}else if(wi(r)){if(r.data===`]`){if(--n===0)break}else r.data===`[`&&n++}r=r.nextSibling}}else t(e)}var Ui=e=>!!e.type.__asyncLoader;function Wi(e){y(e)&&(e={loader:e});let{loader:t,loadingComponent:n,errorComponent:r,delay:i=200,hydrate:a,timeout:o,suspensible:s=!0,onError:c}=e,l=null,u,d=0,f=()=>(d++,l=null,p()),p=()=>{let e;return l||(e=l=t().catch(e=>{if(e=e instanceof Error?e:Error(String(e)),c)return new Promise((t,n)=>{c(e,()=>t(f()),()=>n(e),d+1)});throw e}).then(t=>e!==l&&l?l:(t&&(t.__esModule||t[Symbol.toStringTag]===`Module`)&&(t=t.default),u=t,t)))};return M({name:`AsyncComponentWrapper`,__asyncLoader:p,__asyncHydrate(e,t,n){let r=e.isConnected,i=!1;(t.bu||=[]).push(()=>i=!0);let o=()=>{i||!e.parentNode||r&&!e.isConnected||n()},s=a?()=>{let n=a(o,t=>Hi(e,t));n&&(t.bum||=[]).push(n)}:o;u?s():p().then(()=>!t.isUnmounted&&s())},get __asyncResolved(){return u},setup(){let e=Rs;if(pi(e),u)return()=>Gi(u,e);let t=t=>{l=null,Zn(t,e,13,!r)};if(s&&e.suspense||Gs)return p().then(t=>()=>Gi(t,e)).catch(e=>(t(e),()=>r?B(r,{error:e}):null));let a=O(!1),c=O(),d=O(!!i),f,m;return ca(()=>{f!=null&&clearTimeout(f),m!=null&&clearTimeout(m)}),i&&(m=setTimeout(()=>{e.isUnmounted||(d.value=!1)},i)),o!=null&&(f=setTimeout(()=>{if(!e.isUnmounted&&!a.value&&!c.value){let e=Error(`Async component timed out after ${o}ms.`);t(e),c.value=e}},o)),p().then(()=>{e.isUnmounted||(a.value=!0,e.parent&&Ki(e.parent.vnode)&&e.parent.update())}).catch(n=>{if(e.isUnmounted){l=null;return}t(n),c.value=n}),()=>{if(a.value&&u)return Gi(u,e);if(c.value&&r)return B(r,{error:c.value});if(n&&
Line truncated
|
||||
`))),e[Kl]=Ul(i);let a=r||i.props&&i.props.type===`number`;ul(e,t?`change`:`input`,t=>{t.target.composing||e[Kl](Jl(e.value,n,a))}),(n||a)&&ul(e,`change`,()=>{e.value=Jl(e.value,n,a)}),t||(ul(e,`compositionstart`,Wl),ul(e,`compositionend`,Gl),ul(e,`change`,Gl))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[ql];delete e[ql],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[Kl](Jl(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Kl]=Ul(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?me(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},Xl={deep:!0,created(e,t,n){e[Kl]=Ul(n),ul(e,`change`,()=>{let t=e._modelValue,n=nu(e),r=e.checked,i=e[Kl];if(m(t)){let e=Ne(t,n),a=e!==-1;if(r&&!a)i(t.concat(n));else if(!r&&a){let n=[...t];n.splice(e,1),i(n)}}else if(g(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(ru(e,r))})},mounted:Zl,beforeUpdate(e,t,n){e[Kl]=Ul(n),Zl(e,t,n)}};function Zl(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(m(t))i=Ne(t,r.props.value)>-1;else if(g(t))i=t.has(r.props.value);else{if(t===n)return;i=Me(t,ru(e,!0))}e.checked!==i&&(e.checked=i)}var Ql={created(e,{value:t},n){e.checked=Me(t,n.props.value),e[Kl]=Ul(n),ul(e,`change`,()=>{e[Kl](nu(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Kl]=Ul(r),t!==n&&(e.checked=Me(t,r.props.value))}},$l={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,ul(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?me(nu(e)):nu(e)),r=e.multiple,i=r?g(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?m(i)?t.slice():t:i];try{e[Kl](i)}finally{or(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[Kl]=Ul(r)},mounted(e,{value:t}){tu(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[Kl]=Ul(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!eu(t,n[1],n[0]))&&tu(e,t)}};function eu(e,t,n){if(!n||m(e))return Me(e,t);if(g(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function tu(e,t){let n=e.multiple,r=m(t);if(!n||r||g(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=nu(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):Ne(t,o)>-1}else a.selected=t.has(o)}else if(Me(nu(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function nu(e){return`_value`in e?e._value:e.value}function ru(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var iu={created(e,t,n){ou(e,t,n,null,`created`)},mounted(e,t,n){ou(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){ou(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){ou(e,t,n,r,`updated`)}};function au(e,t){switch(e){case`SELECT`:return $l;case`TEXTAREA`:return Yl;default:switch(t){case`checkbox`:return Xl;case`radio`:return Ql;default:return Yl}}}function ou(e,t,n,r,i){let a=au(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function su(){Yl.getSSRProps=({value:e})=>({value:e}),Ql.getSSRProps=({value:e},t)=>{if(t.props&&Me(t.props.value,e))return{checked:!0}},Xl.getSSRProps=({value:e},t)=>{if(m(e)){if(t.props&&Ne(e,t.props.value)>-1)return{checked:!0}}else if(g(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},iu.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=au(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var cu=[`ctrl`,`shift`,`alt`,`meta`],lu={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>cu.some(n=>e[`${n}Key`]&&!t.includes(n))},uu=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=lu[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},du={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},fu=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=le(n.key);if(t.some(e=>e===r||du[e]===r))return e(n)}))},pu=u({patchProp:Sl},Sc),mu,hu=!1;function gu(){return mu||=Uo(pu)}function _u(){return mu=hu?mu:Wo(pu),hu=!0,mu}var vu=((...e)=>{gu().render(...e)}),yu=((...e)=>{_u().hydrate(...e)}),bu=((...e)=>{let t=gu().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Cu(e);if(!r)return;let i=t._component;!y(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,Su(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t}),xu=((
Line truncated
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var qf=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function Jf(e){let t=e instanceof qf?e.status:void 0,n=e instanceof Error&&e.message?e.message:`Action failed`;return t===401?{kind:`session-expired`,message:n}:t!==void 0&&t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Yf(e,t){let n=await fetch(e,t);if(!n.ok)throw new qf(await Kf(n),n.status);return n}async function Xf(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=Wf,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await Yf(e,s);return a?await c.json():void 0}var J={summary:()=>Xf(`/api/summary`),tasks:()=>Xf(`/api/tasks`),taskMeta:()=>Xf(`/api/task-meta`),task:e=>Xf(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Xf(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Xf(`/api/tasks/${encodeURIComponent(e)}/changes`+Gf(t)),taskDebug:(e,t)=>Xf(`/api/tasks/${encodeURIComponent(e)}/debug`+Gf(t)),taskAction:(e,t)=>Xf(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t}}),setup:()=>Xf(`/api/setup`),capabilities:()=>Xf(`/api/capabilities`),workflows:()=>Xf(`/api/workflows`),workRequest:e=>Xf(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Xf(`/api/skills`),channels:()=>Xf(`/api/channels`),curators:()=>Xf(`/api/curators`),channelReload:e=>Xf(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Xf(`/api/config`),version:()=>Xf(`/api/version`),configUpdate:e=>Xf(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>Xf(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>Xf(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>Xf(`/api/logs`+Gf(e)),taskLogs:(e,t)=>Xf(`/api/tasks/${encodeURIComponent(e)}/logs`+Gf(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>Xf(`/api/captures`+Gf({limit:e})),mappings:()=>Xf(`/api/mappings`),mappingCreate:e=>Xf(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Xf(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Xf(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Xf(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Xf(`/api/bindings`),bindingCreate:e=>Xf(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Xf(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Xf(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Xf(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),chatSessions:()=>Xf(`/api/chat/sessions`),chatMessages:e=>Xf(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>Xf(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>Xf(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>Xf(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:Uf(),text:t,page:location.pathname+location.search||`/`}}),chatPersona:(e,t)=>Xf(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>Xf(`/api/chat/update`),chatUpdateDefer:e=>Xf(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>Xf(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>Xf(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>Xf(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>Xf(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,t={})=>Yf(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t.signal})};function Zf(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 Qf(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(Hf(n.readyState)),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}var $f=`archie.web.chat.channel`;function ep(){let e=localStorage.getItem($f);return e||(e=Uf(),localStorage.setItem($f,e)),e}var tp=/(?:^|\s)\/([^\s]*)$/,np=/(?:^|\s)\/[^\s]*$/,rp=8;function ip(e,t,n){let r=t.slice(0,n).match(tp);if(!r)return[];let i=r[1].toLowerCase();return e.filter(e=>`${e.command} ${e.description??``}`.toLowerCase().includes(i)).slice(0,rp)}function ap(e,t,n){let r=e.slice(0,t),i=e.slice(t),a=r.search(np),o=a<0?r.length:a+ +(r[a]===` `);return{text:`${r.slice(0,o)}$Line truncated
|
||||
|
||||
`);u=r.pop()||``;for(let e of r){let t=e.split(`
|
||||
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(pp.value=n.session_id),n.type===`delta`&&(o+=n.text,vp.value=vp.value?{...vp.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],vp.value=vp.value?{...vp.value,tools:a}:null),n.type===`done`&&(s=!0,o||=n.text||``),n.type===`error`)throw Error(n.text)}if(t)break}if(!s)throw Error(`chat stream ended before completion`);mp.value=[...mp.value,{from:`assistant`,text:o,tool_calls:a}],vp.value=null,gp.value=`Ready`,await Np()}catch(e){let t=e;t.name===`AbortError`&&!c?(vp.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},gp.value=`Stopped`):(vp.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?cp(r):void 0,isRetry:i},gp.value=`Error — retry available`)}finally{clearTimeout(l),jp=null,_p.value=!1}}function Kp(){gp.value=`Stopping…`,pp.value&&J.chatCancel(pp.value).catch(()=>{}),Mp()}function qp(){ia(()=>{Np().catch(e=>{gp.value=e.message||`Chat unavailable`})}),ca(()=>{Mp()})}var Jp=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],Yp=M({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return q(`col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]`,e?`opacity-100`:`-rotate-45 scale-[0.7] opacity-0`)}return(t,i)=>(I(),L(`button`,{type:`button`,class:`relative z-10 grid size-14 cursor-pointer place-items-center rounded-full bg-linear-to-br from-primary to-[var(--brand-alt)] text-primary-foreground shadow-[var(--shadow-md)] transition-[transform,box-shadow] duration-[140ms] hover:-translate-y-px hover:shadow-[0_12px_34px_var(--primary-soft)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0`,"aria-label":e.open?`Close chat`:`Chat with Archie`,title:e.open?`Close chat`:`Chat with Archie`,"aria-expanded":e.open,"aria-controls":k(up),onClick:i[0]||=e=>n(`toggle`)},[z(`span`,{"aria-hidden":`true`,class:E(r(!e.open))},[B(k(Zu),{size:22})],2),z(`span`,{"aria-hidden":`true`,class:E(r(e.open))},[B(k(fd),{size:22})],2)],8,Jp))}});function Xp(e){return typeof e==`string`?`'${e}'`:new em().serialize(e)}var Zp=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,Qp=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Zp.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function $p(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length),r=0;for(let i=0;i<n;i++){let n=e.charCodeAt(i),a=t.charCodeAt(i);if(n===a)continue;let o=n<128&&Qp[n]?Qp[n]:n+128,s=a<128&&Qp[a]?Qp[a]:a+128;if(o!==s)return o<s?-1:1;r===0&&(r=n>a?-1:1)}return e.length===t.length?r:e.length<t.length?-1:1}var em=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?$p(e,t):n===`number`&&r===`number`?e-t:$p(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}let i=Object.keys(e).sort($p),a=`${r}{`;for(let t=0;t<i.length;t++){let n=i[t];a+=`${n}:${this.serialize(e[n])}`,t<i.length-1&&(a+=`,`)}return a+`}`}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`InLine truncated
|
||||
`)].join(`
|
||||
`))}return()=>i.value||r.value||o.value?tc(t.default({present:o.value})[0],{ref:e=>{let t=ep(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),rm=R({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=sp(n.default()),r=e.findIndex(e=>e.type!==ls);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?q(t,i.props):t,o=ws({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),im=[`area`,`img`,`input`],am=R({name:`Primitive`,inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:`div`}},setup(e,{attrs:t,slots:n}){let r=e.asChild?`template`:e.as;return typeof r==`string`&&im.includes(r)?()=>tc(r,t):r===`template`?()=>tc(rm,t,{default:n.default}):()=>tc(e.as,t,{default:n.default})}});function om(){let e=P();return{primitiveElement:e,currentElement:J(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:ep(e))}}var sm=`dismissableLayer.pointerDownOutside`,cm=`dismissableLayer.focusOutside`;function lm(e,t){if(!(t instanceof Element))return!1;let n=t.closest(`[data-dismissable-layer]`),r=e.dataset.dismissableLayer===``?e:e.querySelector(`[data-dismissable-layer]`),i=Array.from(e.ownerDocument.querySelectorAll(`[data-dismissable-layer]`));return!!(n&&(r===n||i.indexOf(r)<i.indexOf(n)))}function um(e,t,n=!0){let r=t?.value?.ownerDocument??globalThis?.document,i=P(!1),a=P(()=>{});return Tr(o=>{if(!Bf||!gn(n))return;let s=async n=>{let o=n.target;if(t?.value&&o){if(lm(t.value,o)){i.value=!1;return}if(n.target&&!i.value){let t={originalEvent:n};function i(){Ff(sm,e,t)}n.pointerType===`touch`?(r.removeEventListener(`click`,a.value),a.value=i,r.addEventListener(`click`,a.value,{once:!0})):i()}else r.removeEventListener(`click`,a.value);i.value=!1}},c=window.setTimeout(()=>{r.addEventListener(`pointerdown`,s)},0);o(()=>{window.clearTimeout(c),r.removeEventListener(`pointerdown`,s),r.removeEventListener(`click`,a.value)})}),{onPointerDownCapture:()=>{gn(n)&&(i.value=!0)}}}function dm(e,t,n=!0){let r=t?.value?.ownerDocument??globalThis?.document,i=P(!1);return Tr(a=>{if(!Bf||!gn(n))return;let o=async n=>{if(!t?.value)return;await er(),await er();let r=n.target;t.value&&r&&!lm(t.value,r)&&n.target&&!i.value&&Ff(cm,e,{originalEvent:n})};r.addEventListener(`focusin`,o),a(()=>r.removeEventListener(`focusin`,o))}),{onFocusCapture:()=>{gn(n)&&(i.value=!0)},onBlurCapture:()=>{gn(n)&&(i.value=!1)}}}var fm=R({__name:`DismissableLayer`,props:{disableOutsidePointerEvents:{type:Boolean,required:!1,default:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},present:{type:Boolean,required:!1,default:!0}},emits:[`escapeKeyDown`,`pointerDownOutside`,`focusOutside`,`interactOutside`,`dismiss`],setup(e,{emit:t}){let n=e,r=t,{forwardRef:i,currentElement:a}=Dp(),o=J(()=>a.value?.ownerDocument??globalThis.document),s=J(()=>pp.layersRoot),c=J(()=>a.value?Array.from(s.value).indexOf(a.value):-1),l=J(()=>pp.layersWithOutsidePointerEventsDisabled.size>0),u=J(()=>{let e=Array.from(s.value),[t]=[...pp.layersWithOutsidePointerEventsDisabled].slice(-1),n=e.indexOf(t);return c.value>=n}),d=um(async e=>{let t=[...pp.branches].some(t=>t?.contains(e.target));n.present&&u.value&&!t&&(r(`pointerDownOutside`,e),r(`interactOutside`,e),await er(),e.defaultPrevented||r(`dismiss`))},a,()=>n.present),f=dm(e=>{let t=[...pp.branches].some(t=>t?.contains(e.target));n.present&&!t&&(r(`focusOutside`,e),r(`interactOutside`,e),e.defaultPrevented||r(`dismiss`))},a);return ip(`Escape`,e=>{n.present&&c.value===s.value.size-1&&(r(`escapeKeyDown`,e),e.defaultPrevented||r(`dismiss`))}),L([a,()=>n.disableOutsidePointerEvents,()=>n.present],([e,t,n],r,i)=>{e&&n&&t&&(pp.layersWithOutsidePointerEventsDisabled.size===0&&(pp.originalBodyPointerEvents=o.value.body.style.pointerEvents,o.value.body.style.pointerEvents=`none`),pp.layersWithOutsidePointerEventsDisabled.add(e),i(()=>{pp.layersWithOutsidePointerEventsDisabled.delete(e),pp.layersWithOutsidePointerEventsDisabled.size===0&&!If(pp.originalBodyPointerEvents)&&(o.value.body.style.pointerEvents=pp.originalBodyPointerEvents)}))},{immediate:!0}),L([a,()=>n.present],([e,t],n,r)=>{e&&t&&(s.value.add(e),r(()=>{s.value.delete(e)}))},{immediate:!0}),Tr(e=>{e(()=>{a.value&&(s.value.delete(a.value),pp.layersWithOutsidePointerEventsDisabled.delete(a.value))})}),(e,t)=>(V(),U(F(am),{ref:F(i),"as-child":e.asChild,as:e.as,"data-dismissable-layer":``,style:A({pointerEvents:l.value?u.value?`auto`:`none`:void 0}),onFocusCapture:F(f).onFocusCapture,onBlurCapture:F(f).onBlurCapture,onPointerdownCapture:F(d).onPointerDownCapture},{default:I(()=>[z(e.$slots,`default`)]),_:3},8,[`as-child`,`as`,`style`,`onFocusCapture`,`onBlurCapture`,`onPointerdownCapture`]))}}),pm=zf(()=>P([]));function mm(){let e=pm();return{add(t){let n=e.value[0];t!==n&&n?.pause(),e.value=hm(e.value,t),e.value.unshift(t)},remove(t){e.value=hm
Line truncated
|
||||
`))}return()=>i.value||r.value||o.value?ac(t.default({present:o.value})[0],{ref:e=>{let t=Nm(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),zh=M({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=Hm(n.default()),r=e.findIndex(e=>e.type!==ms);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?U(t,i.props):t,o=ks({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),Bh=[`area`,`img`,`input`],X=M({name:`Primitive`,inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:`div`}},setup(e,{attrs:t,slots:n}){let r=e.asChild?`template`:e.as;return typeof r==`string`&&Bh.includes(r)?()=>ac(r,t):r===`template`?()=>ac(zh,t,{default:n.default}):()=>ac(e.as,t,{default:n.default})}});function Vh(){let e=O();return{primitiveElement:e,currentElement:W(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:Nm(e))}}function Hh({type:e,defaultValue:t,modelValue:n}){let r=n||t;return n!==void 0||t!==void 0?Array.isArray(r)?`multiple`:`single`:e??`single`}function Uh({type:e,defaultValue:t,modelValue:n}){return e||Hh({type:e,defaultValue:t,modelValue:n})}function Wh({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function Gh(e,t){let n=W(()=>Uh(e)),r=Vm(e,`modelValue`,t,{defaultValue:Wh(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=tm(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(sm(t,e)){let n=t.findIndex(t=>tm(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:W(()=>n.value===`single`)}}var[Kh,qh]=rm(`DialogRoot`),Jh=M({inheritAttrs:!1,__name:`DialogRoot`,props:{open:{type:Boolean,required:!1,default:void 0},defaultOpen:{type:Boolean,required:!1,default:!1},modal:{type:Boolean,required:!1,default:!0},unmountOnHide:{type:Boolean,required:!1,default:!0}},emits:[`update:open`],setup(e,{emit:t}){let n=e,r=Vm(n,`open`,t,{defaultValue:n.defaultOpen,passive:n.open===void 0}),i=O(),a=O(),{modal:o,unmountOnHide:s}=Dn(n);return qh({open:r,modal:o,unmountOnHide:s,openModal:()=>{r.value=!0},onOpenChange:e=>{r.value=e},onOpenToggle:()=>{r.value=!r.value},contentId:``,titleId:``,descriptionId:``,triggerElement:i,contentElement:a}),(e,t)=>P(e.$slots,`default`,{open:k(r),close:()=>r.value=!1})}}),Yh=M({__name:`DialogClose`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;Y();let n=Kh();return(e,r)=>(I(),R(k(X),U(t,{type:e.as===`button`?`button`:void 0,onClick:r[0]||=e=>k(n).onOpenChange(!1)}),{default:A(()=>[P(e.$slots,`default`)]),_:3},16,[`type`]))}}),Xh=`dismissableLayer.pointerDownOutside`,Zh=`dismissableLayer.focusOutside`;function Qh(e,t){if(!(t instanceof Element))return!1;let n=t.closest(`[data-dismissable-layer]`),r=e.dataset.dismissableLayer===``?e:e.querySelector(`[data-dismissable-layer]`),i=Array.from(e.ownerDocument.querySelectorAll(`[data-dismissable-layer]`));return!!(n&&(r===n||i.indexOf(r)<i.indexOf(n)))}function $h(e,t,n=!0){let r=t?.value?.ownerDocument??globalThis?.document,i=O(!1),a=O(()=>{});return jr(o=>{if(!dm||!Sn(n))return;let s=async n=>{let o=n.target;if(t?.value&&o){if(Qh(t.value,o)){i.value=!1;return}if(n.target&&!i.value){let t={originalEvent:n};function i(){am(Xh,e,t)}n.pointerType===`touch`?(r.removeEventListener(`click`,a.value),a.value=i,r.addEventListener(`click`,a.value,{once:!0})):i()}else r.removeEventListener(`click`,a.value);i.value=!1}},c=window.setTimeout(()=>{r.addEventListener(`pointerdown`,s)},0);o(()=>{window.clearTimeout(c),r.removeEventListener(`pointerdown`,s),r.removeEventListener(`click`,a.value)})}),{onPointerDownCapture:()=>{Sn(n)&&(i.value=!0)}}}function eg(e,t,n=!0){let r=t?.value?.ownerDocument??globalThis?.document,i=O(!1);return jr(a=>{if(!dm||!Sn(n))return;let o=async n=>{if(!t?.value)return;await or(),await or();let r=n.target;t.value&&r&&!Qh(t.value,r)&&n.target&&!i.value&&am(Zh,e,{originalEvent:n})};r.addEventListener(`focusin`,o),a(()=>r.removeEventListener(`focusin`,o))}),{onFocusCapture:()=>{Sn(n)&&(i.value=!0)},onBlurCapture:()=>{Sn(n)&&(i.value=!1)}}}var tg=M({__name:`DismissableLayer`,props:{disableOutsidePointerEvents:{type:Boolean,required:!1,default:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},present:{type:Boolean,required:!1,default:!0}},emits:[`escapeKeyDown`,`pointerDownOutside`,`focusOutside`,`interactOutside`,`dismiss`],setup(e,{emit:t}){let n=e,r=t,{forwardRef:i,currentElement:a}=Y(),o=W(()=>a.value?.ownerDocument??globalThis.document),s=W(()=>Jm.layersRoot),c=W(()=>a.value?Array.from(s.value).indexOf(a.value):-1),l=W(()=>Jm.layersWithOutsidePointerEventsDisabled.size>0),u=W(()=>{let e=Array.from(s.value),[t]=[...Jm.layersWithOutsidePointerEventsDisabled].slice(-1),n=e.indexOf(t);return c.value>=n}),d=$h
Line truncated
|
||||
- a positive number
|
||||
- less than the value passed to \`max\` (or ${J_} if no \`max\` prop is set)
|
||||
- less than the value passed to \`max\` (or ${Ab} if no \`max\` prop is set)
|
||||
- \`null\` or \`undefined\` if the progress is indeterminate.
|
||||
|
||||
Defaulting to \`null\`.`),null)}function $_(e){return Z_(e)&&!Number.isNaN(e)&&e>0?e:(console.error(`Invalid prop \`max\` of value \`${e}\` supplied to \`ProgressRoot\`. Only numbers greater than 0 are valid max values. Defaulting to \`${J_}\`.`),J_)}var ev=R({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:J_},getValueLabel:{type:Function,required:!1,default:(e,t)=>Z_(e)?`${Math.round(e/t*J_)}%`:void 0},getValueText:{type:Function,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:modelValue`,`update:max`],setup(e,{emit:t}){let n=e,r=t;Dp();let i=op(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=op(n,`max`,r,{passive:n.max===void 0});L(()=>i.value,async e=>{let t=Q_(e,n.max);t!==e&&(await er(),i.value=t)},{immediate:!0}),L(()=>n.max,e=>{let t=$_(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=J(()=>If(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return X_({modelValue:i,max:a,progressState:o}),(e,t)=>(V(),U(F(am),{"as-child":e.asChild,as:e.as,"aria-valuemax":F(a),"aria-valuemin":0,"aria-valuenow":Z_(F(i))?F(i):void 0,"aria-valuetext":e.getValueText?.(F(i),F(a)),"aria-label":e.getValueLabel(F(i),F(a)),role:`progressbar`,"data-state":o.value,"data-value":F(i)??void 0,"data-max":F(a)},{default:I(()=>[z(e.$slots,`default`,{modelValue:F(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),tv=R({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=Y_();return Dp(),(e,r)=>(V(),U(F(am),q(t,{"data-state":F(n).progressState.value,"data-value":F(n).modelValue?.value??void 0,"data-max":F(n).max.value}),{default:I(()=>[z(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),nv=R({__name:`TooltipArrow`,props:{width:{type:Number,required:!1,default:10},height:{type:Number,required:!1,default:5},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`svg`}},setup(e){let t=e;return Dp(),(e,n)=>(V(),U(F(u_),ye(Cs(t)),{default:I(()=>[z(e.$slots,`default`)]),_:3},16))}}),[rv,iv]=Nf(`TooltipProvider`),av=R({inheritAttrs:!1,__name:`TooltipProvider`,props:{delayDuration:{type:Number,required:!1,default:700},skipDelayDuration:{type:Number,required:!1,default:300},disableHoverableContent:{type:Boolean,required:!1,default:!1},disableClosingTrigger:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},ignoreNonKeyboardFocus:{type:Boolean,required:!1,default:!1},content:{type:Object,required:!1}},setup(e){let{delayDuration:t,skipDelayDuration:n,disableHoverableContent:r,disableClosingTrigger:i,ignoreNonKeyboardFocus:a,disabled:o,content:s}=xn(e);Dp();let c=P(!0),l=P(!1),{start:u,stop:d}=Zf(()=>{c.value=!0},n,{immediate:!1});return iv({isOpenDelayed:c,delayDuration:t,onOpen(){d(),c.value=!1},onClose(){u()},isPointerInTransitRef:l,disableHoverableContent:r,disableClosingTrigger:i,disabled:o,ignoreNonKeyboardFocus:a,content:s}),(e,t)=>z(e.$slots,`default`)}}),ov=`tooltip.open`,[sv,cv]=Nf(`TooltipRoot`),lv=R({__name:`TooltipRoot`,props:{defaultOpen:{type:Boolean,required:!1,default:!1},open:{type:Boolean,required:!1,default:void 0},delayDuration:{type:Number,required:!1,default:void 0},disableHoverableContent:{type:Boolean,required:!1,default:void 0},disableClosingTrigger:{type:Boolean,required:!1,default:void 0},disabled:{type:Boolean,required:!1,default:void 0},ignoreNonKeyboardFocus:{type:Boolean,required:!1,default:void 0}},emits:[`update:open`],setup(e,{emit:t}){let n=e,r=t;Dp();let i=rv(),a=J(()=>n.disableHoverableContent??i.disableHoverableContent.value),o=J(()=>n.disableClosingTrigger??i.disableClosingTrigger.value),s=J(()=>n.disabled??i.disabled.value),c=J(()=>n.delayDuration??i.delayDuration.value),l=J(()=>n.ignoreNonKeyboardFocus??i.ignoreNonKeyboardFocus.value),u=op(n,`open`,r,{defaultValue:n.defaultOpen,passive:n.open===void 0});L(u,e=>{i.onClose&&(e?(i.onOpen(),document.dispatchEvent(new CustomEvent(ov))):i.onClose())});let d=P(!1),f=P(),p=J(()=>u.value?d.value?`delayed-open`:`instant-open`:`closed`),{start:m,stop:h}=Zf(()=>{d.value=!0,u.value=!0},c,{immediate:!1});function g(){h(),d.value=!1,u.value=!0}function _(){h(),u.value=!1}function v(){m()}return cv({contentId:``,open:u,stateAttribute:p,trigger:f,onTriggerChange(e){f.value=e},onTriggerEnter(){i.isOpenDelayed.value?v():g()},onTriggerLeave(){a.value?_():h()},onOpen:g,onClose:_,disableHoverableContent:a,disableClosingTrigger:o,disabled:s,ignoreNonKeyboardFocus:l}),(e,t)=>(V(),U(F(Km),null,{default:I(()=>[z(e.$slots,`default`,{open:F(u)})]),_:3}))}}),uv=R({__name:`TooltipContentImpl`,props:{ariaLabel:{type:String,required:!1},asChild:{type:Boolean,required:!1,default:void 0},as:{type:null,required:!1},side:{type:null,required:!1},sideOffset:{type:Number,required:!1},align:{type:null,required:!1},alignOffset:{type:Number,required:!1},avoidCollisions:{type:BoolLine truncated
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Sx=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};async function Cx(e,t){let n=await fetch(e,t);if(!n.ok)throw new Sx(await xx(n),n.status);return n}async function $(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=yx,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await Cx(e,s);return a?await c.json():void 0}var wx={summary:()=>$(`/api/summary`),tasks:()=>$(`/api/tasks`),taskMeta:()=>$(`/api/task-meta`),task:e=>$(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>$(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>$(`/api/tasks/${encodeURIComponent(e)}/changes`+bx(t)),taskDebug:(e,t)=>$(`/api/tasks/${encodeURIComponent(e)}/debug`+bx(t)),taskAction:(e,t)=>$(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t}}),setup:()=>$(`/api/setup`),capabilities:()=>$(`/api/capabilities`),workflows:()=>$(`/api/workflows`),workRequest:e=>$(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>$(`/api/skills`),channels:()=>$(`/api/channels`),curators:()=>$(`/api/curators`),channelReload:e=>$(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>$(`/api/config`),version:()=>$(`/api/version`),configUpdate:e=>$(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>$(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>$(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>$(`/api/logs`+bx(e)),taskLogs:(e,t)=>$(`/api/tasks/${encodeURIComponent(e)}/logs`+bx(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>$(`/api/captures`+bx({limit:e})),mappings:()=>$(`/api/mappings`),mappingCreate:e=>$(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>$(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>$(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>$(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>$(`/api/bindings`),bindingCreate:e=>$(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>$(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>$(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>$(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),chatSessions:()=>$(`/api/chat/sessions`),chatMessages:e=>$(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>$(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>$(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>$(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:vx(),text:t,page:location.pathname+location.search||`/`}}),chatPersona:(e,t)=>$(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>$(`/api/chat/update`),chatUpdateDefer:e=>$(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>$(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>$(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>$(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>$(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,t={})=>Cx(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t.signal})};function Tx(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 Ex(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 Dx(e){return e==null||Number.isNaN(e)?`—`:new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(e)}var Ox=160;function kx(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>Ox?`${n.slice(0,Ox).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var Ax=`archie.setup-complete.dismissed.v1`;function jx(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?.(Ax),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function Mx(e=globalThis.localStorage){e?.setItem?.(Ax,`1`)}var Nx=new Set([`waiting_human`,`parked`]);function Px(e=[]){let t=e.filter(e=>Nx.has(e.status??``)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`/tasks?task=${encodeURIComponent(t[0].id)}`:`/tasks?status=needs_you`},running:{count:n.length,href:`/tasks?status=running`}}}var Fx={class:`mb-5 flex flex-wrap items-start justify-between gap-5`},Ix={class:`text-3xl font-semibold tracking-[-0.03em]`},Lx={class:`flex flex-wrap items-center gap-2`},Rx={class:`mb-5`},zx={class:`text-lg font-semibold text-primary`},Bx={class:`flex flex-col gap-3`},Vx={key:0,class:`mt-0.5 text-xs text-fg-subtle`},Hx={class:`mt-4 flex flex-col gap-2`},Ux={class:`truncate text-fg-muted`},Wx={key:0,class:`flex items-center justify-between gap-3 rounded-sm bg-muted px-3 py-2 text-sm`},Gx={key:0,class:`mb-5`},Kx={class:`grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-4`},qx={key:1,class:`mb-5`},Jx={class:`grid grid-cols-1 gap-4 min-[1080px]:grid-cols-[minmax(0,1fr)_minmax(0,1.5fr)]`},Yx={class:`mb-1 text-3xl font-semibold tracking-[-0.03em]`},Xx={class:`mb-4 text-xs text-fg-subtle`},Zx=[`title`],Qx=R({__name:`DashboardPage`,setup(e){let t=P([]),n=P(`connecting`),r=P(`idle`),i=P(new Map),a=P(null),o=P(null),s=P(null),c=P(null),l=P(null),u=qu(),d=P(0);Qi(async()=>{await p(),f=Tx(e=>{let n=[e,...t.value];n.splice(50),t.value=n},e=>{n.value=e,r.value=e===`live`?`ok`:`warn`})});let f;na(()=>f?.());async function p(){l.value=null;try{let[e,t,n,r]=await Promise.all([wx.summary(),wx.setup().catch(()=>null),wx.workflows().catch(()=>null),wx.tasks().catch(()=>[])]),l=new Map;for(let e of r)e.owner&&e.repo&&e.issue_number&&l.set(`${e.owner}/${e.repo}#${e.issue_number}`,Number(e.id));i.value=l,a.value=e,o.value=t,s.value=n,c.value=r}catch(e){l.value=String(e.message||e)}}function m(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}let h=e=>m(e,i.value);function g(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function _(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 v(e){u.push(`/tasks?task=${encodeURIComponent(e)}`)}function y(){Mx(),d.value+=1}let b=J(()=>o.value?.operator?`${g()}, ${o.value.operator}`:g()),x=J(()=>Px(c.value??[])),S=J(()=>jx(o.value)),C=J(()=>o.value?.steps??[]),w=J(()=>S.value.kind===`omit`||S.value.kind===`dismissed`),T=J(()=>{let e=o.value?.steps??[];return e.length?Math.round((e.length-S.value.remaining.length)/e.length*100):0}),E=J(()=>a.value?.statuses??{}),D=J(()=>a.value?.tokens_by_day??[]),ee=J(()=>D.value.map(e=>e.tokens||0)),te=J(()=>s.value?.workflows??[]),ne=J(()=>({runs:te.value.reduce((e,t)=>e+(t.runs||0),0),merged:te.value.reduce((e,t)=>e+(t.merged||0)+(t.pr_open||0),0),parked:te.value.reduce((e,t)=>e+(t.parked||0),0)})),re=J(()=>{let e=ee.value.reduce((e,t)=>e+t,0),t=ee.value.slice(-7).reduce((e,t)=>e+t,0),n=D.value.length?e/D.value.length:0;return{used:e,recent:t,perDay:n,projected:Math.round(n*30)}});return(e,i)=>(V(),H(`div`,null,[W(`div`,Fx,[W(`div`,null,[W(`h1`,Ix,M(b.value),1),i[0]||=W(`p`,{class:`mt-2 text-sm text-fg-muted`},` Your agent's control room — what it is working on, what needs you, and what it is spending. `,-1)]),W(`div`,Lx,[l.value?(V(),U(F(ix),{key:0,onClick:p},{default:I(()=>[G(F(gb),{"data-icon":`inline-start`}),i[1]||=K(` Retry `,-1)]),_:1})):c.value===null?Es(``,!0):(V(),H(B,{key:1},[x.value.attention.count>0?(V(),U(F(ix),{key:0,variant:`attention`,"as-child":``},{default:I(()=>[G(F(wf),{to:x.value.attention.href},{default:I(()=>[G(F(mb),{"data-icon":`inline-start`}),K(` `+M(x.value.attention.count)+` need`+M(x.value.attention.count===1?`s`:``)+` you `,1)]),_:1},8,[`to`])]),_:1})):Es(``,!0),x.value.running.count>0?(V(),U(F(ix),{key:1,variant:`outline`,"as-child":``},{default:I(()=>[G(F(wf),{to:x.value.running.href},{default:I(()=>[G(F(_b),{"data-icon":`inline-start`}),K(` `+M(x.value.running.count)+` running `,1)]),_:1},8,[`to`])]),_:1})):Es(``,!0),G(F(ix),{variant:`outline`,"as-child":``},{default:I(()=>[G(F(wf),{to:`/logs`},{default:I(()=>[G(F(bb),{"data-icon":`inline-start`}),i[2]||=K(` Logs `,-1)]),_:1})]),_:1}),G(F(ix),{onClick:p},{default:I(()=>[G(F(gb),{"data-icon":`inline-start`}),i[3]||=K(` Refresh `,-1)]),_:1})],64))])]),W(`section`,Rx,[i[13]||=W(`div`,{cla
Line truncated
|
||||
Defaulting to \`null\`.`),null)}function Fb(e){return Nb(e)&&!Number.isNaN(e)&&e>0?e:(console.error(`Invalid prop \`max\` of value \`${e}\` supplied to \`ProgressRoot\`. Only numbers greater than 0 are valid max values. Defaulting to \`${Ab}\`.`),Ab)}var Ib=M({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:Ab},getValueLabel:{type:Function,required:!1,default:(e,t)=>Nb(e)?`${Math.round(e/t*Ab)}%`:void 0},getValueText:{type:Function,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:modelValue`,`update:max`],setup(e,{emit:t}){let n=e,r=t;Y();let i=Vm(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=Vm(n,`max`,r,{passive:n.max===void 0});j(()=>i.value,async e=>{let t=Pb(e,n.max);t!==e&&(await or(),i.value=t)},{immediate:!0}),j(()=>n.max,e=>{let t=Fb(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=W(()=>om(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return Mb({modelValue:i,max:a,progressState:o}),(e,t)=>(I(),R(k(X),{"as-child":e.asChild,as:e.as,"aria-valuemax":k(a),"aria-valuemin":0,"aria-valuenow":Nb(k(i))?k(i):void 0,"aria-valuetext":e.getValueText?.(k(i),k(a)),"aria-label":e.getValueLabel(k(i),k(a)),role:`progressbar`,"data-state":o.value,"data-value":k(i)??void 0,"data-max":k(a)},{default:A(()=>[P(e.$slots,`default`,{modelValue:k(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),Lb=M({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=jb();return Y(),(e,r)=>(I(),R(k(X),U(t,{"data-state":k(n).progressState.value,"data-value":k(n).modelValue?.value??void 0,"data-max":k(n).max.value}),{default:A(()=>[P(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),[Rb,zb]=rm(`ScrollAreaRoot`),Bb=M({__name:`ScrollAreaRoot`,props:{type:{type:String,required:!1,default:`hover`},dir:{type:String,required:!1},scrollHideDelay:{type:Number,required:!1,default:600},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e,{expose:t}){let n=e,r=O(0),i=O(0),a=O(),o=O(),s=O(),c=O(),l=O(!1),u=O(!1),{type:d,dir:f,scrollHideDelay:p}=Dn(n),m=rh(f);function h(){a.value?.scrollTo({top:0})}function g(){a.value?.scrollTo({top:0,left:0})}t({viewport:a,scrollTop:h,scrollTopLeft:g});let{forwardRef:_,currentElement:v}=Y();return zb({type:d,dir:m,scrollHideDelay:p,scrollArea:v,viewport:a,onViewportChange:e=>{a.value=e||void 0},content:o,onContentChange:e=>{o.value=e},scrollbarX:s,scrollbarXEnabled:l,scrollbarY:c,scrollbarYEnabled:u,onScrollbarXChange:e=>{s.value=e||void 0},onScrollbarYChange:e=>{c.value=e||void 0},onScrollbarXEnabledChange:e=>{l.value=e},onScrollbarYEnabledChange:e=>{u.value=e},onCornerWidthChange:e=>{r.value=e},onCornerHeightChange:e=>{i.value=e}}),(e,t)=>(I(),R(k(X),{ref:k(_),"as-child":n.asChild,as:e.as,dir:k(m),style:ye({position:`relative`,"--reka-scroll-area-corner-width":`${r.value}px`,"--reka-scroll-area-corner-height":`${i.value}px`})},{default:A(()=>[P(e.$slots,`default`)]),_:3},8,[`as-child`,`as`,`dir`,`style`]))}}),Vb=M({__name:`ScrollAreaCornerImpl`,setup(e){let t=Rb(),n=O(0),r=O(0),i=W(()=>!!n.value&&!!r.value);function a(){let e=t.scrollbarX.value?.offsetHeight||0;t.onCornerHeightChange(e),r.value=e}function o(){let e=t.scrollbarY.value?.offsetWidth||0;t.onCornerWidthChange(e),n.value=e}return Bm(t.scrollbarX.value,a),Bm(t.scrollbarY.value,o),j(()=>t.scrollbarX.value,a),j(()=>t.scrollbarY.value,o),(e,a)=>i.value?(I(),R(k(X),U({key:0,style:{width:`${n.value}px`,height:`${r.value}px`,position:`absolute`,right:k(t).dir.value===`ltr`?0:void 0,left:k(t).dir.value===`rtl`?0:void 0,bottom:0}},e.$parent?.$props),{default:A(()=>[P(e.$slots,`default`)]),_:3},16,[`style`])):H(`v-if`,!0)}}),Hb=M({__name:`ScrollAreaCorner`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,{forwardRef:n}=Y(),r=Rb(),i=W(()=>!!r.scrollbarX.value&&!!r.scrollbarY.value),a=W(()=>r.type.value!==`scroll`&&i.value);return(e,r)=>a.value?(I(),R(Vb,U({key:0},t,{ref:k(n)}),{default:A(()=>[P(e.$slots,`default`)]),_:3},16)):H(`v-if`,!0)}});function Ub(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Wb(e){let t=Gb(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Gb(e,t){let n=e/t;return Number.isNaN(n)?0:n}function Kb(e,t=()=>{}){let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)})(),()=>window.cancelAnimationFrame(r)}function qb(e,t,n=`ltr`){let r=Wb(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=n===`ltr`?[0,o]:[o*-1,0],l=nm(e,c[0],c[1]);return Ub([0,o],[0,s])(l)}functLine truncated
|
||||
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:FC(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>FC(e))}),null)};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.push({kind:`pre`,code:a.join(`
|
||||
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=LC(c),u=e+1<n.length?LC(n[e+1]):null;if(l&&u&&RC(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=LC(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>FC(e)),rows:r.map(e=>e.map(e=>FC(e)))});continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.push({kind:`h${d[1].length}`,inline:FC(d[2])});continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tag!==e)&&(s(),i={tag:e,items:[]}),i.items.push((f||p)[1]);continue}if(c.startsWith(`>`)){o(),s(),t.push({kind:`blockquote`,inline:FC(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
|
||||
`)}),t}function LC(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 RC(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var zC={class:`[overflow-wrap:anywhere]`},BC={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},VC={class:`font-mono text-[0.85em]`},HC={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},UC={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},WC={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},GC={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},KC={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},qC={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},JC={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},YC={key:8,class:`mb-2.5 last:mb-0`},XC=M({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=W(()=>IC(t.text));return(e,t)=>(I(),L(`div`,zC,[(I(!0),L(F,null,N(n.value,(e,t)=>(I(),L(F,{key:t},[e.kind===`pre`?(I(),L(`pre`,BC,[z(`code`,VC,D(e.code),1)])):e.kind===`table`?(I(),L(`table`,HC,[z(`thead`,null,[z(`tr`,null,[(I(!0),L(F,null,N(e.head,(e,t)=>(I(),L(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[B(NC,{inline:e},null,8,[`inline`])]))),128))])]),z(`tbody`,null,[(I(!0),L(F,null,N(e.rows,(e,t)=>(I(),L(`tr`,{key:t},[(I(!0),L(F,null,N(e,(e,t)=>(I(),L(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[B(NC,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(I(),L(`blockquote`,UC,[B(NC,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(I(),L(`h1`,WC,[B(NC,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(I(),L(`h2`,GC,[B(NC,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(I(),L(`h3`,KC,[B(NC,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(I(),L(`ul`,qC,[(I(!0),L(F,null,N(e.items,(e,t)=>(I(),L(`li`,{key:t},[B(NC,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(I(),L(`ol`,JC,[(I(!0),L(F,null,N(e.items,(e,t)=>(I(),L(`li`,{key:t},[B(NC,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(I(),L(`p`,YC,[B(NC,{inline:e.inline},null,8,[`inline`])])):H(``,!0)],64))),128))]))}}),ZC={class:`truncate`},QC=M({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=ha(`RouterLink`);return I(),R(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-primary transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:A(()=>[B(k(Bu),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),z(`span`,ZC,D(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),$C={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},ew={class:`font-semibold text-foreground`},tw={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},nw=M({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=W(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=W(()=>t.tool.parameters||t.tool.Parameters||``),i=W(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=W(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(I(),R(QC,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(I(),L(`div`,$C,[B(k(dd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),z(`span`,ew,D(n.value),1),r.value?(I(),L(`code`,tw,D(r.value),1)):H(``,!0),z(`span`,{class:E(k(q)(`text-fg-muted`,i.value&&`text-danger`))},D(a.value),3)]))}}),rw={key:0,class:`mb-2 grid gap-0.5 text-xs`},iw={key:2,class:`whitespace-pre-wrap`},aw=M({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(I(),L(`div`,{class:E([`flex`,e.assistant?`justify-start`:`justify-end`])},[z(`div`,{class:E(k(q)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(I(),L(`div`,rw,[(I(!0),L(F,null,N(e.tools,(t,n)=>(I(),R(nw,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):H(``,!0),e.assistant?(I(),R(XC,{key:1,text:e.text},null,8,[`text`])):(I(),L(`div`,iw,D(e.text),1)),P(t.$slots,`default`)],2)],2))}}),ow={class:`w-full self-center justify-self-center py-6 text-center`},sw={class:`grid gap-2`},cw=[`onClick`],lw=M({__name:`ChatEmptyState`,emits:[`prompt`],setup(e,{emit:t}){let n=t,r=[`Summarise active tasks`,`Show running agents`,`Check system status`];return(e,t)=>(I(),L(`div`,ow,[t[0]||=z(`span`,{"aria-hidden":`true`,class:`mx-auto mb-3 grid size-9 pLine truncated
|
||||
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>Lk?`${n.slice(0,Lk).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var zk=[`title`],Bk=M({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=W(()=>sk(n.event)),a=W(()=>Rk(n.event));function o(){i.value>0&&r(`open`,i.value)}return(e,t)=>(I(),R(k(TD),{class:E(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[fu(uu(o,[`prevent`]),[`enter`]),fu(uu(o,[`prevent`]),[`space`])]},{default:A(()=>[B(k(Q),{class:`font-medium`},{default:A(()=>[V(D(n.event.kind||n.event.type||`event`),1)]),_:1}),B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(i.value>0?`#${i.value}`:`—`),1)]),_:1}),B(k(Q),{class:`w-[55%] max-w-0`},{default:A(()=>[z(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},D(a.value.text),9,zk)]),_:1}),B(k(Q),null,{default:A(()=>[V(D(k($D)(n.event.at||Date.now())),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),Vk=M({__name:`LiveActivityCard`,setup(e){let t=Vw();function n(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(I(),R(k(oD),null,{default:A(()=>[B(k(dD),null,{default:A(()=>[B(k(fD),null,{default:A(()=>[...t[0]||=[V(`Live activity`,-1)]]),_:1}),B(k(lD),null,{default:A(()=>[...t[1]||=[V(`Last 50, newest first`,-1)]]),_:1}),B(k(sD),null,{default:A(()=>[B(k(DD),{variant:k(rk)},{default:A(()=>[V(D(k(nk)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),B(k(cD),null,{default:A(()=>[B(k(CD),null,{default:A(()=>[B(k(ED),null,{default:A(()=>[B(k(TD),null,{default:A(()=>[B(k($),null,{default:A(()=>[...t[2]||=[V(`Event`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[3]||=[V(`Task`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[4]||=[V(`Detail`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...t[5]||=[V(`When`,-1)]]),_:1})]),_:1})]),_:1}),B(k(wD),null,{default:A(()=>[k(tk).length?(I(!0),L(F,{key:1},N(k(tk),(e,t)=>(I(),R(Bk,{key:t,event:e,onOpen:n},null,8,[`event`]))),128)):(I(),R(k(TD),{key:0},{default:A(()=>[B(k(Q),{colspan:`4`},{default:A(()=>[B(k(pD),null,{default:A(()=>[B(k(gD),null,{default:A(()=>[B(k(yD),null,{default:A(()=>[...t[6]||=[V(`Waiting for activity`,-1)]]),_:1}),B(k(hD),null,{default:A(()=>[...t[7]||=[V(`Events appear here as Archie works.`,-1)]]),_:1})]),_:1})]),_:1})]),_:1})]),_:1}))]),_:1})]),_:1})]),_:1})]),_:1}))}}),Hk=M({__name:`Progress`,props:{modelValue:{default:0},max:{},getValueLabel:{},getValueText:{},asChild:{type:Boolean},as:{},class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e,n=OS(t,`class`);return(e,r)=>(I(),R(k(Ib),U({"data-slot":`progress`},k(n),{class:k(q)(`bg-muted h-1 rounded-full relative flex w-full items-center overflow-x-hidden`,t.class)}),{default:A(()=>[B(k(Lb),{"data-slot":`progress-indicator`,class:`bg-primary size-full flex-1 transition-all`,style:ye(`transform: translateX(-${100-(t.modelValue??0)}%);`)},null,8,[`style`])]),_:1},16,[`class`]))}}),Uk=`archie.setup-complete.dismissed.v1`;function Wk(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?.(Uk),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function Gk(e=globalThis.localStorage){e?.setItem?.(Uk,`1`)}var Kk={class:`text-lg font-semibold text-primary`},qk={class:`flex flex-col gap-3`},Jk={key:0,class:`mt-0.5 text-xs text-fg-subtle`},Yk=M({__name:`SetupPanel`,setup(e){let t=O(Wk(ZO.value));j(ZO,()=>{t.value=Wk(ZO.value)});let n=W(()=>ZO.value?.steps??[]),r=W(()=>{let e=n.value.length;return e?Math.round((e-t.value.remaining.length)/e*100):0});function i(){Gk(),t.value=Wk(ZO.value)}return(e,a)=>t.value.kind===`incomplete`?(I(),R(k(oD),{key:0},{default:A(()=>[B(k(dD),null,{default:A(()=>[B(k(fD),null,{default:A(()=>[...a[0]||=[V(`Finish setting up`,-1)]]),_:1}),B(k(lD),null,{default:A(()=>[...a[1]||=[V(`Archie needs these before it can work on its own.`,-1)]]),_:1}),B(k(sD),null,{default:A(()=>[z(`span`,Kk,D(r.value)+`%`,1)]),_:1})]),_:1}),B(k(cD),null,{default:A(()=>[B(k(Hk),{"model-value":r.value,class:`mb-4`},null,8,[`model-value`]),z(`ul`,qk,[(I(!0),L(F,null,N(n.value,(e,t)=>(I(),L(`li`,{key:t,class:`flex items-start gap-3`},[z(`span`,{class:E([`mt-px grid size-[18px] flex-none place-items-center rounded-full border-[1.5px] border-border-strong text-xs text-fg-subtle`,e.done?`border-transparent bg-ok-soft text-ok`:``])},[e.done?(I(),R(k(Vu),{key:0,class:`size-3`})):H(``,!0)],2),z(`div`,null,[z(`div`,{class:E([`text-sm`,e.done?`text-fg-muted line-through`:``])},D(e.title),3),e.detail?(I(),L(`div`,Jk,D(e.detail),1)):H(``,!0)])]))),128))])]),_:1})]),_:1})):t.value.kind===`complete`?(I(),R(k(oD),{key:1},{default:A(()=>[B(k(dD),null,{default:A(()=>[B(k(fD),null,{default:A(()=>[...a[2]||=[V(`Setup complete`,-1)]]),_:1}),B(k(lD),null,{default:A(()=>[...a[3]||=[V(`ArLine truncated
|
||||
`)}return(e,i)=>k(MM)?(I(),R(_M,{key:0,title:`Update status`,description:`Not configured on this deployment, so there is nothing to check against.`})):k(jM)?(I(),R(k(oD),{key:1,class:`mb-4`},{default:A(()=>[B(k(cD),null,{default:A(()=>[B(k(pD),null,{default:A(()=>[B(k(gD),null,{default:A(()=>[B(k(yD),null,{default:A(()=>[...i[0]||=[V(`Update status unavailable`,-1)]]),_:1}),B(k(hD),null,{default:A(()=>[V(D(k(jM)),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})):(I(),R(_M,{key:2,title:`Update status`,description:`How each component is deployed, and whether what's running matches what's installed. Hover a row for the exact versions compared.`},{default:A(()=>[k(AM).length?(I(),R(k(CD),{key:1},{default:A(()=>[B(k(ED),null,{default:A(()=>[B(k(TD),null,{default:A(()=>[B(k($),null,{default:A(()=>[...i[3]||=[V(`Component`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...i[4]||=[V(`Install type`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...i[5]||=[V(`Running`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...i[6]||=[V(`Latest available`,-1)]]),_:1}),B(k($),null,{default:A(()=>[...i[7]||=[V(`Status`,-1)]]),_:1})]),_:1})]),_:1}),B(k(wD),null,{default:A(()=>[(I(!0),L(F,null,N(k(AM),e=>(I(),R(k(TD),{key:e.id||e.label,title:r(e)},{default:A(()=>[B(k(Q),{class:`font-medium`},{default:A(()=>[V(D(e.label||e.id),1)]),_:2},1024),B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(e.install_type||`—`),1)]),_:2},1024),B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(e.running_version||`—`),1)]),_:2},1024),B(k(Q),{class:`font-mono`},{default:A(()=>[V(D(e.latest_available||`—`),1)]),_:2},1024),B(k(Q),null,{default:A(()=>[B(k(DD),{variant:n[e.status||``]||`idle`},{default:A(()=>[V(D(t[e.status||``]||e.status),1)]),_:2},1032,[`variant`])]),_:2},1024)]),_:2},1032,[`title`]))),128))]),_:1})]),_:1})):(I(),R(k(pD),{key:0},{default:A(()=>[B(k(gD),null,{default:A(()=>[B(k(yD),null,{default:A(()=>[...i[1]||=[V(`No components reported`,-1)]]),_:1}),B(k(hD),null,{default:A(()=>[...i[2]||=[V(`The configured update-check command returned nothing.`,-1)]]),_:1})]),_:1})]),_:1}))]),_:1}))}}),JN=M({__name:`SystemStatusPage`,setup(e){async function t(){await Promise.all([kM(),NM(),FM()])}return ia(t),(e,n)=>(I(),L(`div`,null,[B(PE,{title:`Status`,subtitle:`What archied is running with right now.`},{default:A(()=>[B(k(Z),{variant:`outline`,onClick:t},{default:A(()=>[B(k(nd),{"data-icon":`inline-start`}),n[0]||=V(` Refresh `,-1)]),_:1})]),_:1}),B(vN),B(qN),B(KN),k(OM)?(I(),R(oN,{key:0})):(I(),L(F,{key:1},[B(HN),B(aN,{ids:k(eN)},null,8,[`ids`]),B(UN)],64))]))}}),YN=M({__name:`LifecycleActionList`,props:{actions:{}},setup(e){let t=e;function n(e){return e===`quiet`?`ghost`:e===`danger`?`destructive`:`outline`}return(e,r)=>(I(),L(F,null,[r[2]||=z(`h3`,{class:`mt-5 mb-2 text-sm font-semibold text-fg-muted`},`Actions`,-1),t.actions.length?(I(),R(yM,{key:1},{default:A(()=>[(I(!0),L(F,null,N(t.actions,e=>(I(),R($M,{key:e.id,label:e.id},{value:A(()=>[z(`span`,null,[B(k(Z),{variant:n(e.kind),size:`xs`,disabled:``},{default:A(()=>[V(D(e.label??e.id),1)]),_:2},1032,[`variant`])])]),_:2},1032,[`label`]))),128))]),_:1})):(I(),R(k(pD),{key:0},{default:A(()=>[B(k(gD),null,{default:A(()=>[B(k(yD),null,{default:A(()=>[...r[0]||=[V(`No actions reported`,-1)]]),_:1}),B(k(hD),null,{default:A(()=>[...r[1]||=[V(`The server did not return any operator actions.`,-1)]]),_:1})]),_:1})]),_:1}))],64))}}),XN=[{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`}],ZN=[{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`}],QN=vn([...XN]),$N=vn([...ZN]),eP=W(()=>new Map(QN.value.map(e=>[e.id,e]))),tP=W(()=>new Map($N.value.map(e=>[e.id,e])));async function nP(){try{let e=await J.taskMeta();Array.isArray(e?.statuses)&&(QN.value=e.statuses),Array.isArray(e?.actions)&&($N.value=e.actions)}catch{}}function rP(e){return eP.value.get(e)?.label||e||`Unknown`}function iP(e){return eP.value.get(e)?.kind||`idle`}function aP(){return QN.value}function oP(){return QN.value.map(e=>e.id)}function sP(){return new
Line truncated
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from "vue";
|
||||
|
||||
import ChatLauncher from "@/chat/ChatLauncher.vue";
|
||||
import Topbar from "@/components/topbar/Topbar.vue";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
import { hidden, loadCapabilities } from "@/lib/capabilities";
|
||||
@@ -51,5 +52,13 @@ onMounted(() => {
|
||||
</RouterView>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
Outside the shell on purpose: the frame above carries `backdrop-filter`,
|
||||
which makes it a containing block for `position: fixed`, so a launcher
|
||||
nested inside it would anchor to the shell rather than the viewport and
|
||||
ride off the bottom of a long page.
|
||||
-->
|
||||
<ChatLauncher />
|
||||
</TooltipProvider>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* The head every page opens with: what the page is, in a line, and the actions
|
||||
* that belong to it. A component rather than per-page markup because every page
|
||||
* has one, and hand-built copies drift.
|
||||
*/
|
||||
defineProps<{ title: string; subtitle?: string }>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mb-6 flex flex-wrap items-start justify-between gap-5">
|
||||
<div>
|
||||
<h1 class="text-2xl font-semibold tracking-[-0.02em]">{{ title }}</h1>
|
||||
<p v-if="subtitle" class="mt-1 text-sm text-fg-muted">{{ subtitle }}</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,152 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from "vue";
|
||||
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Field, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import {
|
||||
draftFromBinding,
|
||||
emptyDraft,
|
||||
type Binding,
|
||||
type BindingDraft,
|
||||
type MappingOption,
|
||||
type WorkflowOption,
|
||||
} from "./binding-draft";
|
||||
|
||||
/**
|
||||
* The binding editor: name, the matcher source senders POST to, the field
|
||||
* mapping, the workflow, an optional repo pin, and the shared secret their
|
||||
* signature is checked against.
|
||||
*/
|
||||
|
||||
const props = defineProps<{
|
||||
/** null is a new binding; a binding is an edit. */
|
||||
binding: Binding | null;
|
||||
mappings: MappingOption[];
|
||||
workflows: WorkflowOption[];
|
||||
saving: boolean;
|
||||
error: string | null;
|
||||
}>();
|
||||
|
||||
const open = defineModel<boolean>("open", { required: true });
|
||||
const emit = defineEmits<{ save: [draft: BindingDraft] }>();
|
||||
|
||||
// The draft is re-seeded on every open, so an edit that was cancelled -- or a
|
||||
// save that failed -- never leaks into the next binding's form.
|
||||
const draft = ref<BindingDraft>(emptyDraft());
|
||||
watch(
|
||||
open,
|
||||
(isOpen) => {
|
||||
if (isOpen) draft.value = props.binding ? draftFromBinding(props.binding) : emptyDraft();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
const title = computed(() => (props.binding ? "Edit binding" : "New binding"));
|
||||
const secretHint = computed(() =>
|
||||
props.binding
|
||||
? "Leave blank to keep the current secret."
|
||||
: "Senders sign with this via HMAC-SHA256.",
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="open">
|
||||
<!-- Seven fields make this taller than a short window; the dialog itself
|
||||
scrolls rather than clipping its own Save button. -->
|
||||
<DialogContent class="max-h-[85vh] overflow-y-auto sm:max-w-lg">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{{ title }}</DialogTitle>
|
||||
<DialogDescription>
|
||||
A binding is not armed until it is approved, and editing one drops it back to pending approval.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<Alert v-if="props.error" variant="destructive">
|
||||
<AlertTitle>Could not save</AlertTitle>
|
||||
<AlertDescription>{{ props.error }}</AlertDescription>
|
||||
</Alert>
|
||||
|
||||
<form @submit.prevent="emit('save', draft)">
|
||||
<FieldGroup>
|
||||
<Field>
|
||||
<FieldLabel for="binding-name">Name</FieldLabel>
|
||||
<Input id="binding-name" v-model="draft.name" />
|
||||
</Field>
|
||||
|
||||
<Field>
|
||||
<FieldLabel for="binding-source">Source</FieldLabel>
|
||||
<Input id="binding-source" v-model="draft.source" />
|
||||
<FieldDescription>The path segment senders POST to, for example "sentry".</FieldDescription>
|
||||
</Field>
|
||||
|
||||
<Field>
|
||||
<FieldLabel for="binding-mapping">Field mapping</FieldLabel>
|
||||
<Select v-model="draft.mappingId">
|
||||
<SelectTrigger id="binding-mapping" class="w-full">
|
||||
<SelectValue placeholder="Pick a saved mapping" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem v-for="mapping in props.mappings" :key="mapping.id" :value="String(mapping.id)">
|
||||
{{ mapping.name }}
|
||||
</SelectItem>
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
|
||||
<Field>
|
||||
<FieldLabel for="binding-workflow">Workflow</FieldLabel>
|
||||
<Select v-model="draft.workflow">
|
||||
<SelectTrigger id="binding-workflow" class="w-full">
|
||||
<SelectValue placeholder="Pick a workflow" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem v-for="workflow in props.workflows" :key="workflow.id" :value="workflow.id">
|
||||
{{ workflow.name }}
|
||||
</SelectItem>
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
|
||||
<Field>
|
||||
<div class="grid grid-cols-2 items-start gap-3">
|
||||
<Field>
|
||||
<FieldLabel for="binding-owner">Pinned owner</FieldLabel>
|
||||
<Input id="binding-owner" v-model="draft.owner" />
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel for="binding-repo">Pinned repo</FieldLabel>
|
||||
<Input id="binding-repo" v-model="draft.repo" />
|
||||
</Field>
|
||||
</div>
|
||||
<FieldDescription>
|
||||
Optional. A pin is both halves or neither, so leave both blank to use the single configured repo.
|
||||
</FieldDescription>
|
||||
</Field>
|
||||
|
||||
<Field>
|
||||
<FieldLabel for="binding-secret">Shared secret</FieldLabel>
|
||||
<Input id="binding-secret" v-model="draft.secret" type="password" autocomplete="off" />
|
||||
<FieldDescription>{{ secretHint }}</FieldDescription>
|
||||
</Field>
|
||||
</FieldGroup>
|
||||
|
||||
<DialogFooter class="mt-4">
|
||||
<Button type="button" variant="outline" @click="open = false">Cancel</Button>
|
||||
<Button type="submit" :disabled="props.saving">
|
||||
<Spinner v-if="props.saving" data-icon="inline-start" />
|
||||
{{ props.saving ? "Saving" : "Save" }}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</template>
|
||||
@@ -0,0 +1,45 @@
|
||||
<script setup lang="ts">
|
||||
import { Check, Pencil, Trash2 } from "@lucide/vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { TableCell, TableRow } from "@/components/ui/table";
|
||||
import BindingStatusBadge from "./BindingStatusBadge.vue";
|
||||
import { matcherSource, repoPin, type Binding } from "./binding-draft";
|
||||
|
||||
/** One saved binding's summary row. */
|
||||
const props = defineProps<{ binding: Binding }>();
|
||||
const emit = defineEmits<{
|
||||
edit: [binding: Binding];
|
||||
approve: [binding: Binding];
|
||||
delete: [binding: Binding];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TableRow>
|
||||
<TableCell class="font-medium">{{ props.binding.name }}</TableCell>
|
||||
<TableCell class="font-mono text-fg-muted">{{ matcherSource(props.binding) }}</TableCell>
|
||||
<TableCell>{{ props.binding.workflow || "—" }}</TableCell>
|
||||
<TableCell class="font-mono text-fg-muted">{{ repoPin(props.binding) }}</TableCell>
|
||||
<TableCell><BindingStatusBadge :status="props.binding.status" /></TableCell>
|
||||
<TableCell>
|
||||
<div class="flex items-center justify-end gap-1">
|
||||
<Button variant="outline" size="sm" @click="emit('edit', props.binding)">
|
||||
<Pencil data-icon="inline-start" />
|
||||
Edit
|
||||
</Button>
|
||||
<!-- Only a pending binding can be approved. A draft is not a state you
|
||||
approve from and an armed binding is already firing, so the button
|
||||
would be a no-op -- or worse, a misleading one. -->
|
||||
<Button v-if="props.binding.status === 'pending_approval'" size="sm" @click="emit('approve', props.binding)">
|
||||
<Check data-icon="inline-start" />
|
||||
Approve
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" @click="emit('delete', props.binding)">
|
||||
<Trash2 data-icon="inline-start" />
|
||||
Delete
|
||||
</Button>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { statusKind, statusLabel } from "./binding-draft";
|
||||
|
||||
/** A binding's lifecycle state: draft, pending approval, or armed. The
|
||||
* colour ramp is shared with every other status in the dashboard, so the
|
||||
* same colour means the same thing here as it does on a task. */
|
||||
const props = defineProps<{ status?: string }>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Badge :variant="statusKind(props.status)">{{ statusLabel(props.status) }}</Badge>
|
||||
</template>
|
||||
@@ -0,0 +1,112 @@
|
||||
<script setup lang="ts">
|
||||
import { Plus, RefreshCw } from "@lucide/vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import BindingEditor from "./BindingEditor.vue";
|
||||
import BindingsTable from "./BindingsTable.vue";
|
||||
import DeleteBindingDialog from "./DeleteBindingDialog.vue";
|
||||
import type { Binding, BindingDraft } from "./binding-draft";
|
||||
import { useBindings } from "./use-bindings";
|
||||
|
||||
/**
|
||||
* Playbook bindings (t2db.8): tie a matcher + payload mapping + workflow
|
||||
* together, with a draft -> pending_approval -> armed state machine so nothing
|
||||
* self-arms. See docs/architecture/bindings.md and
|
||||
* docs/prds/payload-field-mapping.md. Owner/Repo optionally pin a multi-repo
|
||||
* deployment's dispatch target (archie-core-t2db.8's backend fix, commit
|
||||
* ac42f64).
|
||||
*/
|
||||
|
||||
const {
|
||||
bindings,
|
||||
mappings,
|
||||
workflows,
|
||||
failure,
|
||||
actionFailure,
|
||||
saving,
|
||||
saveFailure,
|
||||
load,
|
||||
resetSaveFailure,
|
||||
save,
|
||||
approve,
|
||||
remove,
|
||||
} = useBindings();
|
||||
|
||||
const editorOpen = ref(false);
|
||||
// null is a new binding; a binding is an edit.
|
||||
const editing = ref<Binding | null>(null);
|
||||
const deleting = ref<Binding | null>(null);
|
||||
|
||||
onMounted(load);
|
||||
|
||||
function startCreate(): void {
|
||||
editing.value = null;
|
||||
resetSaveFailure();
|
||||
editorOpen.value = true;
|
||||
}
|
||||
|
||||
function startEdit(binding: Binding): void {
|
||||
editing.value = binding;
|
||||
resetSaveFailure();
|
||||
editorOpen.value = true;
|
||||
}
|
||||
|
||||
async function handleSave(draft: BindingDraft): Promise<void> {
|
||||
// The editor stays open on failure so the server's reason and the fields it
|
||||
// is about are still on screen together.
|
||||
if (await save(draft)) editorOpen.value = false;
|
||||
}
|
||||
|
||||
async function handleDelete(binding: Binding): Promise<void> {
|
||||
deleting.value = null;
|
||||
await remove(binding);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader
|
||||
title="Playbook bindings"
|
||||
subtitle="Tie a matcher, a field mapping, and a workflow together. New and edited bindings need explicit approval before they can fire."
|
||||
>
|
||||
<Button v-if="failure" @click="load">
|
||||
<RefreshCw data-icon="inline-start" />
|
||||
Retry
|
||||
</Button>
|
||||
<Button v-else @click="startCreate">
|
||||
<Plus data-icon="inline-start" />
|
||||
New binding
|
||||
</Button>
|
||||
</PageHeader>
|
||||
|
||||
<!-- A mutation that failed leaves the list on screen accurate, so its
|
||||
failure sits beside the list rather than replacing it. -->
|
||||
<Alert v-if="actionFailure" variant="destructive" class="mb-4">
|
||||
<AlertTitle>That did not take effect</AlertTitle>
|
||||
<AlertDescription>{{ actionFailure.message }}</AlertDescription>
|
||||
</Alert>
|
||||
|
||||
<BindingsTable
|
||||
:bindings="bindings"
|
||||
:failure="failure"
|
||||
@edit="startEdit"
|
||||
@approve="approve"
|
||||
@delete="deleting = $event"
|
||||
/>
|
||||
|
||||
<BindingEditor
|
||||
v-model:open="editorOpen"
|
||||
:binding="editing"
|
||||
:mappings="mappings"
|
||||
:workflows="workflows"
|
||||
:saving="saving"
|
||||
:error="saveFailure"
|
||||
@save="handleSave"
|
||||
/>
|
||||
|
||||
<DeleteBindingDialog :binding="deleting" @confirm="handleDelete" @cancel="deleting = null" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,86 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Table, TableBody, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||
import BindingRow from "./BindingRow.vue";
|
||||
import type { Binding } from "./binding-draft";
|
||||
import type { LoadFailure } from "./use-bindings";
|
||||
|
||||
const props = defineProps<{
|
||||
/** null means loading, [] means loaded and empty. */
|
||||
bindings: Binding[] | null;
|
||||
failure: LoadFailure | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
edit: [binding: Binding];
|
||||
approve: [binding: Binding];
|
||||
delete: [binding: Binding];
|
||||
}>();
|
||||
|
||||
const loading = computed(() => props.bindings === null);
|
||||
const rows = computed(() => props.bindings ?? []);
|
||||
|
||||
// The failure description is the daemon's own words. "bindings not configured"
|
||||
// answers a deployment with no binding store wired, and the operator can act on
|
||||
// that, where a blanket "cannot reach archied" would be false about a daemon
|
||||
// that answered.
|
||||
const failureTitle = computed(() =>
|
||||
props.failure?.kind === "unconfigured" ? "Bindings are not configured" : "Cannot reach archied",
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Empty v-if="props.failure">
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>{{ failureTitle }}</EmptyTitle>
|
||||
<EmptyDescription>{{ props.failure.message }}</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
|
||||
<Empty v-else-if="!loading && !rows.length">
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>No bindings yet</EmptyTitle>
|
||||
<EmptyDescription>
|
||||
Create one from a saved field mapping to turn a captured webhook into a workflow.
|
||||
</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
|
||||
<Card v-else>
|
||||
<CardContent>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Name</TableHead>
|
||||
<TableHead>Source</TableHead>
|
||||
<TableHead>Workflow</TableHead>
|
||||
<TableHead>Repo pin</TableHead>
|
||||
<TableHead>Status</TableHead>
|
||||
<TableHead />
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<template v-if="loading">
|
||||
<TableRow v-for="row in 3" :key="row">
|
||||
<TableCell v-for="col in 6" :key="col"><Skeleton class="h-4 w-full" /></TableCell>
|
||||
</TableRow>
|
||||
</template>
|
||||
<template v-else>
|
||||
<BindingRow
|
||||
v-for="binding in rows"
|
||||
:key="binding.id"
|
||||
:binding="binding"
|
||||
@edit="emit('edit', $event)"
|
||||
@approve="emit('approve', $event)"
|
||||
@delete="emit('delete', $event)"
|
||||
/>
|
||||
</template>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -0,0 +1,49 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import type { Binding } from "./binding-draft";
|
||||
|
||||
/** Confirming a delete, and nothing else. A binding cannot be recovered, so
|
||||
* the action is behind a dialog rather than a click. */
|
||||
const props = defineProps<{ binding: Binding | null }>();
|
||||
const emit = defineEmits<{ confirm: [binding: Binding]; cancel: [] }>();
|
||||
|
||||
// The binding is handed back by value so the confirmation stands on its own:
|
||||
// the dialog closes on the click, and the caller must not have to re-read
|
||||
// state that the close has already cleared.
|
||||
function confirm(): void {
|
||||
if (props.binding) emit("confirm", props.binding);
|
||||
}
|
||||
|
||||
// Reka closes the dialog on the action click, so this is what tells the caller
|
||||
// to forget the pending binding -- whether the delete happened or not.
|
||||
function onOpenChange(open: boolean): void {
|
||||
if (!open) emit("cancel");
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialog :open="props.binding !== null" @update:open="onOpenChange">
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Delete "{{ props.binding?.name }}"?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
It stops dispatching immediately and cannot be recovered. Captured events for its source keep
|
||||
arriving; they just stop starting tasks.
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction variant="destructive" @click="confirm">Delete</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</template>
|
||||
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* The bindings vocabulary: the wire shapes the daemon returns, the draft the
|
||||
* editor form edits, and the status ramp the list renders. Pure, so it reads
|
||||
* (and would test) without the page's fetch wiring -- the same split
|
||||
* binding-editor.jsx had from bindings.jsx in the Preact build.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A binding as GET /api/bindings returns it. Secret is never returned: the
|
||||
* daemon strips it from every read, and a blank secret on update is its
|
||||
* server-side "keep the current one".
|
||||
*/
|
||||
export interface Binding {
|
||||
id: number;
|
||||
name: string;
|
||||
matcher?: { source?: string };
|
||||
mapping_id?: number;
|
||||
workflow?: string;
|
||||
/** A pin is a complete owner/repo pair or not a pin at all. */
|
||||
owner?: string;
|
||||
repo?: string;
|
||||
status?: string;
|
||||
version?: number;
|
||||
}
|
||||
|
||||
/** The fields of GET /api/mappings this page needs. */
|
||||
export interface MappingOption {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
/** One entry of GET /api/workflows' `definitions`. */
|
||||
export interface WorkflowOption {
|
||||
id: string;
|
||||
name: string;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
/** The Badge variants a binding status maps onto. */
|
||||
export type StatusKind = "ok" | "warn" | "idle";
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
draft: "draft",
|
||||
pending_approval: "pending approval",
|
||||
armed: "armed",
|
||||
};
|
||||
|
||||
const STATUS_KINDS: Record<string, StatusKind> = {
|
||||
draft: "idle",
|
||||
pending_approval: "warn",
|
||||
armed: "ok",
|
||||
};
|
||||
|
||||
/** A status the daemon grows later renders as itself in the neutral kind,
|
||||
* rather than as an unlabelled pill. */
|
||||
export function statusLabel(status?: string): string {
|
||||
if (!status) return "unknown";
|
||||
return STATUS_LABELS[status] ?? status;
|
||||
}
|
||||
|
||||
export function statusKind(status?: string): StatusKind {
|
||||
return STATUS_KINDS[status ?? ""] ?? "idle";
|
||||
}
|
||||
|
||||
/**
|
||||
* The editor's field state. mappingId is the select's string value because a
|
||||
* select's model is its option values; the store's mapping_id is a number.
|
||||
*/
|
||||
export interface BindingDraft {
|
||||
id: number | null;
|
||||
name: string;
|
||||
source: string;
|
||||
mappingId: string;
|
||||
workflow: string;
|
||||
owner: string;
|
||||
repo: string;
|
||||
secret: string;
|
||||
}
|
||||
|
||||
export function emptyDraft(): BindingDraft {
|
||||
return {
|
||||
id: null,
|
||||
name: "",
|
||||
source: "",
|
||||
mappingId: "",
|
||||
workflow: "",
|
||||
owner: "",
|
||||
repo: "",
|
||||
secret: "",
|
||||
};
|
||||
}
|
||||
|
||||
export function draftFromBinding(binding: Binding): BindingDraft {
|
||||
return {
|
||||
id: binding.id,
|
||||
name: binding.name,
|
||||
source: binding.matcher?.source || "",
|
||||
mappingId: binding.mapping_id ? String(binding.mapping_id) : "",
|
||||
workflow: binding.workflow || "",
|
||||
owner: binding.owner || "",
|
||||
repo: binding.repo || "",
|
||||
// Deliberately blank: the secret is never sent to the browser, and an
|
||||
// empty one on update keeps whatever the sender already signs with.
|
||||
secret: "",
|
||||
};
|
||||
}
|
||||
|
||||
/** The body POST /api/bindings and PATCH /api/bindings/{id} both accept. A
|
||||
* blank mapping is 0, which the store rejects -- a binding with no mapping
|
||||
* could never be dispatched. */
|
||||
export function bindingPayload(draft: BindingDraft): Record<string, unknown> {
|
||||
return {
|
||||
name: draft.name,
|
||||
matcher: { source: draft.source },
|
||||
mapping_id: Number(draft.mappingId) || 0,
|
||||
workflow: draft.workflow,
|
||||
owner: draft.owner,
|
||||
repo: draft.repo,
|
||||
secret: draft.secret,
|
||||
};
|
||||
}
|
||||
|
||||
/** The repo pin a row shows, or an em dash when the binding takes the
|
||||
* single-configured-repo default. */
|
||||
export function repoPin(binding: Binding): string {
|
||||
return binding.owner && binding.repo ? `${binding.owner}/${binding.repo}` : "—";
|
||||
}
|
||||
|
||||
/** The matcher source a row shows: the path segment senders POST to. */
|
||||
export function matcherSource(binding: Binding): string {
|
||||
return binding.matcher?.source || "—";
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
import { ref } from "vue";
|
||||
|
||||
import { api, ApiError } from "@/lib/api";
|
||||
import {
|
||||
bindingPayload,
|
||||
type Binding,
|
||||
type BindingDraft,
|
||||
type MappingOption,
|
||||
type WorkflowOption,
|
||||
} from "./binding-draft";
|
||||
|
||||
/**
|
||||
* Why the page has nothing to show. "unconfigured" is a daemon with no
|
||||
* bindings store wired (501/503) -- the feature is off, which reads very
|
||||
* differently from a daemon that answered badly.
|
||||
*/
|
||||
export type LoadFailureKind = "unconfigured" | "failed";
|
||||
|
||||
export interface LoadFailure {
|
||||
kind: LoadFailureKind;
|
||||
message: string;
|
||||
}
|
||||
|
||||
function failureFor(err: unknown): LoadFailure {
|
||||
const message = err instanceof Error && err.message ? err.message : String(err);
|
||||
const status = err instanceof ApiError ? err.status : undefined;
|
||||
return { kind: status === 501 || status === 503 ? "unconfigured" : "failed", message };
|
||||
}
|
||||
|
||||
/**
|
||||
* The bindings page's data: the three lists the list and the editor read, the
|
||||
* load that fills them, and the three mutations. Every mutation goes through
|
||||
* api.* so the CSRF and Content-Type headers are sent -- a bare fetch is
|
||||
* refused 403/415 by archied's mutation guard.
|
||||
*/
|
||||
export function useBindings() {
|
||||
// null means loading, [] means loaded and empty.
|
||||
const bindings = ref<Binding[] | null>(null);
|
||||
const mappings = ref<MappingOption[]>([]);
|
||||
const workflows = ref<WorkflowOption[]>([]);
|
||||
const failure = ref<LoadFailure | null>(null);
|
||||
// A failed mutation is not a failed load: the list on screen is still
|
||||
// accurate, so it keeps rendering and the failure lands beside it.
|
||||
const actionFailure = ref<LoadFailure | null>(null);
|
||||
const saving = ref(false);
|
||||
const saveFailure = ref<string | null>(null);
|
||||
|
||||
async function load(): Promise<void> {
|
||||
failure.value = null;
|
||||
try {
|
||||
const [b, m, w] = await Promise.all([
|
||||
api.bindings<{ bindings?: Binding[] }>(),
|
||||
api.mappings<{ mappings?: MappingOption[] }>(),
|
||||
api.workflows<{ definitions?: WorkflowOption[] }>(),
|
||||
]);
|
||||
bindings.value = b.bindings || [];
|
||||
mappings.value = m.mappings || [];
|
||||
// Only enabled definitions are offerable: binding to a disabled one
|
||||
// would persist a binding that can never dispatch.
|
||||
workflows.value = (w.definitions || []).filter((d) => d.enabled);
|
||||
} catch (err) {
|
||||
failure.value = failureFor(err);
|
||||
bindings.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
function resetSaveFailure(): void {
|
||||
saveFailure.value = null;
|
||||
}
|
||||
|
||||
/** True when the binding was written, so the caller knows to close. */
|
||||
async function save(draft: BindingDraft): Promise<boolean> {
|
||||
saving.value = true;
|
||||
saveFailure.value = null;
|
||||
try {
|
||||
const body = bindingPayload(draft);
|
||||
if (draft.id) {
|
||||
await api.bindingUpdate(String(draft.id), body);
|
||||
} else {
|
||||
await api.bindingCreate(body);
|
||||
}
|
||||
await load();
|
||||
return true;
|
||||
} catch (err) {
|
||||
saveFailure.value = err instanceof Error && err.message ? err.message : String(err);
|
||||
return false;
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function approve(binding: Binding): Promise<void> {
|
||||
actionFailure.value = null;
|
||||
try {
|
||||
await api.bindingApprove(String(binding.id));
|
||||
await load();
|
||||
} catch (err) {
|
||||
actionFailure.value = failureFor(err);
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(binding: Binding): Promise<void> {
|
||||
actionFailure.value = null;
|
||||
try {
|
||||
await api.bindingDelete(String(binding.id));
|
||||
await load();
|
||||
} catch (err) {
|
||||
actionFailure.value = failureFor(err);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
bindings,
|
||||
mappings,
|
||||
workflows,
|
||||
failure,
|
||||
actionFailure,
|
||||
saving,
|
||||
saveFailure,
|
||||
load,
|
||||
resetSaveFailure,
|
||||
save,
|
||||
approve,
|
||||
remove,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { RefreshCw } from "@lucide/vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { load } from "./state";
|
||||
|
||||
/** Read the list again, for an operator who does not want to wait for the
|
||||
* stream to invalidate it. */
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Button variant="outline" @click="load">
|
||||
<RefreshCw data-icon="inline-start" />
|
||||
Refresh
|
||||
</Button>
|
||||
</template>
|
||||
@@ -0,0 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from "vue";
|
||||
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@/components/ui/sheet";
|
||||
import { ago } from "@/lib/format";
|
||||
import CapturePayload from "./CapturePayload.vue";
|
||||
import { selected, type Capture } from "./state";
|
||||
|
||||
/**
|
||||
* One capture's payload and headers, opened from its row. A side panel rather
|
||||
* than a taller row: a payload runs to thousands of characters, and the list
|
||||
* has to stay a list while it is read.
|
||||
*/
|
||||
|
||||
const open = computed({
|
||||
get: () => selected.value !== null,
|
||||
set: (value: boolean) => {
|
||||
if (!value) selected.value = null;
|
||||
},
|
||||
});
|
||||
|
||||
// What the panel renders. The list drops the selection as soon as this sheet
|
||||
// reports closed, and the panel stays mounted through the close animation, so
|
||||
// reading the shared ref would blank it halfway out. Nothing goes stale here:
|
||||
// a stored capture is never rewritten.
|
||||
const shown = ref<Capture | null>(null);
|
||||
watch(selected, (next) => {
|
||||
if (next) shown.value = next;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Sheet v-model:open="open">
|
||||
<SheetContent class="w-full gap-0 sm:max-w-2xl">
|
||||
<SheetHeader>
|
||||
<SheetTitle>{{ shown?.source || "Unknown source" }}</SheetTitle>
|
||||
<SheetDescription>
|
||||
{{ ago(shown?.received_at) }} · {{ shown?.content_type || "no content type" }}
|
||||
</SheetDescription>
|
||||
</SheetHeader>
|
||||
<Separator />
|
||||
<ScrollArea class="min-h-0 flex-1">
|
||||
<div class="flex flex-col gap-5 p-4">
|
||||
<CapturePayload label="Payload" :raw="shown?.body" />
|
||||
<CapturePayload label="Headers" :raw="shown?.headers" />
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
</template>
|
||||
@@ -0,0 +1,30 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
|
||||
import { prettyPrint } from "./capture-payload";
|
||||
|
||||
/**
|
||||
* One labelled block of a capture: its body or its headers, as text. Both are
|
||||
* stored as strings, valid JSON or not, so both go through the same reader.
|
||||
*/
|
||||
const props = defineProps<{ label: string; raw?: string }>();
|
||||
|
||||
const text = computed(() => prettyPrint(props.raw));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="min-w-0">
|
||||
<h3 class="mb-2 text-xs font-semibold tracking-[0.05em] text-fg-subtle uppercase">{{ label }}</h3>
|
||||
<!--
|
||||
Wrap rather than scroll sideways: a captured payload is mostly long
|
||||
unbroken tokens (URLs, hashes, base64), and one of those on a single line
|
||||
would push the panel's contents past its edge instead of being read.
|
||||
-->
|
||||
<p v-if="!text" class="text-sm text-fg-muted">(empty)</p>
|
||||
<pre
|
||||
v-else
|
||||
class="rounded-sm border border-border-strong bg-muted p-3 font-mono text-xs whitespace-pre-wrap wrap-break-word"
|
||||
>{{ text }}</pre
|
||||
>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
import { ChevronRight } from "@lucide/vue";
|
||||
import { computed } from "vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { TableCell, TableRow } from "@/components/ui/table";
|
||||
import { ago } from "@/lib/format";
|
||||
import { selected, type Capture } from "./state";
|
||||
|
||||
/**
|
||||
* One captured event. The row is the control, not a button sitting in one
|
||||
* cell: opening the payload is the row's whole job, and a keyboard user has to
|
||||
* reach what a mouse user clicks -- which is why it is focusable and both
|
||||
* Enter and Space open it.
|
||||
*/
|
||||
const props = defineProps<{ capture: Capture }>();
|
||||
|
||||
const isSelected = computed(() => selected.value?.id === props.capture.id);
|
||||
|
||||
// The name is set here because role="button" makes the cells presentational:
|
||||
// what a screen reader reads is this, not five unrelated columns.
|
||||
const label = computed(() => `View the payload received from ${props.capture.source || "an unknown source"}`);
|
||||
|
||||
function open(): void {
|
||||
selected.value = props.capture;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TableRow
|
||||
:data-state="isSelected ? 'selected' : undefined"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
aria-haspopup="dialog"
|
||||
:aria-label="label"
|
||||
class="cursor-pointer focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring"
|
||||
@click="open"
|
||||
@keydown.enter.prevent="open"
|
||||
@keydown.space.prevent="open"
|
||||
>
|
||||
<TableCell class="font-mono">{{ props.capture.source || "(unknown)" }}</TableCell>
|
||||
<TableCell :title="props.capture.received_at || ''">{{ ago(props.capture.received_at) }}</TableCell>
|
||||
<!-- A stored capture carries no claim from a binding, so this reads Unbound
|
||||
for every row: the column is where a claim would appear, not a state a
|
||||
reader can act on today. -->
|
||||
<TableCell><Badge variant="idle">Unbound</Badge></TableCell>
|
||||
<TableCell class="font-mono">{{ props.capture.content_type || "—" }}</TableCell>
|
||||
<TableCell class="text-right">
|
||||
<ChevronRight class="size-4 text-fg-subtle" />
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { streamKind, streamState } from "./state";
|
||||
|
||||
/**
|
||||
* The state of the stream that is supposed to be adding to this list. Without
|
||||
* it a list that has stopped updating looks exactly like a quiet one.
|
||||
*/
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Badge :variant="streamKind">{{ streamState }}</Badge>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
|
||||
import CapturesList from "./CapturesList.vue";
|
||||
|
||||
/** The captured events panel, with the note that qualifies everything inside
|
||||
* it: what an operator reads here has already been through redaction. */
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Recent captures</CardTitle>
|
||||
<CardDescription>Newest first. Headers and payloads are redacted before they are stored.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<CapturesList />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import CaptureActions from "./CaptureActions.vue";
|
||||
import CaptureStatus from "./CaptureStatus.vue";
|
||||
|
||||
/** The page's title, and what belongs beside it: where the stream has got to,
|
||||
* and a way to ask for the list again. */
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mb-5 flex flex-wrap items-start justify-between gap-5">
|
||||
<div>
|
||||
<h1 class="text-3xl font-semibold tracking-[-0.03em]">Event inspector</h1>
|
||||
<p class="mt-2 text-sm text-fg-muted">Real inbound payloads archie has captured, most recent first.</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<CaptureStatus />
|
||||
<CaptureActions />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,66 @@
|
||||
<script setup lang="ts">
|
||||
import { Inbox, TriangleAlert } from "@lucide/vue";
|
||||
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Table, TableBody, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||
import CaptureRow from "./CaptureRow.vue";
|
||||
import { captures, enabled, error, loading } from "./state";
|
||||
|
||||
/**
|
||||
* The captures, or the one thing that stands in for them: a read that failed,
|
||||
* a deployment with no capture storage, a first read still in flight, or a
|
||||
* window with nothing in it yet.
|
||||
*/
|
||||
|
||||
// The receiver's path, held as a string rather than typed into the template:
|
||||
// its source segment is angle-bracketed, which a template parser reads as a
|
||||
// tag.
|
||||
const webhookHint = "Point a webhook at /webhooks/capture/<source> and it will show up here.";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- A failed read is about this page's request, not about capture, so it says
|
||||
what the server said rather than borrowing an empty state. -->
|
||||
<Alert v-if="error" variant="destructive">
|
||||
<TriangleAlert />
|
||||
<AlertTitle>Cannot reach archied</AlertTitle>
|
||||
<AlertDescription>{{ error }}</AlertDescription>
|
||||
</Alert>
|
||||
|
||||
<Empty v-else-if="!enabled">
|
||||
<EmptyHeader>
|
||||
<EmptyMedia variant="icon"><Inbox /></EmptyMedia>
|
||||
<EmptyTitle>Capture is not configured</EmptyTitle>
|
||||
<EmptyDescription>This deployment has no capture storage wired up.</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
|
||||
<div v-else-if="loading" class="flex flex-col gap-2">
|
||||
<Skeleton v-for="row in 5" :key="row" class="h-9 w-full" />
|
||||
</div>
|
||||
|
||||
<Empty v-else-if="!captures.length">
|
||||
<EmptyHeader>
|
||||
<EmptyMedia variant="icon"><Inbox /></EmptyMedia>
|
||||
<EmptyTitle>No captures yet</EmptyTitle>
|
||||
<EmptyDescription>{{ webhookHint }}</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
|
||||
<Table v-else>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Source</TableHead>
|
||||
<TableHead>Received</TableHead>
|
||||
<TableHead>Binding</TableHead>
|
||||
<TableHead>Content type</TableHead>
|
||||
<TableHead class="w-10"><span class="sr-only">Payload</span></TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<CaptureRow v-for="capture in captures" :key="capture.id" :capture="capture" />
|
||||
</TableBody>
|
||||
</Table>
|
||||
</template>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import CaptureDetailSheet from "./CaptureDetailSheet.vue";
|
||||
import CapturesCard from "./CapturesCard.vue";
|
||||
import CapturesHeader from "./CapturesHeader.vue";
|
||||
import { useCaptures } from "./state";
|
||||
|
||||
/**
|
||||
* Event inspector (t2db.2): the operator-facing half of capture. Recent
|
||||
* inbound events, newest first, with the full redacted payload explorable from
|
||||
* each row -- see docs/prds/event-capture-storage.md for what the backend
|
||||
* guarantees (retention, redaction, disk bounds). Composes the page; it holds
|
||||
* no state of its own.
|
||||
*/
|
||||
useCaptures();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CapturesHeader />
|
||||
<CapturesCard />
|
||||
<CaptureDetailSheet />
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
// prettyPrint indents valid JSON so a captured payload can be read as a
|
||||
// structure rather than a line. A payload that is not JSON is returned as it
|
||||
// arrived: the receiver stores whatever it is sent, JSON or not
|
||||
// (docs/prds/webhook-intake-security.md), and the non-JSON case is the one an
|
||||
// operator most needs to see.
|
||||
export function prettyPrint(raw: string | undefined): string {
|
||||
if (!raw) return "";
|
||||
try {
|
||||
return JSON.stringify(JSON.parse(raw), null, 2);
|
||||
} catch {
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import { computed, onMounted, onUnmounted, ref } from "vue";
|
||||
|
||||
import { api, subscribeEvents } from "@/lib/api";
|
||||
import type { StatusKind } from "@/lib/status";
|
||||
import type { StreamState } from "@/lib/stream-state";
|
||||
|
||||
/**
|
||||
* The event inspector's shared state.
|
||||
*
|
||||
* The list, the stream's state beside it and the sheet that shows one
|
||||
* capture's payload all read it, so it lives in a module rather than being
|
||||
* threaded down through a chain of props.
|
||||
*/
|
||||
|
||||
/**
|
||||
* One captured inbound event as the daemon stored it. Headers and body are
|
||||
* already redacted (webhookguard.RedactPayload runs before InsertCapture), so
|
||||
* what the page prints is what the store holds.
|
||||
*/
|
||||
export interface Capture {
|
||||
id: number;
|
||||
received_at?: string;
|
||||
source?: string;
|
||||
remote_addr?: string;
|
||||
content_type?: string;
|
||||
headers?: string;
|
||||
body?: string;
|
||||
authenticated?: boolean;
|
||||
}
|
||||
|
||||
interface CapturesResponse {
|
||||
captures?: Capture[];
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
// How many captures the list asks for. This is a recent-events window, not a
|
||||
// log: retention and the disk bound are the daemon's (see
|
||||
// docs/prds/event-capture-storage.md), so an operator looking for something
|
||||
// older is looking in the wrong place rather than scrolling further.
|
||||
const LIST_LIMIT = 100;
|
||||
|
||||
export const captures = ref<Capture[]>([]);
|
||||
export const enabled = ref(true);
|
||||
export const error = ref<string | null>(null);
|
||||
export const loading = ref(true);
|
||||
export const streamState = ref<StreamState | "connecting">("connecting");
|
||||
|
||||
/**
|
||||
* The open row's capture, or null. Held by value rather than by id: the list
|
||||
* is re-read on every capture event, so resolving an id again would close the
|
||||
* sheet under an operator reading a capture that has just aged out of the
|
||||
* window.
|
||||
*/
|
||||
export const selected = ref<Capture | null>(null);
|
||||
|
||||
/** The stream's state as a badge kind. A stream still connecting and one that
|
||||
* has given up are different answers, so they do not share a tone. */
|
||||
export const streamKind = computed<StatusKind>(() => {
|
||||
if (streamState.value === "live") return "ok";
|
||||
return streamState.value === "unavailable" ? "danger" : "warn";
|
||||
});
|
||||
|
||||
/**
|
||||
* load re-reads the list. It runs once on mount and again on every capture
|
||||
* event, so it deliberately never re-enters the loading state: the skeletons
|
||||
* are for a page with nothing on it yet, and a live refresh that put them back
|
||||
* would replace the rows an operator is reading several times a minute.
|
||||
*/
|
||||
export async function load(): Promise<void> {
|
||||
try {
|
||||
const res = await api.captures<CapturesResponse>(LIST_LIMIT);
|
||||
enabled.value = res.enabled !== false;
|
||||
captures.value = res.captures || [];
|
||||
error.value = null;
|
||||
} catch (err) {
|
||||
// The server's own message is the only part of a failure an operator can
|
||||
// act on, so it is what the list says instead of the captures.
|
||||
error.value = (err as Error).message || String(err);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleEvent(raw: unknown): void {
|
||||
// The "capture" event on /events carries the id and source only, no payload
|
||||
// (see handleCapture), so it is an invalidation signal rather than data: it
|
||||
// says a capture exists, and the authoritative list -- the only place the
|
||||
// redacted payload lives -- is asked for again. Merging it into local state
|
||||
// instead would put a row in the list with nothing behind it.
|
||||
if ((raw as { kind?: string } | null)?.kind !== "capture") return;
|
||||
void load();
|
||||
}
|
||||
|
||||
let unsubscribe: (() => void) | undefined;
|
||||
|
||||
/** Owns the initial read and the live stream that invalidates it, for the
|
||||
* page's lifetime. */
|
||||
export function useCaptures(): void {
|
||||
onMounted(() => {
|
||||
void load();
|
||||
unsubscribe = subscribeEvents(handleEvent, (state) => {
|
||||
streamState.value = state;
|
||||
});
|
||||
});
|
||||
onUnmounted(() => unsubscribe?.());
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<script lang="ts">
|
||||
/** A conversational front-end, as /api/channels serialises it. */
|
||||
export interface Channel {
|
||||
id?: string;
|
||||
name: string;
|
||||
state?: string;
|
||||
configured?: boolean;
|
||||
description?: string;
|
||||
detail?: string;
|
||||
reload_supported?: boolean;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { RefreshCw } from "@lucide/vue";
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import type { StatusKind } from "@/lib/status";
|
||||
|
||||
const props = defineProps<{ channel: Channel }>();
|
||||
const emit = defineEmits<{ reload: [id: string] }>();
|
||||
|
||||
// In-flight state rather than mutating the button's disabled attribute: the
|
||||
// element is re-rendered by Vue, so a DOM write would be discarded.
|
||||
const reloading = ref(false);
|
||||
|
||||
function tone(state: string | undefined, configured: boolean | undefined): StatusKind {
|
||||
if (state === "running") return "ok";
|
||||
if (state === "failed" || state === "degraded") return "warn";
|
||||
return configured ? "idle" : "idle";
|
||||
}
|
||||
|
||||
const label = computed(() => props.channel.state || (props.channel.configured ? "configured" : "stopped"));
|
||||
|
||||
async function reload() {
|
||||
reloading.value = true;
|
||||
try {
|
||||
emit("reload", props.channel.id || props.channel.name.toLowerCase());
|
||||
} finally {
|
||||
reloading.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{{ props.channel.name }}</CardTitle>
|
||||
<CardDescription v-if="props.channel.description">{{ props.channel.description }}</CardDescription>
|
||||
<Badge :variant="tone(props.channel.state, props.channel.configured)">{{ label }}</Badge>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p v-if="props.channel.detail" class="mb-3 text-sm text-fg-muted">{{ props.channel.detail }}</p>
|
||||
<Button v-if="props.channel.reload_supported" variant="outline" :disabled="reloading" @click="reload">
|
||||
<RefreshCw data-icon="inline-start" />
|
||||
Reload
|
||||
</Button>
|
||||
<p v-else class="text-sm text-fg-subtle">Reload requires a daemon restart for this adapter.</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</template>
|
||||
@@ -0,0 +1,70 @@
|
||||
<script setup lang="ts">
|
||||
import { RefreshCw } from "@lucide/vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { api } from "@/lib/api";
|
||||
import ChannelCard, { type Channel } from "./ChannelCard.vue";
|
||||
|
||||
/** The conversational front-ends Archie can be reached through. */
|
||||
|
||||
const channels = ref<Channel[]>([]);
|
||||
const error = ref<string | null>(null);
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
const res = await api.channels<{ channels?: Channel[] }>();
|
||||
channels.value = res?.channels || [];
|
||||
error.value = null;
|
||||
} catch (err) {
|
||||
error.value = String((err as Error).message || err);
|
||||
}
|
||||
}
|
||||
|
||||
/** Reload, then re-read: the adapter's new state is what the card shows, so a
|
||||
* failed reload surfaces as the state it failed to leave. */
|
||||
async function reload(id: string) {
|
||||
try {
|
||||
await api.channelReload(id);
|
||||
} catch {
|
||||
// Reported by the refreshed state below.
|
||||
}
|
||||
await load();
|
||||
}
|
||||
|
||||
onMounted(load);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader
|
||||
title="Channels"
|
||||
subtitle="The conversational front-ends Archie can be reached through."
|
||||
>
|
||||
<Button variant="outline" @click="load">
|
||||
<RefreshCw data-icon="inline-start" />
|
||||
Refresh
|
||||
</Button>
|
||||
</PageHeader>
|
||||
|
||||
<div class="grid grid-cols-1 gap-4 min-[1080px]:grid-cols-[repeat(auto-fit,minmax(340px,1fr))]">
|
||||
<Empty v-if="error">
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>Cannot reach archied</EmptyTitle>
|
||||
<EmptyDescription>{{ error }}</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
<Empty v-else-if="!channels.length">
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>No channels configured</EmptyTitle>
|
||||
<EmptyDescription>
|
||||
Configure [chat.telegram] or [chat.webhook_addr] in config.toml to talk to Archie outside the dashboard.
|
||||
</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
<ChannelCard v-for="channel in channels" v-else :key="channel.id || channel.name" :channel="channel" @reload="reload" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import ChatSessionList from "./ChatSessionList.vue";
|
||||
import ChatSettings from "./ChatSettings.vue";
|
||||
|
||||
/**
|
||||
* One row for everything that is not the conversation: which conversation is
|
||||
* open, and the controls that are consulted rather than used constantly.
|
||||
*/
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center gap-2 border-b px-3 py-2">
|
||||
<ChatSessionList />
|
||||
<ChatSettings />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
import { cn } from "@/lib/utils";
|
||||
import ChatMarkdown from "./ChatMarkdown.vue";
|
||||
import ChatToolCall from "./ChatToolCall.vue";
|
||||
import type { ChatToolCall as ToolCall } from "./state";
|
||||
|
||||
/**
|
||||
* One message, from either side of the conversation. There is no speaker
|
||||
* label: which side of the panel it sits on, and its fill, are what say who is
|
||||
* talking. A trailing action arrives through the slot, so the retry the
|
||||
* transcript offers belongs to the bubble rather than beside it.
|
||||
*/
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
text: string;
|
||||
tools?: ToolCall[];
|
||||
assistant?: boolean;
|
||||
/** The turn is still arriving: a tool call with no outcome is running. */
|
||||
streaming?: boolean;
|
||||
}>(),
|
||||
{ tools: () => [], assistant: false, streaming: false },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex" :class="assistant ? 'justify-start' : 'justify-end'">
|
||||
<div
|
||||
:class="
|
||||
cn(
|
||||
'max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]',
|
||||
assistant ? 'bg-muted' : 'bg-primary/15',
|
||||
)
|
||||
"
|
||||
>
|
||||
<div v-if="assistant && tools.length" class="mb-2 grid gap-0.5 text-xs">
|
||||
<ChatToolCall v-for="(tool, i) in tools" :key="i" :tool="tool" :streaming="streaming" />
|
||||
</div>
|
||||
<ChatMarkdown v-if="assistant" :text="text" />
|
||||
<div v-else class="whitespace-pre-wrap">{{ text }}</div>
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,150 @@
|
||||
<script setup lang="ts">
|
||||
import { nextTick, ref, watch } from "vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { applyCommand, isExactCommand } from "./commands";
|
||||
import ChatSlashPalette from "./ChatSlashPalette.vue";
|
||||
import {
|
||||
closeCommandMenu,
|
||||
commandMatches,
|
||||
commandSelection,
|
||||
commandSpecs,
|
||||
composerText,
|
||||
isCommandMenuOpen,
|
||||
isSending,
|
||||
moveCommandSelection,
|
||||
sendMessage,
|
||||
stopTurn,
|
||||
syncCommandMenu,
|
||||
} from "./state";
|
||||
|
||||
/**
|
||||
* The composer: the text, the palette that completes a slash command, and the
|
||||
* two actions. It stays writeable and focused while a turn is in flight --
|
||||
* stopping is not the only thing an operator may want to do next -- so Stop is
|
||||
* an addition to the row, never a replacement for Send.
|
||||
*
|
||||
* The textarea is stripped back to bare text inside the shell that carries the
|
||||
* border and the fill: the field's own chrome would draw a second box inside
|
||||
* the first. `bg-transparent!` beats the field's dark fill, which the dark
|
||||
* variant would otherwise re-apply over the shell. It grows with what is typed
|
||||
* and stops at `max-h-40`, so a long draft scrolls rather than eating the
|
||||
* transcript above it.
|
||||
*/
|
||||
const props = defineProps<{ open: boolean }>();
|
||||
|
||||
const field = ref<{ $el: HTMLTextAreaElement } | null>(null);
|
||||
|
||||
function focus(): void {
|
||||
field.value?.$el?.focus();
|
||||
}
|
||||
|
||||
defineExpose({ focus });
|
||||
|
||||
// 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.
|
||||
watch(
|
||||
() => props.open,
|
||||
(open) => {
|
||||
if (open) void nextTick(focus);
|
||||
},
|
||||
);
|
||||
|
||||
// A finished turn leaves the caret in the composer, where the next message is
|
||||
// typed, rather than on the button that sent the last one.
|
||||
watch(isSending, (sending, wasSending) => {
|
||||
if (wasSending && !sending) void nextTick(focus);
|
||||
});
|
||||
|
||||
function onInput(event: Event): void {
|
||||
const input = event.target as HTMLTextAreaElement;
|
||||
composerText.value = input.value;
|
||||
syncCommandMenu(input.value, input.selectionStart ?? input.value.length);
|
||||
}
|
||||
|
||||
function choose(index: number): void {
|
||||
const spec = commandMatches.value[index];
|
||||
const input = field.value?.$el;
|
||||
if (!spec || !input) return;
|
||||
// Completing the command replaces the token the caret sits in, which is
|
||||
// decided by the same rule that found the matches.
|
||||
const { text, cursor } = applyCommand(input.value, input.selectionStart ?? input.value.length, spec.command);
|
||||
composerText.value = text;
|
||||
closeCommandMenu();
|
||||
void nextTick(() => {
|
||||
input.focus();
|
||||
input.setSelectionRange(cursor, cursor);
|
||||
});
|
||||
}
|
||||
|
||||
function onKeydown(event: KeyboardEvent): void {
|
||||
const plain = !event.shiftKey && !event.ctrlKey && !event.metaKey;
|
||||
if (isCommandMenuOpen.value && commandMatches.value.length) {
|
||||
// A command typed in full is sent rather than completed, so Enter never
|
||||
// re-enters the command the palette was offering.
|
||||
if (event.key === "Enter" && plain && isExactCommand(commandSpecs.value, composerText.value)) {
|
||||
event.preventDefault();
|
||||
closeCommandMenu();
|
||||
void sendMessage();
|
||||
return;
|
||||
}
|
||||
if (event.key === "ArrowDown") {
|
||||
event.preventDefault();
|
||||
moveCommandSelection(1);
|
||||
return;
|
||||
}
|
||||
if (event.key === "ArrowUp") {
|
||||
event.preventDefault();
|
||||
moveCommandSelection(-1);
|
||||
return;
|
||||
}
|
||||
if (event.key === "Enter" && plain) {
|
||||
event.preventDefault();
|
||||
choose(commandSelection.value);
|
||||
return;
|
||||
}
|
||||
if (event.key === "Escape") {
|
||||
// Consumed here: dismissing the palette must not also close the panel.
|
||||
event.preventDefault();
|
||||
closeCommandMenu();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (event.key === "Enter" && !event.shiftKey) {
|
||||
event.preventDefault();
|
||||
void sendMessage();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="border-t p-3">
|
||||
<div class="relative flex items-end gap-2 rounded-xl border border-border-strong bg-muted px-3 py-2.5">
|
||||
<Textarea
|
||||
ref="field"
|
||||
:model-value="composerText"
|
||||
rows="3"
|
||||
placeholder="Message Archie, or type / for commands"
|
||||
aria-label="Message Archie"
|
||||
class="max-h-40 min-h-11 flex-1 resize-none border-0 bg-transparent! px-0 py-1 text-sm focus-visible:ring-0"
|
||||
@input="onInput"
|
||||
@keydown="onKeydown"
|
||||
/>
|
||||
|
||||
<ChatSlashPalette
|
||||
v-if="isCommandMenuOpen && commandMatches.length"
|
||||
:matches="commandMatches"
|
||||
:selection="commandSelection"
|
||||
@choose="choose"
|
||||
/>
|
||||
|
||||
<div class="flex flex-none items-center gap-2">
|
||||
<!-- Only while a turn is arriving: a Stop with nothing to stop is a
|
||||
button that lies about what the panel is doing. -->
|
||||
<Button v-if="isSending" variant="outline" size="sm" @click="stopTurn">Stop</Button>
|
||||
<Button size="sm" :disabled="isSending || !composerText.trim()" @click="sendMessage()">Send</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,35 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* What the panel opens on before there is a conversation: an invitation, and
|
||||
* three prompts that fill the composer. The text is handed up rather than
|
||||
* typed into the composer here, because the composer owns its own focus.
|
||||
*/
|
||||
const emit = defineEmits<{ prompt: [text: string] }>();
|
||||
|
||||
// Prompts an operator might actually ask, rather than demonstrations of the
|
||||
// feature.
|
||||
const PROMPTS = ["Summarise active tasks", "Show running agents", "Check system status"];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="w-full self-center justify-self-center py-6 text-center">
|
||||
<span
|
||||
aria-hidden="true"
|
||||
class="mx-auto mb-3 grid size-9 place-items-center rounded-xl border border-border-strong font-bold text-primary"
|
||||
>A</span
|
||||
>
|
||||
<h2 class="text-lg font-semibold tracking-[-0.02em]">What are we working on?</h2>
|
||||
<p class="mt-2 mb-4 text-sm text-fg-muted">Ask Archie anything, or start with one of these prompts.</p>
|
||||
<div class="grid gap-2">
|
||||
<button
|
||||
v-for="prompt in PROMPTS"
|
||||
:key="prompt"
|
||||
type="button"
|
||||
class="rounded-full border border-border bg-muted px-3 py-2 text-left text-sm text-fg-muted transition-colors hover:border-border-strong hover:text-foreground"
|
||||
@click="emit('prompt', prompt)"
|
||||
>
|
||||
{{ prompt }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,46 @@
|
||||
<script setup lang="ts">
|
||||
import { MessageCircle, X } from "@lucide/vue";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import { CHAT_PANEL_ID } from "./state";
|
||||
|
||||
/**
|
||||
* The launcher: the one control that opens and closes the panel, which is why
|
||||
* there is no close button inside it.
|
||||
*
|
||||
* Both glyphs are stacked and cross-faded, so the button keeps one size and the
|
||||
* swap cannot reflow the dock. It stays visible while the panel is open -- and
|
||||
* on a phone, where the panel becomes a sheet above it, that visibility is the
|
||||
* only way out.
|
||||
*/
|
||||
defineProps<{ open: boolean }>();
|
||||
const emit = defineEmits<{ toggle: [] }>();
|
||||
|
||||
// Stacked in one cell, so switching glyphs changes opacity and rotation rather
|
||||
// than layout.
|
||||
function glyph(visible: boolean): string {
|
||||
return cn(
|
||||
"col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]",
|
||||
visible ? "opacity-100" : "-rotate-45 scale-[0.7] opacity-0",
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
type="button"
|
||||
class="relative z-10 grid size-14 cursor-pointer place-items-center rounded-full bg-linear-to-br from-primary to-[var(--brand-alt)] text-primary-foreground shadow-[var(--shadow-md)] transition-[transform,box-shadow] duration-[140ms] hover:-translate-y-px hover:shadow-[0_12px_34px_var(--primary-soft)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0"
|
||||
:aria-label="open ? 'Close chat' : 'Chat with Archie'"
|
||||
:title="open ? 'Close chat' : 'Chat with Archie'"
|
||||
:aria-expanded="open"
|
||||
:aria-controls="CHAT_PANEL_ID"
|
||||
@click="emit('toggle')"
|
||||
>
|
||||
<span aria-hidden="true" :class="glyph(!open)">
|
||||
<MessageCircle :size="22" />
|
||||
</span>
|
||||
<span aria-hidden="true" :class="glyph(open)">
|
||||
<X :size="22" />
|
||||
</span>
|
||||
</button>
|
||||
</template>
|
||||
@@ -0,0 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import { MessageCirclePlus } from "@lucide/vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { panelTitle } from "./session";
|
||||
import { currentSession, newChat, sessions } from "./state";
|
||||
|
||||
/**
|
||||
* The panel's head: which conversation is open, and the one action that always
|
||||
* applies to it.
|
||||
*
|
||||
* There is no close button. The launcher stays visible while the panel is open
|
||||
* and is the single control that opens and closes it, so a second one here
|
||||
* would be a duplicate that can drift out of step.
|
||||
*/
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center justify-between gap-2 border-b px-4 py-3">
|
||||
<strong class="truncate text-sm font-semibold">{{ panelTitle(sessions, currentSession) }}</strong>
|
||||
<Button variant="ghost" size="icon-sm" class="flex-none" title="New chat" aria-label="New chat" @click="newChat">
|
||||
<MessageCirclePlus />
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,35 @@
|
||||
<script setup lang="ts">
|
||||
import type { ChatInline } from "./markdown";
|
||||
|
||||
/** One inline run: the spans of a paragraph, a heading or a table cell. */
|
||||
defineProps<{ inline: ChatInline[] }>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-for="(span, i) in inline" :key="i">
|
||||
<img
|
||||
v-if="span.kind === 'image'"
|
||||
:src="span.src"
|
||||
:alt="span.alt"
|
||||
loading="lazy"
|
||||
class="my-1 block max-h-96 max-w-full cursor-pointer rounded-md border border-border bg-card object-contain"
|
||||
/>
|
||||
<del v-else-if="span.kind === 'del'">{{ span.text }}</del>
|
||||
<strong v-else-if="span.kind === 'strong'">{{ span.text }}</strong>
|
||||
<code
|
||||
v-else-if="span.kind === 'code'"
|
||||
class="rounded bg-foreground/10 px-1 py-0.5 font-mono text-[0.9em]"
|
||||
>{{ span.text }}</code
|
||||
>
|
||||
<a
|
||||
v-else-if="span.kind === 'link'"
|
||||
:href="span.href"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
class="text-primary underline-offset-4 hover:underline"
|
||||
>{{ span.text }}</a
|
||||
>
|
||||
<em v-else-if="span.kind === 'em'">{{ span.text }}</em>
|
||||
<template v-else>{{ span.text }}</template>
|
||||
</template>
|
||||
</template>
|
||||
@@ -0,0 +1,67 @@
|
||||
<script setup lang="ts">
|
||||
import { onUnmounted, ref, watch } from "vue";
|
||||
|
||||
import ChatFab from "./ChatFab.vue";
|
||||
import ChatPanel from "./ChatPanel.vue";
|
||||
import { escapeOwnedByLayer } from "./state";
|
||||
|
||||
/**
|
||||
* Chat is a floating launcher and the panel it opens, not a route: the operator
|
||||
* asks Archie about the page they are already on, so navigating must not close
|
||||
* it and opening it must not replace the work that prompted the question.
|
||||
*
|
||||
* Deliberately not a modal: no scrim, no body scroll lock, no focus trap. The
|
||||
* page stays readable, scrollable and clickable while the panel is open, which
|
||||
* is what "ask about this page" requires.
|
||||
*
|
||||
* It hosts a single panel instance, so the session and its stream survive
|
||||
* navigation rather than being rebuilt per page.
|
||||
*
|
||||
* This element is mounted outside the app shell: `.shell`'s backdrop-filter
|
||||
* makes it a containing block for `position: fixed`, so a launcher nested
|
||||
* inside it would anchor to the shell and ride off the bottom of a long page.
|
||||
*/
|
||||
const open = ref(false);
|
||||
const fab = ref<{ $el: HTMLButtonElement } | null>(null);
|
||||
|
||||
function close(): void {
|
||||
open.value = false;
|
||||
// Focus goes back to the control that opened the panel; otherwise a keyboard
|
||||
// user who dismisses it lands at the top of the document.
|
||||
fab.value?.$el?.focus();
|
||||
}
|
||||
|
||||
function toggle(): void {
|
||||
if (open.value) close();
|
||||
else open.value = true;
|
||||
}
|
||||
|
||||
function onKeydown(event: KeyboardEvent): void {
|
||||
// A focused control (the composer dismissing its palette, or the topbar
|
||||
// search) already handled Escape via preventDefault; closing the panel too
|
||||
// would make that menu impossible to dismiss on its own.
|
||||
if (event.defaultPrevented || event.key !== "Escape") return;
|
||||
// The same rule for a layer that owns Escape by being open rather than by
|
||||
// holding focus: a popover portalled out of the panel listens on document
|
||||
// too, and the panel registered its own handler first, so the flag is what
|
||||
// keeps the innermost layer's dismissal from taking the panel with it.
|
||||
if (escapeOwnedByLayer()) return;
|
||||
close();
|
||||
}
|
||||
|
||||
watch(open, (isOpen) => {
|
||||
if (isOpen) document.addEventListener("keydown", onKeydown);
|
||||
else document.removeEventListener("keydown", onKeydown);
|
||||
});
|
||||
|
||||
onUnmounted(() => document.removeEventListener("keydown", onKeydown));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="fixed right-6 bottom-6 z-40 max-[720px]:right-4 max-[720px]:bottom-4"
|
||||
>
|
||||
<ChatPanel :open="open" />
|
||||
<ChatFab ref="fab" :open="open" @toggle="toggle" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,74 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
|
||||
import ChatInline from "./ChatInline.vue";
|
||||
import { parseMarkdown } from "./markdown";
|
||||
|
||||
/**
|
||||
* A reply rendered as semantic HTML: headings, lists, quotes, fenced code,
|
||||
* tables, inline emphasis. The parse is a computed, so a reply that grows a
|
||||
* token at a time re-renders from the text it now has rather than accumulating
|
||||
* markup.
|
||||
*/
|
||||
const props = defineProps<{ text: string }>();
|
||||
|
||||
const blocks = computed(() => parseMarkdown(props.text));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="[overflow-wrap:anywhere]">
|
||||
<template v-for="(block, i) in blocks" :key="i">
|
||||
<pre
|
||||
v-if="block.kind === 'pre'"
|
||||
class="my-2 overflow-auto rounded-md border border-border bg-background/60 p-3"
|
||||
><code class="font-mono text-[0.85em]">{{ block.code }}</code></pre>
|
||||
|
||||
<table v-else-if="block.kind === 'table'" class="my-3 w-full border-collapse text-[0.92em]">
|
||||
<thead>
|
||||
<tr>
|
||||
<th
|
||||
v-for="(cell, c) in block.head"
|
||||
:key="c"
|
||||
class="border border-border bg-muted px-2 py-1.5 text-left font-semibold"
|
||||
>
|
||||
<ChatInline :inline="cell" />
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(row, r) in block.rows" :key="r">
|
||||
<td v-for="(cell, c) in row" :key="c" class="border border-border px-2 py-1.5 text-left">
|
||||
<ChatInline :inline="cell" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<blockquote
|
||||
v-else-if="block.kind === 'blockquote'"
|
||||
class="my-2 border-l-[3px] border-primary pl-3 text-fg-muted"
|
||||
>
|
||||
<ChatInline :inline="block.inline" />
|
||||
</blockquote>
|
||||
|
||||
<h1 v-else-if="block.kind === 'h1'" class="mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]">
|
||||
<ChatInline :inline="block.inline" />
|
||||
</h1>
|
||||
<h2 v-else-if="block.kind === 'h2'" class="mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]">
|
||||
<ChatInline :inline="block.inline" />
|
||||
</h2>
|
||||
<h3 v-else-if="block.kind === 'h3'" class="mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]">
|
||||
<ChatInline :inline="block.inline" />
|
||||
</h3>
|
||||
|
||||
<ul v-else-if="block.kind === 'ul'" class="my-2.5 flex list-disc flex-col gap-1 pl-5">
|
||||
<li v-for="(item, n) in block.items" :key="n"><ChatInline :inline="item" /></li>
|
||||
</ul>
|
||||
<ol v-else-if="block.kind === 'ol'" class="my-2.5 flex list-decimal flex-col gap-1 pl-5">
|
||||
<li v-for="(item, n) in block.items" :key="n"><ChatInline :inline="item" /></li>
|
||||
</ol>
|
||||
|
||||
<p v-else-if="block.kind === 'p'" class="mb-2.5 last:mb-0"><ChatInline :inline="block.inline" /></p>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import { ArrowUpRight } from "@lucide/vue";
|
||||
|
||||
/**
|
||||
* A dashboard_navigate result: a clickable chip that routes the operator to a
|
||||
* dashboard page. It is an action, not evidence, so it is styled as a button
|
||||
* rather than a muted log line, and it visibly invites a click. It is the only
|
||||
* clickable navigation surface in the transcript.
|
||||
*
|
||||
* A RouterLink rather than a `#/path` anchor: history routing means the server
|
||||
* stores bare paths, and an anchor would reload the whole app to change one
|
||||
* segment.
|
||||
*/
|
||||
defineProps<{ path: string; label?: string }>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RouterLink
|
||||
:to="path"
|
||||
:title="`Go to ${label || path}`"
|
||||
class="inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-primary transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
|
||||
>
|
||||
<ArrowUpRight aria-hidden="true" class="size-3.5 shrink-0" />
|
||||
<span class="truncate">{{ label || path }}</span>
|
||||
</RouterLink>
|
||||
</template>
|
||||
@@ -0,0 +1,88 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
import ChatBar from "./ChatBar.vue";
|
||||
import ChatComposer from "./ChatComposer.vue";
|
||||
import ChatHeader from "./ChatHeader.vue";
|
||||
import ChatSessionActions from "./ChatSessionActions.vue";
|
||||
import ChatTranscript from "./ChatTranscript.vue";
|
||||
import { CHAT_PANEL_ID, composerText, currentSession, useChat } from "./state";
|
||||
|
||||
/**
|
||||
* The panel: the shape that grows out of the launcher, holding the
|
||||
* conversation. It composes the head, the bar, the transcript and the composer,
|
||||
* and owns nothing but the morph and the composer's focus.
|
||||
*
|
||||
* It stays mounted while closed, so the session and any turn in flight survive
|
||||
* a navigation. `inert` is what keeps an invisible panel out of the tab order
|
||||
* and out of the pointer's way.
|
||||
*/
|
||||
const props = defineProps<{ open: boolean }>();
|
||||
|
||||
useChat();
|
||||
|
||||
const composer = ref<InstanceType<typeof ChatComposer> | null>(null);
|
||||
|
||||
/**
|
||||
* The panel's shape.
|
||||
*
|
||||
* Closed, it is collapsed to a small round shape sitting exactly over the
|
||||
* button; open, it is the full panel beside it. Scaling from the bottom-right
|
||||
* corner and translating by the launcher's own width is what makes the button
|
||||
* appear to become the panel, rather than a panel merely fading in next to it:
|
||||
* scale, border-radius and position interpolate together. The contents fade in
|
||||
* separately, below, once the shape has arrived.
|
||||
*
|
||||
* On a phone the sheet rises from the launcher instead of opening beside it, so
|
||||
* the closed shape travels down toward the button rather than sideways. Those
|
||||
* two values (56px launcher, 0.75rem gap) are the dock's own geometry; the
|
||||
* launcher and every offset here are built from them.
|
||||
*/
|
||||
const panelShape = computed(() =>
|
||||
props.open
|
||||
? "pointer-events-auto rounded-lg opacity-100 [transform:none] [transition:opacity_160ms_cubic-bezier(0.4,0,0.2,1),transform_260ms_cubic-bezier(0.22,1,0.36,1),border-radius_260ms_cubic-bezier(0.22,1,0.36,1)]"
|
||||
: "pointer-events-none rounded-full opacity-0 [transform:translateX(calc(56px_+_0.75rem))_scale(0.16)] max-[720px]:[transform:translateY(calc(56px_+_0.75rem))_scale(0.16)] [transition:opacity_140ms_cubic-bezier(0.4,0,0.2,1),transform_200ms_cubic-bezier(0.4,0,1,1),border-radius_200ms_cubic-bezier(0.4,0,1,1)]",
|
||||
);
|
||||
|
||||
// The contents follow the shape rather than stretching with it: they fade in
|
||||
// once the panel is most of the way open, so the morph reads as a container
|
||||
// opening instead of a page being scaled up.
|
||||
const contentFade = computed(() =>
|
||||
props.open
|
||||
? "opacity-100 transition-opacity duration-[160ms] ease-linear delay-[120ms]"
|
||||
: "opacity-0 transition-opacity duration-[120ms] ease-linear",
|
||||
);
|
||||
|
||||
function usePrompt(text: string): void {
|
||||
composerText.value = text;
|
||||
composer.value?.focus();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<aside
|
||||
:id="CHAT_PANEL_ID"
|
||||
aria-label="Chat with Archie"
|
||||
:aria-hidden="open ? undefined : 'true'"
|
||||
class="pointer-events-none absolute bottom-0 right-[calc(56px_+_0.75rem)] h-[min(640px,calc(100vh_-_3rem))] w-[min(440px,calc(100vw_-_56px_-_0.75rem_-_3rem))] max-[720px]:fixed max-[720px]:bottom-[calc(1rem_+_56px_+_0.75rem)] max-[720px]:left-4 max-[720px]:right-4 max-[720px]:h-[min(72vh,calc(100vh_-_2rem_-_56px_-_0.75rem))] max-[720px]:w-auto"
|
||||
>
|
||||
<div
|
||||
:class="
|
||||
panelShape +
|
||||
' h-full w-full overflow-hidden border bg-popover shadow-[var(--shadow-md)] origin-bottom-right'
|
||||
"
|
||||
:inert="open ? undefined : true"
|
||||
>
|
||||
<!-- The conversation takes the rest of the column: without `min-h-0` on
|
||||
the transcript it sizes to its content instead, and the composer
|
||||
floats above dead space. -->
|
||||
<div :class="contentFade + ' flex h-full min-h-0 flex-col overflow-hidden'">
|
||||
<ChatHeader />
|
||||
<ChatBar />
|
||||
<ChatSessionActions v-if="currentSession" />
|
||||
<ChatTranscript @prompt="usePrompt" />
|
||||
<ChatComposer ref="composer" :open="open" />
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</template>
|
||||
@@ -0,0 +1,47 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { promptSessionCommand, runSessionCommand, useEscapeLayer } from "./state";
|
||||
|
||||
/**
|
||||
* The commands that act on the conversation itself rather than on what is being
|
||||
* said: retry the last turn, undo it, rename the conversation, branch it, or
|
||||
* look at what compressing it would drop.
|
||||
*
|
||||
* Each one is the same command the server accepts from any other channel, so
|
||||
* this is a set of buttons over the slash surface rather than a second way to
|
||||
* do the work. The popover closes as the command goes, because its answer comes
|
||||
* back into the transcript and the status line, not into the menu.
|
||||
*/
|
||||
const open = ref(false);
|
||||
useEscapeLayer(open);
|
||||
|
||||
function run(command: string): void {
|
||||
open.value = false;
|
||||
void runSessionCommand(command);
|
||||
}
|
||||
|
||||
function prompt(command: string, message: string): void {
|
||||
open.value = false;
|
||||
promptSessionCommand(command, message);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center border-b px-3 py-1.5 text-xs">
|
||||
<Popover v-model:open="open">
|
||||
<PopoverTrigger as-child>
|
||||
<Button variant="ghost" size="xs" class="text-fg-muted">Session actions</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="start" class="flex w-[min(22rem,72vw)] flex-wrap gap-1.5">
|
||||
<Button variant="outline" size="sm" @click="run('/retry')">Retry</Button>
|
||||
<Button variant="outline" size="sm" @click="run('/undo')">Undo</Button>
|
||||
<Button variant="outline" size="sm" @click="prompt('/title', 'Session title')">Rename</Button>
|
||||
<Button variant="outline" size="sm" @click="prompt('/branch', 'Branch name (optional)')">Branch</Button>
|
||||
<Button variant="outline" size="sm" @click="run('/compress --preview')">Preview compression</Button>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { sessionTitle } from "./session";
|
||||
import { currentSession, selectSession, sessions } from "./state";
|
||||
|
||||
/**
|
||||
* Which conversation is open, and how to switch. A select rather than a list:
|
||||
* the panel is small, and choosing between a handful of conversations is a
|
||||
* control, not a place to be.
|
||||
*
|
||||
* reka-ui refuses an empty string as an item value -- it is how the component
|
||||
* spells "nothing selected" -- and a session id is never empty, so the ids pass
|
||||
* through unchanged.
|
||||
*/
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="min-w-0 flex-1">
|
||||
<Select
|
||||
:model-value="currentSession"
|
||||
:disabled="!sessions.length"
|
||||
@update:model-value="selectSession(String($event))"
|
||||
>
|
||||
<SelectTrigger size="sm" class="w-full" aria-label="Conversation">
|
||||
<SelectValue placeholder="No conversations yet" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem v-for="session in sessions" :key="session.session_id" :value="session.session_id">
|
||||
{{ sessionTitle(session) }}
|
||||
</SelectItem>
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,108 @@
|
||||
<script setup lang="ts">
|
||||
import { Settings } from "@lucide/vue";
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Field, FieldLabel } from "@/components/ui/field";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import {
|
||||
currentModels,
|
||||
selectedModel,
|
||||
selectedPersona,
|
||||
selectedProvider,
|
||||
selectorData,
|
||||
setModel,
|
||||
setPersona,
|
||||
setProvider,
|
||||
statusText,
|
||||
useEscapeLayer,
|
||||
} from "./state";
|
||||
|
||||
/**
|
||||
* The chat's own settings, folded away: what the panel is doing right now, and
|
||||
* the three selectors the server offers.
|
||||
*
|
||||
* A Popover rather than a disclosure menu: it closes on an outside pointerdown
|
||||
* and on focus leaving it, which is what a control that opens over the
|
||||
* transcript has to do. It portals out of the panel, so the panel's overflow
|
||||
* cannot clip it.
|
||||
*
|
||||
* reka-ui refuses an empty string as an item value (that is how it spells
|
||||
* "nothing selected") while the wire reads an absent value as "use the
|
||||
* default", so the sentinel converts at this boundary and the state below keeps
|
||||
* the empty string.
|
||||
*/
|
||||
const DEFAULT = "__default__";
|
||||
|
||||
const open = ref(false);
|
||||
useEscapeLayer(open);
|
||||
|
||||
const personaValue = computed(() => selectedPersona.value || DEFAULT);
|
||||
const providerValue = computed(() => selectedProvider.value || DEFAULT);
|
||||
const modelValue = computed(() => selectedModel.value || DEFAULT);
|
||||
|
||||
function clear(value: unknown): string {
|
||||
return value === DEFAULT ? "" : String(value ?? "");
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Popover v-model:open="open">
|
||||
<PopoverTrigger as-child>
|
||||
<Button variant="ghost" size="icon-sm" aria-label="Chat settings" title="Chat settings">
|
||||
<Settings />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="end" class="grid w-64 gap-3">
|
||||
<span class="text-xs text-fg-subtle">{{ statusText }}</span>
|
||||
|
||||
<Field class="gap-1">
|
||||
<FieldLabel class="text-xs text-fg-muted">Personality</FieldLabel>
|
||||
<Select :model-value="personaValue" @update:model-value="setPersona(clear($event))">
|
||||
<SelectTrigger size="sm" class="w-full" aria-label="Personality">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem :value="DEFAULT">Default</SelectItem>
|
||||
<SelectItem v-for="name in selectorData.personas || []" :key="name" :value="name">{{ name }}</SelectItem>
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
|
||||
<Field v-if="(selectorData.providers || []).length" class="gap-1">
|
||||
<FieldLabel class="text-xs text-fg-muted">Provider</FieldLabel>
|
||||
<Select :model-value="providerValue" @update:model-value="setProvider(clear($event))">
|
||||
<SelectTrigger size="sm" class="w-full" aria-label="Provider">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem :value="DEFAULT">Default</SelectItem>
|
||||
<SelectItem v-for="provider in selectorData.providers || []" :key="provider" :value="provider">
|
||||
{{ provider }}
|
||||
</SelectItem>
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
|
||||
<Field class="gap-1">
|
||||
<FieldLabel class="text-xs text-fg-muted">Model</FieldLabel>
|
||||
<Select :model-value="modelValue" @update:model-value="setModel(clear($event))">
|
||||
<SelectTrigger size="sm" class="w-full" aria-label="Model">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem :value="DEFAULT">Default</SelectItem>
|
||||
<SelectItem v-for="model in currentModels" :key="model" :value="model">{{ model }}</SelectItem>
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</template>
|
||||
@@ -0,0 +1,60 @@
|
||||
<script setup lang="ts">
|
||||
import { nextTick, ref, watch } from "vue";
|
||||
|
||||
import { commandScrollTop } from "./command-scroll";
|
||||
import type { ChatCommandSpec } from "./state";
|
||||
|
||||
/**
|
||||
* The slash palette: the commands the server accepts, floating above the
|
||||
* composer. It is the only command surface -- there is no second list anywhere
|
||||
* in the panel -- so the arrow keys and the pointer both land here.
|
||||
*/
|
||||
const props = defineProps<{ matches: ChatCommandSpec[]; selection: number }>();
|
||||
const emit = defineEmits<{ choose: [index: number] }>();
|
||||
|
||||
const menu = ref<HTMLElement | null>(null);
|
||||
|
||||
// Arrow keys move the selection, and the list scrolls so the highlight stays
|
||||
// visible once the matches run past the rows that fit. The arithmetic is
|
||||
// command-scroll.ts's; this only applies what it returns. flush: 'post' so the
|
||||
// option being measured is the one just selected, not the one leaving.
|
||||
watch(
|
||||
() => [props.selection, props.matches.length],
|
||||
async () => {
|
||||
await nextTick();
|
||||
const el = menu.value;
|
||||
const option = el?.children[props.selection] as HTMLElement | undefined;
|
||||
if (!el || !option) return;
|
||||
el.scrollTop = commandScrollTop({
|
||||
scrollTop: el.scrollTop,
|
||||
viewportHeight: el.clientHeight,
|
||||
optionTop: option.offsetTop,
|
||||
optionHeight: option.offsetHeight,
|
||||
});
|
||||
},
|
||||
{ flush: "post" },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
ref="menu"
|
||||
role="listbox"
|
||||
aria-label="Commands"
|
||||
class="absolute inset-x-3 bottom-[calc(100%-0.25rem)] z-30 grid max-h-72 gap-0.5 overflow-auto rounded-lg border border-border-strong bg-popover p-1.5 shadow-md"
|
||||
>
|
||||
<button
|
||||
v-for="(spec, index) in matches"
|
||||
:key="spec.command"
|
||||
type="button"
|
||||
role="option"
|
||||
:aria-selected="index === selection"
|
||||
class="grid grid-cols-[minmax(8rem,14rem)_1fr] items-center gap-2.5 rounded-md border border-transparent px-2.5 py-2 text-left text-fg-muted hover:bg-muted hover:text-foreground aria-selected:border-border aria-selected:bg-muted aria-selected:text-foreground"
|
||||
@mousedown.prevent
|
||||
@click="emit('choose', index)"
|
||||
>
|
||||
<code class="truncate text-foreground">{{ spec.command }}</code>
|
||||
<span class="truncate">{{ spec.description || spec.usage || "" }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,46 @@
|
||||
<script setup lang="ts">
|
||||
import { Wrench } from "@lucide/vue";
|
||||
import { computed } from "vue";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
import ChatNavChip from "./ChatNavChip.vue";
|
||||
import type { ChatToolCall } from "./state";
|
||||
|
||||
/**
|
||||
* One tool call: the name, the parameters it was given, and what came back.
|
||||
*
|
||||
* A quiet log line rather than the point of the reply: it is evidence for the
|
||||
* answer under it, so it is smaller and dimmer than the text it produced, and
|
||||
* a failed call is the only thing here that raises its voice. An empty list
|
||||
* renders nothing, so a turn that called no tools looks untouched.
|
||||
*/
|
||||
const props = defineProps<{
|
||||
tool: ChatToolCall;
|
||||
/** The turn is still arriving, so a call with no outcome yet is running. */
|
||||
streaming?: boolean;
|
||||
}>();
|
||||
|
||||
const name = computed(() => props.tool.name || props.tool.Name || props.tool.tool || "tool");
|
||||
const parameters = computed(() => props.tool.parameters || props.tool.Parameters || "");
|
||||
const failed = computed(() => Boolean(props.tool.err || props.tool.Err || props.tool.failed));
|
||||
|
||||
// A recorded turn reports its outcome in summary, a live frame in text, and a
|
||||
// failure may only carry the error. Which words stand in for silence depends on
|
||||
// whether the turn is still going: "running…" is true mid-turn and a lie after.
|
||||
const summary = computed(() => {
|
||||
const reported = props.tool.summary || props.tool.Summary || props.tool.text || props.tool.err || props.tool.Err;
|
||||
if (reported) return reported;
|
||||
if (!props.streaming) return "done";
|
||||
return failed.value ? "failed" : "running…";
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ChatNavChip v-if="tool.path" :path="tool.path" :label="tool.label" />
|
||||
<div v-else class="flex items-baseline gap-1.5 [overflow-wrap:anywhere]">
|
||||
<Wrench aria-hidden="true" class="size-3.5 shrink-0 self-center text-fg-subtle" />
|
||||
<span class="font-semibold text-foreground">{{ name }}</span>
|
||||
<code v-if="parameters" class="font-mono text-[0.95em] text-fg-subtle">{{ parameters }}</code>
|
||||
<span :class="cn('text-fg-muted', failed && 'text-danger')">{{ summary }}</span>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,87 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from "vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import ChatBubble from "./ChatBubble.vue";
|
||||
import ChatEmptyState from "./ChatEmptyState.vue";
|
||||
import { messages, sendMessage, streamingTurn, type ChatMessage } from "./state";
|
||||
|
||||
/**
|
||||
* The conversation: the messages so far, the turn still arriving, and what the
|
||||
* panel says before either exists. It scrolls itself to the newest line, so a
|
||||
* streamed answer stays in view as it grows.
|
||||
*/
|
||||
const emit = defineEmits<{ prompt: [text: string] }>();
|
||||
|
||||
const scroller = ref<{ $el: HTMLElement } | null>(null);
|
||||
|
||||
function parts(message: ChatMessage) {
|
||||
const from = message.from ?? message.From ?? "";
|
||||
// Anything this browser's composer did not send is Archie's answer.
|
||||
return {
|
||||
text: message.text ?? message.Text ?? "",
|
||||
tools: message.tool_calls || message.ToolCalls || [],
|
||||
assistant: from !== "web",
|
||||
};
|
||||
}
|
||||
|
||||
const bubbles = computed(() => messages.value.map(parts));
|
||||
|
||||
// ScrollArea renders its own scrollable element, so the way to follow the tail
|
||||
// is to reach into the component for it. Asking the wrapper instead would set
|
||||
// scrollTop on a box that does not scroll.
|
||||
function viewport(): HTMLElement | null {
|
||||
return scroller.value?.$el?.querySelector<HTMLElement>('[data-slot="scroll-area-viewport"]') ?? null;
|
||||
}
|
||||
|
||||
// Auto scroll to the bottom on a new message or a streamed token. flush: 'post'
|
||||
// measures after the new content is in the DOM; measuring before that reads the
|
||||
// height the transcript is about to replace.
|
||||
watch(
|
||||
[messages, streamingTurn],
|
||||
() => {
|
||||
const el = viewport();
|
||||
if (el) el.scrollTop = el.scrollHeight;
|
||||
},
|
||||
{ flush: "post" },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ScrollArea ref="scroller" class="min-h-0 flex-1">
|
||||
<div class="grid content-start gap-4 p-4">
|
||||
<ChatEmptyState v-if="!bubbles.length && !streamingTurn" @prompt="emit('prompt', $event)" />
|
||||
|
||||
<template v-else>
|
||||
<ChatBubble
|
||||
v-for="(bubble, i) in bubbles"
|
||||
:key="i"
|
||||
:text="bubble.text"
|
||||
:tools="bubble.tools"
|
||||
:assistant="bubble.assistant"
|
||||
/>
|
||||
|
||||
<!-- The live turn is a bubble like any other, so what arrives is
|
||||
rendered by the same rules as what was already there. -->
|
||||
<ChatBubble
|
||||
v-if="streamingTurn"
|
||||
:text="streamingTurn.text || '…'"
|
||||
:tools="streamingTurn.tools"
|
||||
assistant
|
||||
streaming
|
||||
>
|
||||
<Button
|
||||
v-if="streamingTurn.isError && streamingTurn.turn"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
class="mt-2"
|
||||
@click="sendMessage({ turn: streamingTurn.turn })"
|
||||
>
|
||||
Retry
|
||||
</Button>
|
||||
</ChatBubble>
|
||||
</template>
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
import { randomUUID } from "@/lib/uuid";
|
||||
|
||||
const CHANNEL_KEY = "archie.web.chat.channel";
|
||||
|
||||
/**
|
||||
* The browser's chat identity. The server keys a conversation on the channel
|
||||
* alone (the browser has no threading), so this is persisted: a reload rejoins
|
||||
* the conversation instead of starting a second one beside it.
|
||||
*/
|
||||
export function channelID(): string {
|
||||
let id = localStorage.getItem(CHANNEL_KEY);
|
||||
if (!id) {
|
||||
id = randomUUID();
|
||||
localStorage.setItem(CHANNEL_KEY, id);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import type { ChatCommandSpec } from "./state";
|
||||
|
||||
/**
|
||||
* The slash palette's arithmetic, kept out of the composer so it is decided in
|
||||
* one place rather than reconstructed from DOM positions twice.
|
||||
*/
|
||||
|
||||
/** The command token the caret sits in: a slash word at the start or after a space. */
|
||||
const OPEN_TOKEN = /(?:^|\s)\/([^\s]*)$/;
|
||||
const ANY_TOKEN = /(?:^|\s)\/[^\s]*$/;
|
||||
|
||||
/** How many matches the palette will show at once. */
|
||||
const MAX_MATCHES = 8;
|
||||
|
||||
/**
|
||||
* matchesFor returns the commands worth offering for the text before the
|
||||
* caret, matched on the command and its description together so a word from
|
||||
* either finds it.
|
||||
*/
|
||||
export function matchesFor(specs: ChatCommandSpec[], value: string, caret: number): ChatCommandSpec[] {
|
||||
const match = value.slice(0, caret).match(OPEN_TOKEN);
|
||||
if (!match) return [];
|
||||
const query = match[1].toLowerCase();
|
||||
return specs
|
||||
.filter((spec) => `${spec.command} ${spec.description ?? ""}`.toLowerCase().includes(query))
|
||||
.slice(0, MAX_MATCHES);
|
||||
}
|
||||
|
||||
/**
|
||||
* applyCommand replaces the token being completed with the chosen command and
|
||||
* returns the cursor position just after it, ready for the next word.
|
||||
*/
|
||||
export function applyCommand(value: string, caret: number, command: string): { text: string; cursor: number } {
|
||||
const before = value.slice(0, caret);
|
||||
const after = value.slice(caret);
|
||||
const start = before.search(ANY_TOKEN);
|
||||
const tokenStart = start < 0 ? before.length : start + (before[start] === " " ? 1 : 0);
|
||||
return {
|
||||
text: `${before.slice(0, tokenStart)}${command} ${after}`,
|
||||
cursor: tokenStart + command.length + 1,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* isExactCommand reports whether the composer already holds a command and
|
||||
* nothing else. Enter then sends it rather than completing it, so a command
|
||||
* typed in full is never re-entered by the palette that was offering it.
|
||||
*/
|
||||
export function isExactCommand(specs: ChatCommandSpec[], value: string): boolean {
|
||||
const trimmed = value.trim();
|
||||
return specs.some((spec) => spec.command === trimmed);
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
/**
|
||||
* Chat markdown.
|
||||
*
|
||||
* Telegram-style rich blocks -- headings, lists, quotes, fenced code, tables,
|
||||
* inline emphasis/links/images -- parsed into a tree that ChatMarkdown renders
|
||||
* as semantic HTML. The parse is separate from the render so a streamed reply
|
||||
* can be re-rendered on every frame without re-deciding what the text means.
|
||||
*/
|
||||
|
||||
/** One span of an inline run: what a paragraph's text breaks down into. */
|
||||
export type ChatInline =
|
||||
| { kind: "text"; text: string }
|
||||
| { kind: "strong"; text: string }
|
||||
| { kind: "em"; text: string }
|
||||
| { kind: "del"; text: string }
|
||||
| { kind: "code"; text: string }
|
||||
| { kind: "link"; text: string; href: string }
|
||||
| { kind: "image"; alt: string; src: string };
|
||||
|
||||
/** One block of the document. Lists carry their items as inline runs. */
|
||||
export type ChatBlock =
|
||||
| { kind: "p" | "h1" | "h2" | "h3" | "blockquote"; inline: ChatInline[] }
|
||||
| { kind: "ul" | "ol"; items: ChatInline[][] }
|
||||
| { kind: "pre"; code: string }
|
||||
| { kind: "table"; head: ChatInline[][]; rows: ChatInline[][][] };
|
||||
|
||||
const INLINE =
|
||||
/(!\[[^\]]*\]\((?:https?:\/\/[^\s)]+|data:image\/[^\s)]+|\/[^\s)]+)\)|~~[^~]+~~|\*\*[^*]+\*\*|__[^_]+__|`[^`]+`|\[[^\]]+\]\((?:https?:\/\/[^\s)]+|\/[^\s)]+)\)|\*[^*]+\*|_[^_]+_)/g;
|
||||
|
||||
// inlineMarkdown returns the children of one line: plain text and the element
|
||||
// each matched span becomes, in order.
|
||||
function inlineMarkdown(text: string): ChatInline[] {
|
||||
const children: ChatInline[] = [];
|
||||
let cursor = 0;
|
||||
for (const match of String(text).matchAll(INLINE)) {
|
||||
if (match.index > cursor) children.push({ kind: "text", text: text.slice(cursor, match.index) });
|
||||
const value = match[0];
|
||||
if (value.startsWith("![")) {
|
||||
const img = value.match(/^!\[([^\]]*)\]\((.+)\)$/);
|
||||
if (img) children.push({ kind: "image", alt: img[1] || "Image", src: img[2] });
|
||||
} else if (value.startsWith("~~")) {
|
||||
children.push({ kind: "del", text: value.slice(2, -2) });
|
||||
} else if (value.startsWith("**") || value.startsWith("__")) {
|
||||
children.push({ kind: "strong", text: value.slice(2, -2) });
|
||||
} else if (value.startsWith("`")) {
|
||||
children.push({ kind: "code", text: value.slice(1, -1) });
|
||||
} else if (value.startsWith("[")) {
|
||||
const link = value.match(/^\[([^\]]+)\]\((https?:\/\/[^\s)]+|\/[^\s)]+)\)$/);
|
||||
if (link) children.push({ kind: "link", text: link[1], href: link[2] });
|
||||
} else {
|
||||
children.push({ kind: "em", text: value.slice(1, -1) });
|
||||
}
|
||||
cursor = match.index + value.length;
|
||||
}
|
||||
if (cursor < text.length) children.push({ kind: "text", text: text.slice(cursor) });
|
||||
return children;
|
||||
}
|
||||
|
||||
export function parseMarkdown(text: string | null | undefined): ChatBlock[] {
|
||||
const blocks: ChatBlock[] = [];
|
||||
const lines = String(text || "").split("\n");
|
||||
let paragraph: string[] = [];
|
||||
let list: { tag: "ul" | "ol"; items: string[] } | null = null;
|
||||
let code: string[] | null = null;
|
||||
|
||||
const flushParagraph = () => {
|
||||
if (paragraph.length) {
|
||||
blocks.push({ kind: "p", inline: inlineMarkdown(paragraph.join(" ")) });
|
||||
paragraph = [];
|
||||
}
|
||||
};
|
||||
const flushList = () => {
|
||||
if (!list) return;
|
||||
blocks.push({ kind: list.tag, items: list.items.map((item) => inlineMarkdown(item)) });
|
||||
list = null;
|
||||
};
|
||||
|
||||
for (let index = 0; index < lines.length; index++) {
|
||||
const line = lines[index];
|
||||
if (line.startsWith("```")) {
|
||||
flushParagraph();
|
||||
flushList();
|
||||
if (code) {
|
||||
blocks.push({ kind: "pre", code: code.join("\n") });
|
||||
code = null;
|
||||
} else {
|
||||
code = [];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (code) {
|
||||
code.push(line);
|
||||
continue;
|
||||
}
|
||||
const headerCells = tableCells(line);
|
||||
const separatorCells = index + 1 < lines.length ? tableCells(lines[index + 1]) : null;
|
||||
if (
|
||||
headerCells &&
|
||||
separatorCells &&
|
||||
isTableSeparator(separatorCells) &&
|
||||
headerCells.length === separatorCells.length
|
||||
) {
|
||||
flushParagraph();
|
||||
flushList();
|
||||
const rows: string[][] = [];
|
||||
for (index += 2; index < lines.length; index++) {
|
||||
const cells = tableCells(lines[index]);
|
||||
if (!cells || cells.length !== headerCells.length) {
|
||||
index--;
|
||||
break;
|
||||
}
|
||||
rows.push(cells);
|
||||
}
|
||||
blocks.push({
|
||||
kind: "table",
|
||||
head: headerCells.map((cell) => inlineMarkdown(cell)),
|
||||
rows: rows.map((row) => row.map((cell) => inlineMarkdown(cell))),
|
||||
});
|
||||
continue;
|
||||
}
|
||||
if (!line.trim()) {
|
||||
flushParagraph();
|
||||
flushList();
|
||||
continue;
|
||||
}
|
||||
const heading = line.match(/^(#{1,3})\s+(.+)$/);
|
||||
if (heading) {
|
||||
flushParagraph();
|
||||
flushList();
|
||||
blocks.push({ kind: `h${heading[1].length}` as "h1" | "h2" | "h3", inline: inlineMarkdown(heading[2]) });
|
||||
continue;
|
||||
}
|
||||
const bullet = line.match(/^\s*[-*]\s+(.+)$/);
|
||||
const ordered = line.match(/^\s*\d+[.)]\s+(.+)$/);
|
||||
if (bullet || ordered) {
|
||||
flushParagraph();
|
||||
const tag = ordered ? "ol" : "ul";
|
||||
if (!list || list.tag !== tag) {
|
||||
flushList();
|
||||
list = { tag, items: [] };
|
||||
}
|
||||
list.items.push((bullet || ordered)![1]);
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith(">")) {
|
||||
flushParagraph();
|
||||
flushList();
|
||||
blocks.push({ kind: "blockquote", inline: inlineMarkdown(line.replace(/^>\s?/, "")) });
|
||||
continue;
|
||||
}
|
||||
paragraph.push(line);
|
||||
}
|
||||
flushParagraph();
|
||||
flushList();
|
||||
if (code) blocks.push({ kind: "pre", code: code.join("\n") });
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
function tableCells(line: string): string[] | null {
|
||||
const value = String(line || "").trim();
|
||||
if (!value.includes("|")) return null;
|
||||
const unwrapped = value.replace(/^\|/, "").replace(/\|$/, "");
|
||||
const cells = unwrapped.split("|").map((cell) => cell.trim());
|
||||
return cells.length > 1 && cells.every((cell) => cell !== "") ? cells : null;
|
||||
}
|
||||
|
||||
function isTableSeparator(cells: string[]): boolean {
|
||||
return cells.every((cell) => /^:?-{3,}:?$/.test(cell));
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import type { ChatSession } from "./state";
|
||||
|
||||
export function sessionTitle(session: ChatSession): string {
|
||||
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: ChatSession[], currentSession: string): string {
|
||||
if (!currentSession) return "Archie";
|
||||
const session = (sessions || []).find((item) => item.session_id === currentSession);
|
||||
return session ? sessionTitle(session) : "Archie";
|
||||
}
|
||||
@@ -0,0 +1,462 @@
|
||||
import { computed, onMounted, onUnmounted, ref, watch, type Ref } from "vue";
|
||||
|
||||
import { api } from "@/lib/api";
|
||||
import { channelID } from "./channel";
|
||||
import { matchesFor } from "./commands";
|
||||
import { resolveTurn, retryChatTurn, type ChatTurn, type RetryOptions } from "./turn";
|
||||
|
||||
/**
|
||||
* The chat panel's shared state.
|
||||
*
|
||||
* The launcher and the panel are separate components and the panel survives a
|
||||
* navigation, so the conversation lives in a module rather than in either one.
|
||||
* Everything the server answers with is read here; the components decide how it
|
||||
* looks.
|
||||
*/
|
||||
|
||||
/** One web conversation, as GET /api/chat/sessions lists it. */
|
||||
export interface ChatSession {
|
||||
session_id: string;
|
||||
title?: string;
|
||||
branch_name?: string;
|
||||
}
|
||||
|
||||
/** One slash command the server will accept. */
|
||||
export interface ChatCommandSpec {
|
||||
command: string;
|
||||
usage?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A tool the assistant called. A live frame names the tool in `tool` and
|
||||
* carries its outcome in `text`; a recorded turn uses `name` and `summary`.
|
||||
*/
|
||||
export interface ChatToolCall {
|
||||
id?: string;
|
||||
name?: string;
|
||||
tool?: string;
|
||||
parameters?: string;
|
||||
summary?: string;
|
||||
text?: string;
|
||||
failed?: boolean;
|
||||
/** A dashboard_navigate result: the page to route to, instead of a tool line. */
|
||||
path?: string;
|
||||
label?: string;
|
||||
// The same view reaches the browser from more than one composition, so an
|
||||
// outcome may arrive under either spelling. `err`/`Err` is also how a failed
|
||||
// call reports itself: it is a result, not a missing one.
|
||||
Name?: string;
|
||||
Parameters?: string;
|
||||
Summary?: string;
|
||||
Err?: string;
|
||||
err?: string;
|
||||
}
|
||||
|
||||
/** One message in the transcript, from either side. */
|
||||
export interface ChatMessage {
|
||||
from?: string;
|
||||
text?: string;
|
||||
tool_calls?: ChatToolCall[];
|
||||
// The same view reaches the browser from more than one composition, so both
|
||||
// spellings are read rather than assuming one serialiser.
|
||||
From?: string;
|
||||
Text?: string;
|
||||
ToolCalls?: ChatToolCall[];
|
||||
message_id?: string;
|
||||
MessageID?: string;
|
||||
}
|
||||
|
||||
/** A turn in flight: what it is showing, and what to resend if it fails. */
|
||||
export interface StreamingTurn {
|
||||
text: string;
|
||||
tools: ChatToolCall[];
|
||||
isError: boolean;
|
||||
turn?: ChatTurn;
|
||||
isRetry: boolean;
|
||||
}
|
||||
|
||||
/** Everything the selectors on the panel read, from one sessions read. */
|
||||
export interface ChatSelectorData {
|
||||
personas?: string[];
|
||||
providers?: string[];
|
||||
models?: string[];
|
||||
models_by_provider?: Record<string, string[]>;
|
||||
active_persona?: string;
|
||||
active_personas?: Record<string, string>;
|
||||
active_provider?: string;
|
||||
active_model?: string;
|
||||
commands?: Array<ChatCommandSpec | string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The id the launcher points its `aria-controls` at and the panel answers to.
|
||||
* Both read it here so the pair cannot drift apart.
|
||||
*/
|
||||
export const CHAT_PANEL_ID = "chat-panel";
|
||||
|
||||
/**
|
||||
* One `data: {...}` frame of the chat stream. The server always emits `text`,
|
||||
* empty or not: the browser concatenates it, so a missing key would put the
|
||||
* string "undefined" into the transcript on a turn whose reply is empty.
|
||||
*/
|
||||
interface ChatStreamFrame extends ChatToolCall {
|
||||
type?: string;
|
||||
text: string;
|
||||
session_id?: string;
|
||||
}
|
||||
|
||||
/** A turn that never settles must not hold the composer closed forever. */
|
||||
const STREAM_TIMEOUT_MS = 120000;
|
||||
|
||||
export const sessions = ref<ChatSession[]>([]);
|
||||
export const currentSession = ref("");
|
||||
export const messages = ref<ChatMessage[]>([]);
|
||||
export const composerText = ref("");
|
||||
export const statusText = ref("Ready");
|
||||
export const isSending = ref(false);
|
||||
export const streamingTurn = ref<StreamingTurn | null>(null);
|
||||
|
||||
export const selectorData = ref<ChatSelectorData>({});
|
||||
export const selectedPersona = ref("");
|
||||
export const selectedProvider = ref("");
|
||||
export const selectedModel = ref("");
|
||||
|
||||
export const commandSpecs = ref<ChatCommandSpec[]>([]);
|
||||
export const commandMatches = ref<ChatCommandSpec[]>([]);
|
||||
export const commandSelection = ref(0);
|
||||
export const isCommandMenuOpen = ref(false);
|
||||
|
||||
export const currentModels = computed(() => {
|
||||
const grouped = selectorData.value.models_by_provider || {};
|
||||
const provider = selectedProvider.value;
|
||||
return provider && grouped[provider] ? grouped[provider] : selectorData.value.models || [];
|
||||
});
|
||||
|
||||
/**
|
||||
* How many layers inside the panel currently own Escape -- an open popover, a
|
||||
* select inside one.
|
||||
*
|
||||
* The panel's own Escape defers to them. Dismissing a menu must not also throw
|
||||
* away the conversation the menu was opened over, and a layer that dismissed
|
||||
* both would make the panel impossible to keep open while consulting it.
|
||||
*/
|
||||
const openLayers = ref(0);
|
||||
|
||||
/** Registers a toggleable layer inside the panel, for as long as it is mounted. */
|
||||
export function useEscapeLayer(open: Ref<boolean>): void {
|
||||
watch(open, (isOpen) => {
|
||||
openLayers.value += isOpen ? 1 : -1;
|
||||
});
|
||||
onUnmounted(() => {
|
||||
if (open.value) openLayers.value -= 1;
|
||||
});
|
||||
}
|
||||
|
||||
export function escapeOwnedByLayer(): boolean {
|
||||
return openLayers.value > 0;
|
||||
}
|
||||
|
||||
let activeController: AbortController | null = null;
|
||||
|
||||
// The send path holds a stream loop that outlives the click that started it; a
|
||||
// module-level controller is what a Stop, or an unmount, aborts.
|
||||
function abortActiveTurn(): void {
|
||||
activeController?.abort();
|
||||
}
|
||||
|
||||
export async function refreshSessions(): Promise<void> {
|
||||
const data = await api.chatSessions<ChatSelectorData & { sessions?: ChatSession[] }>();
|
||||
const sessionList = data.sessions || [];
|
||||
sessions.value = sessionList;
|
||||
selectorData.value = data;
|
||||
|
||||
selectedPersona.value = data.active_persona || "";
|
||||
const providers = data.providers || [];
|
||||
selectedProvider.value = data.active_provider || providers[0] || "";
|
||||
selectedModel.value = data.active_model || "";
|
||||
|
||||
commandSpecs.value = (data.commands || []).map((item) =>
|
||||
typeof item === "string" ? { command: item, usage: item, description: "" } : item,
|
||||
);
|
||||
|
||||
if (!currentSession.value && sessionList[0]) {
|
||||
// Vue's reactivity makes the assignment above readable here immediately, so
|
||||
// the read that selects the first conversation needs no data threaded into
|
||||
// it the way the Preact tree had to pass its own copy.
|
||||
await selectSession(sessionList[0].session_id);
|
||||
}
|
||||
}
|
||||
|
||||
export async function selectSession(id: string): Promise<void> {
|
||||
if (!id) return;
|
||||
const data = selectorData.value;
|
||||
currentSession.value = id;
|
||||
messages.value = [];
|
||||
streamingTurn.value = null;
|
||||
|
||||
selectedPersona.value = data.active_personas?.[id] || data.active_persona || "";
|
||||
|
||||
try {
|
||||
// Resuming is the server's own command, so the transcript read below is of
|
||||
// a conversation the server considers current rather than a stale one.
|
||||
await api.chatMessage(channelID(), `/resume ${id}`);
|
||||
const [msgs, turns] = await Promise.all([api.chatMessages<ChatMessage[]>(id), api.chatTurns<ChatTurnView[]>(id)]);
|
||||
const byAssistantMessage = new Map<string, ChatTurnView>();
|
||||
for (const turn of turns || []) {
|
||||
const assistantID = turn.assistant_message_id || turn.AssistantMessageID;
|
||||
if (assistantID) byAssistantMessage.set(assistantID, turn);
|
||||
}
|
||||
// Tool calls belong to the turn, not the message, so a reopened
|
||||
// conversation gets its transcript back with the evidence in place.
|
||||
messages.value = (msgs || []).map((message) => {
|
||||
const messageID = message.message_id || message.MessageID;
|
||||
const turn = messageID ? byAssistantMessage.get(messageID) : undefined;
|
||||
return turn ? { ...message, tool_calls: turn.tool_calls || turn.ToolCalls || [] } : message;
|
||||
});
|
||||
} catch (err) {
|
||||
statusText.value = (err as Error).message || "Could not load session messages";
|
||||
}
|
||||
}
|
||||
|
||||
/** One recorded turn, as GET /api/chat/sessions/{id}/turns returns it. */
|
||||
interface ChatTurnView {
|
||||
assistant_message_id?: string;
|
||||
AssistantMessageID?: string;
|
||||
tool_calls?: ChatToolCall[];
|
||||
ToolCalls?: ChatToolCall[];
|
||||
}
|
||||
|
||||
export async function runSessionCommand(command: string): Promise<void> {
|
||||
if (!currentSession.value) return;
|
||||
try {
|
||||
statusText.value = "Working…";
|
||||
const result = await api.chatMessage<{ session_id?: string; reply?: string }>(channelID(), command);
|
||||
if (result.session_id) currentSession.value = result.session_id;
|
||||
statusText.value = result.reply || "Session updated";
|
||||
await refreshSessions();
|
||||
if (result.session_id || currentSession.value) {
|
||||
await selectSession(result.session_id || currentSession.value);
|
||||
}
|
||||
} catch (err) {
|
||||
statusText.value = (err as Error).message || "Session action failed";
|
||||
}
|
||||
}
|
||||
|
||||
// Rename and branch take a value the server has no form for, so the browser's
|
||||
// own prompt is the input: a modal built for two commands would be more UI than
|
||||
// the two commands are worth.
|
||||
export function promptSessionCommand(command: string, message: string): void {
|
||||
const value = window.prompt(message);
|
||||
if (value?.trim()) void runSessionCommand(`${command} ${value.trim()}`);
|
||||
}
|
||||
|
||||
export function setPersona(name: string): void {
|
||||
selectedPersona.value = name;
|
||||
const session = currentSession.value;
|
||||
if (!session || !name) return;
|
||||
api
|
||||
.chatPersona(session, name)
|
||||
.then(() => {
|
||||
const data = selectorData.value;
|
||||
selectorData.value = {
|
||||
...data,
|
||||
active_personas: { ...(data.active_personas || {}), [session]: name },
|
||||
};
|
||||
statusText.value = `Personality: ${name}`;
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
statusText.value = err.message || "Failed to set personality";
|
||||
});
|
||||
}
|
||||
|
||||
export async function setProvider(provider: string): Promise<void> {
|
||||
selectedProvider.value = provider;
|
||||
if (!provider) return;
|
||||
try {
|
||||
const result = await api.chatMessage<{ reply?: string }>(channelID(), `/model --provider ${provider}`);
|
||||
statusText.value = result.reply || "Provider updated";
|
||||
await refreshSessions();
|
||||
} catch (err) {
|
||||
statusText.value = `Provider update failed: ${(err as Error).message || err}`;
|
||||
}
|
||||
}
|
||||
|
||||
export async function setModel(model: string): Promise<void> {
|
||||
selectedModel.value = model;
|
||||
if (!model) return;
|
||||
try {
|
||||
const result = await api.chatMessage<{ reply?: string }>(channelID(), `/model ${model}`);
|
||||
statusText.value = result.reply || "Model updated";
|
||||
await refreshSessions();
|
||||
} catch (err) {
|
||||
statusText.value = `Model update failed: ${(err as Error).message || err}`;
|
||||
}
|
||||
}
|
||||
|
||||
export function newChat(): void {
|
||||
composerText.value = "/new";
|
||||
void sendMessage({ textOverride: "/new" });
|
||||
}
|
||||
|
||||
/** Opens the palette for the slash word the caret sits in, or closes it. */
|
||||
export function syncCommandMenu(value: string, caret: number): void {
|
||||
const matches = matchesFor(commandSpecs.value, value, caret);
|
||||
if (matches.length) {
|
||||
commandMatches.value = matches;
|
||||
commandSelection.value = 0;
|
||||
isCommandMenuOpen.value = true;
|
||||
return;
|
||||
}
|
||||
isCommandMenuOpen.value = false;
|
||||
commandMatches.value = [];
|
||||
}
|
||||
|
||||
export function closeCommandMenu(): void {
|
||||
isCommandMenuOpen.value = false;
|
||||
}
|
||||
|
||||
export function moveCommandSelection(delta: number): void {
|
||||
const length = commandMatches.value.length;
|
||||
if (!length) return;
|
||||
commandSelection.value = (commandSelection.value + delta + length) % length;
|
||||
}
|
||||
|
||||
/** The page the operator asked from, so an answer can be about what they saw. */
|
||||
function currentPage(): string {
|
||||
return location.pathname + location.search || "/";
|
||||
}
|
||||
|
||||
export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
|
||||
const explicitText = retryOpts?.textOverride;
|
||||
const rawValue = explicitText !== undefined ? explicitText : composerText.value;
|
||||
const { text, turn, isRetry } = resolveTurn(retryOpts, rawValue);
|
||||
if (!text || isSending.value) return;
|
||||
|
||||
closeCommandMenu();
|
||||
isSending.value = true;
|
||||
statusText.value = isRetry ? "Retrying…" : "Thinking…";
|
||||
|
||||
if (!isRetry) {
|
||||
messages.value = [...messages.value, { from: "web", text }];
|
||||
composerText.value = "";
|
||||
}
|
||||
|
||||
let activeTools: ChatToolCall[] = [];
|
||||
streamingTurn.value = { text: "", tools: [], isError: false, turn, isRetry };
|
||||
|
||||
let streamedText = "";
|
||||
let finished = false;
|
||||
let timedOut = false;
|
||||
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
||||
|
||||
try {
|
||||
const controller = new AbortController();
|
||||
activeController = controller;
|
||||
timeoutId = setTimeout(() => {
|
||||
timedOut = true;
|
||||
controller.abort();
|
||||
}, STREAM_TIMEOUT_MS);
|
||||
|
||||
const response = await api.chatStream(
|
||||
{
|
||||
channel_id: channelID(),
|
||||
source_id: turn.sourceID,
|
||||
text: turn.text,
|
||||
page: currentPage(),
|
||||
},
|
||||
{ signal: controller.signal },
|
||||
);
|
||||
const body = response.body;
|
||||
if (!body) throw new Error("the chat stream returned no body");
|
||||
|
||||
const reader = body.getReader();
|
||||
const decoder = new TextDecoder();
|
||||
let buffer = "";
|
||||
|
||||
// Drained to completion: the stream is read until the reader reports done,
|
||||
// and a turn that ends without a `done` frame is a failed turn rather than
|
||||
// a short one. Reading only some frames leaves the producer writing into a
|
||||
// stream nobody collects.
|
||||
for (;;) {
|
||||
const { value, done } = await reader.read();
|
||||
buffer += decoder.decode(value || new Uint8Array(), { stream: !done });
|
||||
const frames = buffer.split("\n\n");
|
||||
buffer = frames.pop() || "";
|
||||
for (const frame of frames) {
|
||||
const line = frame.split("\n").find((part) => part.startsWith("data: "));
|
||||
if (!line) continue;
|
||||
const event = JSON.parse(line.slice(6)) as ChatStreamFrame;
|
||||
if (event.session_id) currentSession.value = event.session_id;
|
||||
if (event.type === "delta") {
|
||||
streamedText += event.text;
|
||||
streamingTurn.value = streamingTurn.value ? { ...streamingTurn.value, text: streamedText } : null;
|
||||
}
|
||||
// A navigate result is appended to the same list as the tool calls: it
|
||||
// is one more thing the turn did, and it renders as a chip rather than
|
||||
// a tool line.
|
||||
if (event.type === "tool" || event.type === "navigate") {
|
||||
activeTools = [...activeTools, event];
|
||||
streamingTurn.value = streamingTurn.value ? { ...streamingTurn.value, tools: activeTools } : null;
|
||||
}
|
||||
if (event.type === "done") {
|
||||
finished = true;
|
||||
if (!streamedText) streamedText = event.text || "";
|
||||
}
|
||||
if (event.type === "error") throw new Error(event.text);
|
||||
}
|
||||
if (done) break;
|
||||
}
|
||||
|
||||
if (!finished) throw new Error("chat stream ended before completion");
|
||||
|
||||
messages.value = [...messages.value, { from: "assistant", text: streamedText, tool_calls: activeTools }];
|
||||
streamingTurn.value = null;
|
||||
statusText.value = "Ready";
|
||||
await refreshSessions();
|
||||
} catch (err) {
|
||||
const failed = err as Error;
|
||||
if (failed.name === "AbortError" && !timedOut) {
|
||||
streamingTurn.value = { text: "Turn stopped.", tools: activeTools, isError: false, turn, isRetry };
|
||||
statusText.value = "Stopped";
|
||||
} else {
|
||||
streamingTurn.value = {
|
||||
text: `Unable to complete that turn: ${failed.message || failed}`,
|
||||
tools: activeTools,
|
||||
isError: true,
|
||||
turn: turn ? retryChatTurn(turn) : undefined,
|
||||
isRetry,
|
||||
};
|
||||
statusText.value = "Error — retry available";
|
||||
}
|
||||
} finally {
|
||||
clearTimeout(timeoutId);
|
||||
activeController = null;
|
||||
isSending.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
export function stopTurn(): void {
|
||||
statusText.value = "Stopping…";
|
||||
if (currentSession.value) {
|
||||
void api.chatCancel(currentSession.value).catch(() => {});
|
||||
}
|
||||
abortActiveTurn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Owns the first sessions read and the teardown of an in-flight turn for the
|
||||
* panel's lifetime. The panel is mounted once beside the outlet and stays
|
||||
* mounted while it is closed, so opening it is a prop change rather than a
|
||||
* mount and the conversation survives a navigation.
|
||||
*/
|
||||
export function useChat(): void {
|
||||
onMounted(() => {
|
||||
refreshSessions().catch((err: Error) => {
|
||||
statusText.value = err.message || "Chat unavailable";
|
||||
});
|
||||
});
|
||||
onUnmounted(() => {
|
||||
abortActiveTurn();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import { randomUUID } from "@/lib/uuid";
|
||||
|
||||
/**
|
||||
* What a send puts on the wire: the text, and the source id the server keys
|
||||
* the turn on so a retry of the same turn is recognisable as one.
|
||||
*/
|
||||
export interface ChatTurn {
|
||||
text: string;
|
||||
sourceID: string;
|
||||
}
|
||||
|
||||
export function newChatTurn(text: string): ChatTurn {
|
||||
return { text, sourceID: randomUUID() };
|
||||
}
|
||||
|
||||
export function retryChatTurn(turn: ChatTurn): ChatTurn {
|
||||
return { ...turn };
|
||||
}
|
||||
|
||||
/** A retry descriptor as the transcript holds it, or nothing for a fresh send. */
|
||||
export interface RetryOptions {
|
||||
textOverride?: string;
|
||||
turn?: ChatTurn;
|
||||
}
|
||||
|
||||
// resolveTurn decides what to send: a real retry descriptor's original turn,
|
||||
// or a fresh turn built from the composer text. `retry` is untrusted here --
|
||||
// a DOM event handler bound as `el.onclick = sendMessage` (rather than
|
||||
// `() => sendMessage()`) hands the click's MouseEvent to this function as
|
||||
// `retry`, and a MouseEvent is truthy but has no `.turn`. Only an object
|
||||
// carrying a `turn.text` string counts as a genuine retry; anything else
|
||||
// (including no argument) falls back to the composer text instead of
|
||||
// throwing on a missing property.
|
||||
export function resolveTurn(
|
||||
retry: RetryOptions | null | undefined,
|
||||
composerValue: string,
|
||||
): { text: string; turn: ChatTurn; isRetry: boolean } {
|
||||
const isRetry = !!(retry && typeof retry === "object" && retry.turn && typeof retry.turn.text === "string");
|
||||
const text = isRetry ? retry.turn!.text : composerValue.trim();
|
||||
const turn = isRetry ? retryChatTurn(retry.turn!) : newChatTurn(text);
|
||||
return { text, turn, isRetry };
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { Moon, Sun } from "@lucide/vue";
|
||||
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { theme, toggleTheme } from "@/lib/theme";
|
||||
|
||||
const label = computed(() => (theme.value === "dark" ? "Switch to light" : "Switch to dark"));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Tooltip>
|
||||
<TooltipTrigger as-child>
|
||||
<button
|
||||
type="button"
|
||||
class="text-muted-foreground hover:text-foreground hover:bg-accent focus-visible:ring-ring/50 inline-flex size-8 items-center justify-center rounded-md outline-none focus-visible:ring-[3px]"
|
||||
:aria-label="label"
|
||||
@click="toggleTheme()"
|
||||
>
|
||||
<component :is="theme === 'dark' ? Moon : Sun" :size="16" />
|
||||
</button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent :side-offset="8">{{ label }}</TooltipContent>
|
||||
</Tooltip>
|
||||
</template>
|
||||
@@ -4,7 +4,6 @@ import Nav from "./Nav.vue";
|
||||
import ProfileDropdown from "./ProfileDropdown.vue";
|
||||
import SearchBar from "./SearchBar.vue";
|
||||
import SupportLink from "./SupportLink.vue";
|
||||
import ThemeToggle from "./ThemeToggle.vue";
|
||||
|
||||
defineProps<{ hidden: string[] }>();
|
||||
</script>
|
||||
@@ -16,7 +15,11 @@ defineProps<{ hidden: string[] }>();
|
||||
<div class="flex shrink-0 items-center gap-1">
|
||||
<SearchBar :hidden="hidden" />
|
||||
<SupportLink />
|
||||
<ThemeToggle />
|
||||
<!--
|
||||
The theme control lives on /system/appearance, not here. Two switches
|
||||
for one preference is two places to look and one of them to be wrong
|
||||
(docs/prds/dashboard-navigation-groups.md).
|
||||
-->
|
||||
<ProfileDropdown />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import type { AlertDialogEmits, AlertDialogProps } from 'reka-ui'
|
||||
import { AlertDialogRoot, useForwardPropsEmits } from 'reka-ui'
|
||||
|
||||
const props = defineProps<AlertDialogProps>()
|
||||
const emits = defineEmits<AlertDialogEmits>()
|
||||
|
||||
const forwarded = useForwardPropsEmits(props, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialogRoot v-slot="slotProps" data-slot="alert-dialog" v-bind="forwarded">
|
||||
<slot v-bind="slotProps" />
|
||||
</AlertDialogRoot>
|
||||
</template>
|
||||
@@ -0,0 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import type { AlertDialogActionProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import type { ButtonVariants } from '@/components/ui/button'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { AlertDialogAction } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { buttonVariants } from '@/components/ui/button'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<AlertDialogActionProps & {
|
||||
class?: HTMLAttributes['class']
|
||||
variant?: ButtonVariants['variant']
|
||||
size?: ButtonVariants['size']
|
||||
}>(),
|
||||
{
|
||||
variant: 'default',
|
||||
size: 'default',
|
||||
},
|
||||
)
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class', 'variant', 'size')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialogAction
|
||||
data-slot="alert-dialog-action"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn('', buttonVariants({ variant, size }), props.class)"
|
||||
>
|
||||
<slot />
|
||||
</AlertDialogAction>
|
||||
</template>
|
||||
@@ -0,0 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import type { AlertDialogCancelProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import type { ButtonVariants } from '@/components/ui/button'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { AlertDialogCancel } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { buttonVariants } from '@/components/ui/button'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<AlertDialogCancelProps & {
|
||||
class?: HTMLAttributes['class']
|
||||
variant?: ButtonVariants['variant']
|
||||
size?: ButtonVariants['size']
|
||||
}>(),
|
||||
{
|
||||
variant: 'outline',
|
||||
size: 'default',
|
||||
},
|
||||
)
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class', 'variant', 'size')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialogCancel
|
||||
data-slot="alert-dialog-cancel"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn(
|
||||
'',
|
||||
buttonVariants({ variant, size }),
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</AlertDialogCancel>
|
||||
</template>
|
||||
@@ -0,0 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
import type { AlertDialogContentEmits, AlertDialogContentProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import {
|
||||
AlertDialogContent,
|
||||
AlertDialogOverlay,
|
||||
AlertDialogPortal,
|
||||
useForwardPropsEmits,
|
||||
} from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
})
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<AlertDialogContentProps & {
|
||||
class?: HTMLAttributes['class']
|
||||
size?: 'default' | 'sm'
|
||||
}>(),
|
||||
{
|
||||
size: 'default',
|
||||
},
|
||||
)
|
||||
const emits = defineEmits<AlertDialogContentEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class', 'size')
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialogPortal>
|
||||
<AlertDialogOverlay
|
||||
data-slot="alert-dialog-overlay"
|
||||
class="data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 z-50"
|
||||
/>
|
||||
<AlertDialogContent
|
||||
data-slot="alert-dialog-content"
|
||||
:data-size="size"
|
||||
v-bind="{ ...$attrs, ...forwarded }"
|
||||
:class="
|
||||
cn(
|
||||
'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 bg-popover text-popover-foreground ring-foreground/10 gap-4 rounded-xl p-4 ring-1 duration-100 data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 outline-none',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
</AlertDialogContent>
|
||||
</AlertDialogPortal>
|
||||
</template>
|
||||
@@ -0,0 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import type { AlertDialogDescriptionProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import {
|
||||
AlertDialogDescription,
|
||||
} from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<AlertDialogDescriptionProps & { class?: HTMLAttributes['class'] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialogDescription
|
||||
data-slot="alert-dialog-description"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn('text-muted-foreground *:[a]:hover:text-foreground text-sm text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</AlertDialogDescription>
|
||||
</template>
|
||||
@@ -0,0 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="alert-dialog-footer"
|
||||
:class="
|
||||
cn(
|
||||
'bg-muted/50 -mx-4 -mb-4 rounded-b-xl border-t p-4 flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="alert-dialog-header"
|
||||
:class="cn('grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="alert-dialog-media"
|
||||
:class="cn('bg-muted mb-2 inline-flex size-10 items-center justify-center rounded-md sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*=size-])]:size-6', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import type { AlertDialogTitleProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { AlertDialogTitle } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<AlertDialogTitleProps & { class?: HTMLAttributes['class'] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialogTitle
|
||||
data-slot="alert-dialog-title"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn('text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2 cn-font-heading', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</AlertDialogTitle>
|
||||
</template>
|
||||
@@ -0,0 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import type { AlertDialogTriggerProps } from 'reka-ui'
|
||||
import { AlertDialogTrigger } from 'reka-ui'
|
||||
|
||||
const props = defineProps<AlertDialogTriggerProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AlertDialogTrigger data-slot="alert-dialog-trigger" v-bind="props">
|
||||
<slot />
|
||||
</AlertDialogTrigger>
|
||||
</template>
|
||||
@@ -0,0 +1,10 @@
|
||||
export { default as AlertDialog } from './AlertDialog.vue'
|
||||
export { default as AlertDialogAction } from './AlertDialogAction.vue'
|
||||
export { default as AlertDialogCancel } from './AlertDialogCancel.vue'
|
||||
export { default as AlertDialogContent } from './AlertDialogContent.vue'
|
||||
export { default as AlertDialogDescription } from './AlertDialogDescription.vue'
|
||||
export { default as AlertDialogFooter } from './AlertDialogFooter.vue'
|
||||
export { default as AlertDialogHeader } from './AlertDialogHeader.vue'
|
||||
export { default as AlertDialogMedia } from './AlertDialogMedia.vue'
|
||||
export { default as AlertDialogTitle } from './AlertDialogTitle.vue'
|
||||
export { default as AlertDialogTrigger } from './AlertDialogTrigger.vue'
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import type { AlertVariants } from '.'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { alertVariants } from '.'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
variant?: AlertVariants['variant']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="alert"
|
||||
:class="cn(alertVariants({ variant }), props.class)"
|
||||
role="alert"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="alert-action"
|
||||
:class="cn('absolute top-2 right-2', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="alert-description"
|
||||
:class="cn('text-muted-foreground text-sm text-balance md:text-pretty [&_p:not(:last-child)]:mb-4 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="alert-title"
|
||||
:class="cn('font-medium group-has-[>svg]/alert:col-start-2 cn-font-heading [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { VariantProps } from 'class-variance-authority'
|
||||
import { cva } from 'class-variance-authority'
|
||||
|
||||
export { default as Alert } from './Alert.vue'
|
||||
export { default as AlertAction } from './AlertAction.vue'
|
||||
export { default as AlertDescription } from './AlertDescription.vue'
|
||||
export { default as AlertTitle } from './AlertTitle.vue'
|
||||
|
||||
export const alertVariants = cva('grid gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*=size-])]:size-4 group/alert relative w-full', {
|
||||
variants: {
|
||||
variant: {
|
||||
default: 'bg-card text-card-foreground',
|
||||
destructive: 'text-destructive bg-card *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
},
|
||||
})
|
||||
|
||||
export type AlertVariants = VariantProps<typeof alertVariants>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import type { CheckboxRootEmits, CheckboxRootProps } from 'reka-ui'
|
||||
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { CheckIcon } from '@lucide/vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { CheckboxIndicator, CheckboxRoot, useForwardPropsEmits } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<CheckboxRootProps & { class?: HTMLAttributes['class'] }>()
|
||||
const emits = defineEmits<CheckboxRootEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CheckboxRoot
|
||||
v-slot="slotProps"
|
||||
data-slot="checkbox"
|
||||
v-bind="forwarded"
|
||||
:class="cn('border-input dark:bg-input/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 flex size-4 items-center justify-center rounded-[4px] border transition-colors group-has-disabled/field:opacity-50 focus-visible:ring-3 aria-invalid:ring-3 peer relative shrink-0 outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-50', props.class)"
|
||||
>
|
||||
<CheckboxIndicator
|
||||
data-slot="checkbox-indicator"
|
||||
class="[&>svg]:size-3.5 grid place-content-center text-current transition-none"
|
||||
>
|
||||
<slot v-bind="slotProps">
|
||||
<CheckIcon />
|
||||
</slot>
|
||||
</CheckboxIndicator>
|
||||
</CheckboxRoot>
|
||||
</template>
|
||||
@@ -0,0 +1 @@
|
||||
export { default as Checkbox } from './Checkbox.vue'
|
||||
@@ -0,0 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import type { CollapsibleRootEmits, CollapsibleRootProps } from 'reka-ui'
|
||||
import { CollapsibleRoot, useForwardPropsEmits } from 'reka-ui'
|
||||
|
||||
const props = defineProps<CollapsibleRootProps>()
|
||||
const emits = defineEmits<CollapsibleRootEmits>()
|
||||
|
||||
const forwarded = useForwardPropsEmits(props, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CollapsibleRoot
|
||||
v-slot="slotProps"
|
||||
data-slot="collapsible"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<slot v-bind="slotProps" />
|
||||
</CollapsibleRoot>
|
||||
</template>
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import type { CollapsibleContentProps } from 'reka-ui'
|
||||
import { CollapsibleContent } from 'reka-ui'
|
||||
|
||||
const props = defineProps<CollapsibleContentProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CollapsibleContent
|
||||
data-slot="collapsible-content"
|
||||
v-bind="props"
|
||||
>
|
||||
<slot />
|
||||
</CollapsibleContent>
|
||||
</template>
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import type { CollapsibleTriggerProps } from 'reka-ui'
|
||||
import { CollapsibleTrigger } from 'reka-ui'
|
||||
|
||||
const props = defineProps<CollapsibleTriggerProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CollapsibleTrigger
|
||||
data-slot="collapsible-trigger"
|
||||
v-bind="props"
|
||||
>
|
||||
<slot />
|
||||
</CollapsibleTrigger>
|
||||
</template>
|
||||
@@ -0,0 +1,3 @@
|
||||
export { default as Collapsible } from './Collapsible.vue'
|
||||
export { default as CollapsibleContent } from './CollapsibleContent.vue'
|
||||
export { default as CollapsibleTrigger } from './CollapsibleTrigger.vue'
|
||||
@@ -0,0 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import type { DialogRootEmits, DialogRootProps } from 'reka-ui'
|
||||
import { DialogRoot, useForwardPropsEmits } from 'reka-ui'
|
||||
|
||||
const props = defineProps<DialogRootProps>()
|
||||
const emits = defineEmits<DialogRootEmits>()
|
||||
|
||||
const forwarded = useForwardPropsEmits(props, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogRoot
|
||||
v-slot="slotProps"
|
||||
data-slot="dialog"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<slot v-bind="slotProps" />
|
||||
</DialogRoot>
|
||||
</template>
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import type { DialogCloseProps } from 'reka-ui'
|
||||
import { DialogClose } from 'reka-ui'
|
||||
|
||||
const props = defineProps<DialogCloseProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogClose
|
||||
data-slot="dialog-close"
|
||||
v-bind="props"
|
||||
>
|
||||
<slot />
|
||||
</DialogClose>
|
||||
</template>
|
||||
@@ -0,0 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
import type { DialogContentEmits, DialogContentProps } from 'reka-ui'
|
||||
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { XIcon } from '@lucide/vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import {
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogPortal,
|
||||
useForwardPropsEmits,
|
||||
} from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import DialogOverlay from './DialogOverlay.vue'
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
})
|
||||
|
||||
const props = withDefaults(defineProps<DialogContentProps & { class?: HTMLAttributes['class'], showCloseButton?: boolean }>(), {
|
||||
showCloseButton: true,
|
||||
})
|
||||
const emits = defineEmits<DialogContentEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogPortal>
|
||||
<DialogOverlay />
|
||||
<DialogContent
|
||||
data-slot="dialog-content"
|
||||
v-bind="{ ...$attrs, ...forwarded }"
|
||||
:class="cn('bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 ring-foreground/10 grid max-w-[calc(100%-2rem)] gap-4 rounded-xl p-4 text-sm ring-1 duration-100 sm:max-w-sm fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 outline-none', props.class)"
|
||||
>
|
||||
<slot />
|
||||
|
||||
<DialogClose
|
||||
v-if="showCloseButton"
|
||||
data-slot="dialog-close"
|
||||
as-child
|
||||
>
|
||||
<Button variant="ghost" class="absolute top-2 right-2" size="icon-sm">
|
||||
<XIcon />
|
||||
<span class="sr-only">Close</span>
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</DialogContent>
|
||||
</DialogPortal>
|
||||
</template>
|
||||
@@ -0,0 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import type { DialogDescriptionProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { DialogDescription, useForwardProps } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<DialogDescriptionProps & { class?: HTMLAttributes['class'] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
|
||||
const forwardedProps = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogDescription
|
||||
data-slot="dialog-description"
|
||||
v-bind="forwardedProps"
|
||||
:class="cn('text-muted-foreground *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</DialogDescription>
|
||||
</template>
|
||||
@@ -0,0 +1,27 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { DialogClose } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { Button } from '@/components/ui/button'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
showCloseButton?: boolean
|
||||
}>(), {
|
||||
showCloseButton: false,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="dialog-footer"
|
||||
:class="cn('bg-muted/50 -mx-4 -mb-4 rounded-b-xl border-t p-4 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', props.class)"
|
||||
>
|
||||
<slot />
|
||||
<DialogClose v-if="showCloseButton" as-child>
|
||||
<Button variant="outline">
|
||||
Close
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="dialog-header"
|
||||
:class="cn('gap-2 flex flex-col', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import type { DialogOverlayProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { DialogOverlay } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<DialogOverlayProps & { class?: HTMLAttributes['class'] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogOverlay
|
||||
data-slot="dialog-overlay"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn('data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</DialogOverlay>
|
||||
</template>
|
||||
@@ -0,0 +1,60 @@
|
||||
<script setup lang="ts">
|
||||
import type { DialogContentEmits, DialogContentProps } from 'reka-ui'
|
||||
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { XIcon } from '@lucide/vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import {
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogOverlay,
|
||||
DialogPortal,
|
||||
useForwardPropsEmits,
|
||||
} from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
})
|
||||
|
||||
const props = defineProps<DialogContentProps & { class?: HTMLAttributes['class'] }>()
|
||||
const emits = defineEmits<DialogContentEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogPortal>
|
||||
<DialogOverlay
|
||||
class="fixed inset-0 z-50 grid place-items-center overflow-y-auto bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"
|
||||
>
|
||||
<DialogContent
|
||||
:class="
|
||||
cn(
|
||||
'relative z-50 grid w-full max-w-lg my-8 gap-4 border border-border bg-background p-6 shadow-lg duration-200 sm:rounded-lg md:w-full',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
v-bind="{ ...$attrs, ...forwarded }"
|
||||
@pointer-down-outside="(event) => {
|
||||
const originalEvent = event.detail.originalEvent;
|
||||
const target = originalEvent.target as HTMLElement;
|
||||
if (originalEvent.offsetX > target.clientWidth || originalEvent.offsetY > target.clientHeight) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}"
|
||||
>
|
||||
<slot />
|
||||
|
||||
<DialogClose
|
||||
class="absolute top-4 right-4 p-0.5 transition-colors rounded-md hover:bg-secondary"
|
||||
>
|
||||
<XIcon class="w-4 h-4" />
|
||||
<span class="sr-only">Close</span>
|
||||
</DialogClose>
|
||||
</DialogContent>
|
||||
</DialogOverlay>
|
||||
</DialogPortal>
|
||||
</template>
|
||||
@@ -0,0 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import type { DialogTitleProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { DialogTitle, useForwardProps } from 'reka-ui'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<DialogTitleProps & { class?: HTMLAttributes['class'] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
|
||||
const forwardedProps = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogTitle
|
||||
data-slot="dialog-title"
|
||||
v-bind="forwardedProps"
|
||||
:class="cn('text-base leading-none font-medium cn-font-heading', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</DialogTitle>
|
||||
</template>
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import type { DialogTriggerProps } from 'reka-ui'
|
||||
import { DialogTrigger } from 'reka-ui'
|
||||
|
||||
const props = defineProps<DialogTriggerProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogTrigger
|
||||
data-slot="dialog-trigger"
|
||||
v-bind="props"
|
||||
>
|
||||
<slot />
|
||||
</DialogTrigger>
|
||||
</template>
|
||||
@@ -0,0 +1,10 @@
|
||||
export { default as Dialog } from './Dialog.vue'
|
||||
export { default as DialogClose } from './DialogClose.vue'
|
||||
export { default as DialogContent } from './DialogContent.vue'
|
||||
export { default as DialogDescription } from './DialogDescription.vue'
|
||||
export { default as DialogFooter } from './DialogFooter.vue'
|
||||
export { default as DialogHeader } from './DialogHeader.vue'
|
||||
export { default as DialogOverlay } from './DialogOverlay.vue'
|
||||
export { default as DialogScrollContent } from './DialogScrollContent.vue'
|
||||
export { default as DialogTitle } from './DialogTitle.vue'
|
||||
export { default as DialogTrigger } from './DialogTrigger.vue'
|
||||
@@ -0,0 +1,27 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import type { FieldVariants } from '.'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { fieldVariants } from '.'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
orientation?: FieldVariants['orientation']
|
||||
}>(), {
|
||||
orientation: 'vertical',
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
role="group"
|
||||
data-slot="field"
|
||||
:data-orientation="orientation"
|
||||
:class="cn(
|
||||
fieldVariants({ orientation }),
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="field-content"
|
||||
:class="cn(
|
||||
'gap-0.5 group/field-content flex flex-1 flex-col leading-snug',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<p
|
||||
data-slot="field-description"
|
||||
:class="cn(
|
||||
'text-muted-foreground text-left text-sm [[data-variant=legend]+&]:-mt-1.5 leading-normal font-normal group-has-data-horizontal/field:text-balance',
|
||||
'last:mt-0 nth-last-2:-mt-1',
|
||||
'[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</p>
|
||||
</template>
|
||||
@@ -0,0 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { computed } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
errors?: Array<string | { message: string | undefined } | undefined>
|
||||
}>()
|
||||
|
||||
const content = computed(() => {
|
||||
if (!props.errors || props.errors.length === 0)
|
||||
return null
|
||||
|
||||
const uniqueErrors = [
|
||||
...new Map(
|
||||
props.errors
|
||||
.filter(Boolean)
|
||||
.map((error) => {
|
||||
const message = typeof error === 'string' ? error : error?.message
|
||||
return [message, error]
|
||||
}),
|
||||
).values(),
|
||||
]
|
||||
|
||||
if (uniqueErrors.length === 1 && uniqueErrors[0]) {
|
||||
return typeof uniqueErrors[0] === 'string' ? uniqueErrors[0] : uniqueErrors[0].message
|
||||
}
|
||||
|
||||
return uniqueErrors.map(error => typeof error === 'string' ? error : error?.message)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="$slots.default || content"
|
||||
role="alert"
|
||||
data-slot="field-error"
|
||||
:class="cn('text-destructive text-sm font-normal', props.class)"
|
||||
>
|
||||
<slot v-if="$slots.default" />
|
||||
|
||||
<template v-else-if="typeof content === 'string'">
|
||||
{{ content }}
|
||||
</template>
|
||||
|
||||
<ul v-else-if="Array.isArray(content)" class="ml-4 flex list-disc flex-col gap-1">
|
||||
<li v-for="(error, index) in content" :key="index">
|
||||
{{ error }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="field-group"
|
||||
:class="cn(
|
||||
'gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4 group/field-group @container/field-group flex w-full flex-col',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { Label } from '@/components/ui/label'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Label
|
||||
data-slot="field-label"
|
||||
:class="cn(
|
||||
'has-data-checked:bg-primary/5 has-data-checked:border-primary/30 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 gap-2 group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 group/field-label peer/field-label flex w-fit leading-snug',
|
||||
'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</Label>
|
||||
</template>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
variant?: 'legend' | 'label'
|
||||
}>(), {
|
||||
variant: 'legend',
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<legend
|
||||
data-slot="field-legend"
|
||||
:data-variant="variant"
|
||||
:class="cn('mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</legend>
|
||||
</template>
|
||||
@@ -0,0 +1,29 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="field-separator"
|
||||
:data-content="!!$slots.default"
|
||||
:class="cn(
|
||||
'-my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2 relative',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<Separator class="absolute inset-0 top-1/2" />
|
||||
<span
|
||||
v-if="$slots.default"
|
||||
class="text-muted-foreground px-2 relative mx-auto block w-fit bg-background"
|
||||
data-slot="field-separator-content"
|
||||
>
|
||||
<slot />
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<fieldset
|
||||
data-slot="field-set"
|
||||
:class="cn('gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3 flex flex-col', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</fieldset>
|
||||
</template>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="field-label"
|
||||
:class="cn(
|
||||
'gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50 flex w-fit items-center leading-snug',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { VariantProps } from 'class-variance-authority'
|
||||
import { cva } from 'class-variance-authority'
|
||||
|
||||
export const fieldVariants = cva('data-[invalid=true]:text-destructive gap-2 group/field flex w-full', {
|
||||
variants: {
|
||||
orientation: {
|
||||
vertical:
|
||||
'flex-col *:w-full [&>.sr-only]:w-auto',
|
||||
horizontal:
|
||||
'flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
|
||||
responsive:
|
||||
'flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
orientation: 'vertical',
|
||||
},
|
||||
})
|
||||
|
||||
export type FieldVariants = VariantProps<typeof fieldVariants>
|
||||
|
||||
export { default as Field } from './Field.vue'
|
||||
export { default as FieldContent } from './FieldContent.vue'
|
||||
export { default as FieldDescription } from './FieldDescription.vue'
|
||||
export { default as FieldError } from './FieldError.vue'
|
||||
export { default as FieldGroup } from './FieldGroup.vue'
|
||||
export { default as FieldLabel } from './FieldLabel.vue'
|
||||
export { default as FieldLegend } from './FieldLegend.vue'
|
||||
export { default as FieldSeparator } from './FieldSeparator.vue'
|
||||
export { default as FieldSet } from './FieldSet.vue'
|
||||
export { default as FieldTitle } from './FieldTitle.vue'
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
data-slot="input-group"
|
||||
role="group"
|
||||
:class="cn(
|
||||
'border-input dark:bg-input/30 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-disabled:bg-input/50 dark:has-disabled:bg-input/80 h-8 rounded-lg border transition-colors in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-3 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5 group/input-group relative flex w-full min-w-0 items-center outline-none has-[>textarea]:h-auto',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import type { InputGroupVariants } from '.'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { inputGroupAddonVariants } from '.'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
align?: InputGroupVariants['align']
|
||||
class?: HTMLAttributes['class']
|
||||
}>(), {
|
||||
align: 'inline-start',
|
||||
})
|
||||
|
||||
function handleInputGroupAddonClick(e: MouseEvent) {
|
||||
const currentTarget = e.currentTarget as HTMLElement | null
|
||||
const target = e.target as HTMLElement | null
|
||||
if (target && target.closest('button')) {
|
||||
return
|
||||
}
|
||||
if (currentTarget && currentTarget?.parentElement) {
|
||||
currentTarget.parentElement?.querySelector('input')?.focus()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
role="group"
|
||||
data-slot="input-group-addon"
|
||||
:data-align="props.align"
|
||||
:class="cn(inputGroupAddonVariants({ align: props.align }), props.class)"
|
||||
@click="handleInputGroupAddonClick"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import type { InputGroupButtonProps } from '.'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { inputGroupButtonVariants } from '.'
|
||||
|
||||
const props = withDefaults(defineProps<InputGroupButtonProps>(), {
|
||||
size: 'xs',
|
||||
variant: 'ghost',
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Button
|
||||
type="button"
|
||||
:data-size="props.size"
|
||||
:variant="props.variant"
|
||||
:class="cn(inputGroupButtonVariants({ size: props.size }), props.class)"
|
||||
>
|
||||
<slot />
|
||||
</Button>
|
||||
</template>
|
||||
@@ -0,0 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { Input } from '@/components/ui/input'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Input
|
||||
data-slot="input-group-control"
|
||||
:class="cn(
|
||||
'rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent flex-1',
|
||||
props.class,
|
||||
)"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span
|
||||
:class="cn(
|
||||
'text-muted-foreground gap-2 text-sm [&_svg:not([class*=size-])]:size-4 flex items-center [&_svg]:pointer-events-none',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</span>
|
||||
</template>
|
||||
Loaded 100 of 276 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user