Files
archie/ui/src/chat/ChatPanel.vue
T
sam 8e91ccb76d 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.
2026-09-20 20:04:55 +10:00

89 lines
3.9 KiB
Vue

<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>