The chat dock is now a free-floating window on desktop-width screens: the header drags it to any position, all eight edges and corners resize it by pointer and keyboard (role=separator with aria-orientation and valuenow), and Left / Float / Right controls in the header switch modes explicitly. Dragging near a side edge shows the pinned split preview and commits on release; minimising leaves the bar in place and draggable; Ctrl+/ toggles the window. The layout persists under archie.chat.dock.v2, migrating and removing the old archie.chat.dock key. Phone width keeps the full-width bottom bar.
559 lines
23 KiB
Vue
559 lines
23 KiB
Vue
<script setup lang="ts">
|
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
|
import { ChevronDown, ChevronUp, GripVertical, PanelLeft, PanelRight, Square } from "@lucide/vue";
|
|
import { useEventListener, useMediaQuery, useStorage, useWindowSize } from "@vueuse/core";
|
|
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from "vue";
|
|
|
|
import { Badge } from "@/components/ui/badge";
|
|
import { Button } from "@/components/ui/button";
|
|
import { useLiveResource } from "@/stores/session";
|
|
import { cn } from "@/lib/utils";
|
|
import ChatBar from "./ChatBar.vue";
|
|
import ChatComposer from "./ChatComposer.vue";
|
|
import ChatTranscript from "./ChatTranscript.vue";
|
|
import {
|
|
DOCK_STORAGE_KEY,
|
|
DRAG_START,
|
|
MAX_W,
|
|
MIN_H,
|
|
MIN_W,
|
|
RESIZE_DIRS,
|
|
barPlacement,
|
|
fitRect,
|
|
handleOrientation,
|
|
handleValue,
|
|
isSwipeDown,
|
|
keyboardCover,
|
|
keyStep,
|
|
migrateDockStorage,
|
|
normalizeLayout,
|
|
phoneBarBottom,
|
|
pinnedWidth,
|
|
resizeRect,
|
|
snapEdge,
|
|
type DockLayout,
|
|
type DockMode,
|
|
type Rect,
|
|
type ResizeDir,
|
|
} from "./ChatDockLayout";
|
|
import { escapeOwnedByLayer, isSending, reloadTranscript, useChat } from "./state";
|
|
import { setDockOpen, unseenCount } from "./unseen";
|
|
|
|
/**
|
|
* Chat is a window docked to every page, not a route: the operator asks Archie
|
|
* about the page they are already on, so navigating must not reset it, and it
|
|
* must not replace the work that prompted the question. The agent is told
|
|
* which page that is.
|
|
*
|
|
* It is the composer alone until the operator focuses it or a turn starts, then
|
|
* the conversation opens above it. Hiding the conversation leaves the bar where
|
|
* it was. It is deliberately not a modal: no scrim, no scroll lock, no focus
|
|
* trap.
|
|
*
|
|
* On a desktop-width screen the expanded conversation is a free-floating
|
|
* window: the header drags it anywhere, all eight edges and corners resize it
|
|
* (pointer and keyboard), and dragging near a side edge shows the pinned
|
|
* split, committing on release. Left / Float / Right in the header switch
|
|
* modes explicitly; pinned, the page reflows beside the dock instead of
|
|
* sitting under it. Ctrl+/ toggles the window, Escape collapses it, and the
|
|
* collapsed bar stays where it was and drags too. The layout (mode, x, y,
|
|
* width, height) is remembered per browser under "archie.chat.dock.v2", which
|
|
* replaces the old edge-pin preference.
|
|
*
|
|
* On a phone-width screen the dock stays the full-width bottom bar: it rides
|
|
* above the on-screen keyboard, which iOS does not resize the page for, and
|
|
* swiping down on the conversation header hides it. No float or resize handles
|
|
* exist below the desktop breakpoint.
|
|
*
|
|
* The collapsed bar's show button carries the count of replies that landed
|
|
* while it was closed, and a task this conversation started reports its
|
|
* outcome into the transcript while the dock stays mounted.
|
|
*
|
|
* It stays mounted, so the session and any turn in flight survive a navigation.
|
|
* It is mounted outside the app shell: `.shell`'s backdrop-filter makes it a
|
|
* containing block for `position: fixed`, so a bar nested inside would anchor to
|
|
* the shell and ride off the bottom of a long page.
|
|
*/
|
|
useChat();
|
|
|
|
// A task this conversation started reports its outcome into it. The dock stays
|
|
// mounted while collapsed, so a reply that lands then is still read and counted.
|
|
useLiveResource("chat", () => void reloadTranscript());
|
|
|
|
const expanded = ref(false);
|
|
watch(expanded, setDockOpen, { immediate: true });
|
|
|
|
// The old edge-pin preference moves into the new key before useStorage reads it.
|
|
migrateDockStorage(localStorage, window.innerWidth, window.innerHeight);
|
|
const stored = useStorage<DockLayout>(
|
|
DOCK_STORAGE_KEY,
|
|
normalizeLayout(null, window.innerWidth, window.innerHeight),
|
|
localStorage,
|
|
);
|
|
|
|
const desktop = useMediaQuery("(min-width: 768px)");
|
|
const { width: vw, height: vh } = useWindowSize();
|
|
const layout = computed<DockLayout>({
|
|
get: () => normalizeLayout(stored.value, vw.value, vh.value),
|
|
set: (value) => {
|
|
stored.value = value;
|
|
},
|
|
});
|
|
const mode = computed<DockMode>(() => (desktop.value ? layout.value.mode : "float"));
|
|
const pinned = computed(() => desktop.value && expanded.value && mode.value !== "float");
|
|
const pinW = computed(() => pinnedWidth(layout.value.w, vw.value));
|
|
const pinMax = computed(() => Math.max(MIN_W, Math.min(MAX_W, vw.value - 480)));
|
|
|
|
// The rendered rectangle of the window: full-height at an edge when pinned, the
|
|
// clamped stored rectangle when floating.
|
|
const winRect = computed<Rect>(() => {
|
|
if (!desktop.value) return { x: 0, y: 0, w: vw.value, h: vh.value };
|
|
if (pinned.value) {
|
|
return { x: mode.value === "left" ? 0 : vw.value - pinW.value, y: 0, w: pinW.value, h: vh.value };
|
|
}
|
|
return fitRect(layout.value, vw.value, vh.value);
|
|
});
|
|
|
|
// The part of the layout viewport the on-screen keyboard covers, and the height
|
|
// left above it. Fixed elements stay anchored to the layout viewport, so without
|
|
// this the bar sits under the keyboard.
|
|
const keyboard = ref(0);
|
|
const visibleHeight = ref(window.innerHeight);
|
|
function followViewport(): void {
|
|
const vv = window.visualViewport;
|
|
keyboard.value = keyboardCover(window.innerHeight, vv);
|
|
visibleHeight.value = vv ? vv.height : window.innerHeight;
|
|
}
|
|
useEventListener(() => window.visualViewport, ["resize", "scroll"], followViewport);
|
|
const phoneBottom = computed(() => phoneBarBottom(keyboard.value));
|
|
|
|
const wrapStyle = computed<Record<string, string> | undefined>((): Record<string, string> | undefined => {
|
|
if (!desktop.value) return { bottom: phoneBottom.value };
|
|
if (pinned.value) {
|
|
return { left: `${winRect.value.x}px`, top: "0px", width: `${pinW.value}px`, height: `${vh.value}px` };
|
|
}
|
|
const rect = winRect.value;
|
|
if (expanded.value) {
|
|
return { left: `${rect.x}px`, top: `${rect.y}px`, width: `${rect.w}px`, height: `${rect.h}px` };
|
|
}
|
|
const bar = barPlacement(rect, mode.value, vw.value, vh.value);
|
|
return { left: `${bar.x}px`, bottom: `${bar.bottom}px`, width: `${bar.w}px` };
|
|
});
|
|
|
|
// Nothing outside the dock closes it: every navigation control is outside it,
|
|
// so a click-outside dismissal turned navigation into a collapse and read as a
|
|
// lost conversation. Hide, swipe down, Escape and Ctrl+/ are the only ways to
|
|
// collapse.
|
|
|
|
watch(isSending, (sending) => {
|
|
if (sending) expanded.value = true;
|
|
});
|
|
|
|
function onKeydown(event: KeyboardEvent): void {
|
|
// A focused control (the composer dismissing its palette, or the topbar
|
|
// search) already handled Escape via preventDefault; collapsing too would
|
|
// make that menu impossible to dismiss on its own. A popover portalled out
|
|
// of the bar owns Escape by being open, which the flag reports.
|
|
if (event.defaultPrevented || event.key !== "Escape" || escapeOwnedByLayer()) return;
|
|
expanded.value = false;
|
|
}
|
|
watch(expanded, (open) => {
|
|
if (open) document.addEventListener("keydown", onKeydown);
|
|
else document.removeEventListener("keydown", onKeydown);
|
|
});
|
|
onUnmounted(() => document.removeEventListener("keydown", onKeydown));
|
|
|
|
function onGlobalKeydown(event: KeyboardEvent): void {
|
|
if (event.defaultPrevented) return;
|
|
if ((event.ctrlKey || event.metaKey) && event.key === "/") {
|
|
event.preventDefault();
|
|
expanded.value = !expanded.value;
|
|
}
|
|
}
|
|
onMounted(() => document.addEventListener("keydown", onGlobalKeydown));
|
|
onUnmounted(() => document.removeEventListener("keydown", onGlobalKeydown));
|
|
|
|
// The page reserves the collapsed dock's height, read from the rendered bar so
|
|
// the last line of any page can scroll clear of it. A bar floating clear of the
|
|
// bottom of the screen reserves nothing.
|
|
const dock = ref<HTMLElement | null>(null);
|
|
let observer: ResizeObserver | null = null;
|
|
function reserve(): void {
|
|
if (expanded.value || !dock.value) return;
|
|
const rect = dock.value.getBoundingClientRect();
|
|
// Only a bar sitting in the bottom quarter of the screen needs the page to
|
|
// reserve room under it; one floating higher up does not.
|
|
const clear = rect.bottom >= window.innerHeight * 0.75 ? Math.ceil(window.innerHeight - rect.top) : 0;
|
|
document.documentElement.style.setProperty("--chat-dock-clear", `${clear}px`);
|
|
}
|
|
onMounted(() => {
|
|
observer = new ResizeObserver(reserve);
|
|
if (dock.value) observer.observe(dock.value);
|
|
window.addEventListener("resize", reserve);
|
|
});
|
|
onUnmounted(() => {
|
|
observer?.disconnect();
|
|
window.removeEventListener("resize", reserve);
|
|
document.documentElement.style.removeProperty("--chat-dock-clear");
|
|
});
|
|
watch([expanded, desktop, () => layout.value.x, () => layout.value.y, () => layout.value.w, mode], () =>
|
|
nextTick(reserve),
|
|
);
|
|
|
|
// The page makes room for a pinned dock through these two variables.
|
|
watch([pinned, mode, pinW], () => {
|
|
const root = document.documentElement.style;
|
|
root.setProperty("--chat-pin-l", pinned.value && mode.value === "left" ? `${pinW.value}px` : "0px");
|
|
root.setProperty("--chat-pin-r", pinned.value && mode.value === "right" ? `${pinW.value}px` : "0px");
|
|
}, { immediate: true });
|
|
onUnmounted(() => {
|
|
document.documentElement.style.removeProperty("--chat-pin-l");
|
|
document.documentElement.style.removeProperty("--chat-pin-r");
|
|
});
|
|
|
|
const MODES: { mode: DockMode; label: string; icon: typeof PanelLeft; aria: string; title: string }[] = [
|
|
{ mode: "left", label: "Left", icon: PanelLeft, aria: "Pin chat to left edge", title: "Dock left, reflowing the page beside it" },
|
|
{ mode: "float", label: "Float", icon: Square, aria: "Float window", title: "Float the window, dragging and resizing freely" },
|
|
{ mode: "right", label: "Right", icon: PanelRight, aria: "Pin chat to right edge", title: "Dock right, reflowing the page beside it" },
|
|
];
|
|
function setMode(next: DockMode): void {
|
|
if (!desktop.value) return;
|
|
layout.value = { ...layout.value, mode: next };
|
|
expanded.value = true;
|
|
}
|
|
|
|
// Pointer travel before a press on a drag surface becomes a drag, so a click or
|
|
// a double-click on it never moves the dock.
|
|
const dragging = ref(false);
|
|
const snapTarget = ref<"left" | "right" | null>(null);
|
|
|
|
function startDrag(event: PointerEvent): void {
|
|
if (!desktop.value || event.button !== 0 || !event.isPrimary) return;
|
|
// The move handle is a button that drags, so it is exempt from the ignore list.
|
|
const target = event.target as HTMLElement;
|
|
if (target.closest("button, a, input, select, textarea, [role=combobox], [role=separator]") && !target.closest("[data-move-handle]")) return;
|
|
const grip = event.currentTarget as HTMLElement;
|
|
const origin = { ...winRect.value };
|
|
const x0 = event.clientX;
|
|
const y0 = event.clientY;
|
|
grip.setPointerCapture(event.pointerId);
|
|
let moved = false;
|
|
let snap: "left" | "right" | null = null;
|
|
const move = (e: PointerEvent): void => {
|
|
const dx = e.clientX - x0;
|
|
const dy = e.clientY - y0;
|
|
if (!moved && Math.hypot(dx, dy) < DRAG_START) return;
|
|
moved = true;
|
|
dragging.value = true;
|
|
const next = fitRect({ x: origin.x + dx, y: origin.y + dy, w: origin.w, h: origin.h }, vw.value, vh.value);
|
|
layout.value = { ...layout.value, mode: "float", x: next.x, y: next.y, w: next.w, h: next.h };
|
|
snap = expanded.value ? snapEdge(e.clientX, vw.value) : null;
|
|
snapTarget.value = snap;
|
|
};
|
|
const end = (e: PointerEvent): void => {
|
|
grip.removeEventListener("pointermove", move);
|
|
grip.removeEventListener("pointerup", end);
|
|
grip.removeEventListener("pointercancel", end);
|
|
if (moved && e.type === "pointerup" && snap) layout.value = { ...layout.value, mode: snap };
|
|
moved = false;
|
|
dragging.value = false;
|
|
snapTarget.value = null;
|
|
};
|
|
grip.addEventListener("pointermove", move);
|
|
grip.addEventListener("pointerup", end);
|
|
grip.addEventListener("pointercancel", end);
|
|
}
|
|
// On a phone the header is a swipe surface, not a drag surface: a downward
|
|
// flick hides the conversation.
|
|
function startSwipe(event: PointerEvent): void {
|
|
const grip = event.currentTarget as HTMLElement;
|
|
const { clientX: x0, clientY: y0 } = event;
|
|
const end = (e: PointerEvent): void => {
|
|
grip.removeEventListener("pointerup", end);
|
|
grip.removeEventListener("pointercancel", end);
|
|
if (e.type === "pointerup" && isSwipeDown(e.clientX - x0, e.clientY - y0)) {
|
|
// The keyboard is for the composer, which is no longer in front of it.
|
|
(document.activeElement as HTMLElement | null)?.blur();
|
|
expanded.value = false;
|
|
}
|
|
};
|
|
grip.addEventListener("pointerup", end);
|
|
grip.addEventListener("pointercancel", end);
|
|
}
|
|
function onHeaderPointerDown(event: PointerEvent): void {
|
|
if (!desktop.value) return startSwipe(event);
|
|
startDrag(event);
|
|
}
|
|
function togglePin(event: MouseEvent): void {
|
|
const target = event.target as HTMLElement;
|
|
if (!desktop.value || (target.closest("button, a, input, select, textarea, [role=combobox], [role=separator]") && !target.closest("[data-move-handle]"))) return;
|
|
layout.value = { ...layout.value, mode: mode.value === "float" ? "right" : "float" };
|
|
}
|
|
|
|
// The collapsed bar drags from its own padding and its move handle; the
|
|
// composer inside it keeps its text selection.
|
|
function onBarPointerDown(event: PointerEvent): void {
|
|
if (expanded.value) return;
|
|
startDrag(event);
|
|
}
|
|
|
|
function moveByKey(event: KeyboardEvent): void {
|
|
if (!desktop.value || !event.key.startsWith("Arrow")) return;
|
|
event.preventDefault();
|
|
const step = keyStep(event.shiftKey);
|
|
const rect = winRect.value;
|
|
const next = fitRect(
|
|
{
|
|
...rect,
|
|
x: rect.x + (event.key === "ArrowRight" ? step : event.key === "ArrowLeft" ? -step : 0),
|
|
y: rect.y + (event.key === "ArrowDown" ? step : event.key === "ArrowUp" ? -step : 0),
|
|
},
|
|
vw.value,
|
|
vh.value,
|
|
);
|
|
layout.value = { ...layout.value, mode: "float", x: next.x, y: next.y, w: next.w, h: next.h };
|
|
}
|
|
|
|
const HANDLE_CLASS: Record<ResizeDir, string> = {
|
|
n: "top-[-3px] left-3.5 right-3.5 h-2 cursor-ns-resize",
|
|
s: "bottom-[-3px] left-3.5 right-3.5 h-2 cursor-ns-resize",
|
|
e: "right-[-3px] top-3.5 bottom-3.5 w-2 cursor-ew-resize",
|
|
w: "left-[-3px] top-3.5 bottom-3.5 w-2 cursor-ew-resize",
|
|
ne: "top-0 right-0 size-3.5 cursor-nesw-resize",
|
|
nw: "top-0 left-0 size-3.5 cursor-nwse-resize",
|
|
se: "bottom-0 right-0 size-4 cursor-nwse-resize",
|
|
sw: "bottom-0 left-0 size-4 cursor-nesw-resize",
|
|
};
|
|
const DIR_LABEL: Record<ResizeDir, string> = {
|
|
n: "top",
|
|
s: "bottom",
|
|
e: "right",
|
|
w: "left",
|
|
ne: "top right",
|
|
nw: "top left",
|
|
se: "bottom right",
|
|
sw: "bottom left",
|
|
};
|
|
// The minimised bar keeps its height, so only its width edges resize it.
|
|
const visibleDirs = computed<ResizeDir[]>(() => (expanded.value ? [...RESIZE_DIRS] : ["e", "w"]));
|
|
|
|
function applyResize(dir: ResizeDir, dx: number, dy: number): void {
|
|
const rect = resizeRect(winRect.value, dir, dx, dy, vw.value, vh.value);
|
|
layout.value = { ...layout.value, mode: "float", x: rect.x, y: rect.y, w: rect.w, h: rect.h };
|
|
}
|
|
|
|
function startResize(dir: ResizeDir, event: PointerEvent): void {
|
|
if (!desktop.value || event.button !== 0 || !event.isPrimary) return;
|
|
const handle = event.currentTarget as HTMLElement;
|
|
handle.setPointerCapture(event.pointerId);
|
|
const move = (e: PointerEvent): void => applyResize(dir, e.clientX - event.clientX, e.clientY - event.clientY);
|
|
const end = (): void => {
|
|
handle.removeEventListener("pointermove", move);
|
|
handle.removeEventListener("pointerup", end);
|
|
handle.removeEventListener("pointercancel", end);
|
|
};
|
|
handle.addEventListener("pointermove", move);
|
|
handle.addEventListener("pointerup", end);
|
|
handle.addEventListener("pointercancel", end);
|
|
}
|
|
|
|
function onHandleKey(dir: ResizeDir, event: KeyboardEvent): void {
|
|
if (!desktop.value || !event.key.startsWith("Arrow")) return;
|
|
event.preventDefault();
|
|
const step = keyStep(event.shiftKey);
|
|
const dx = event.key === "ArrowRight" ? step : event.key === "ArrowLeft" ? -step : 0;
|
|
const dy = event.key === "ArrowDown" ? step : event.key === "ArrowUp" ? -step : 0;
|
|
applyResize(dir, dx, dy);
|
|
}
|
|
|
|
// The pinned split keeps its single divider, which resizes the pin width.
|
|
function startPinResize(event: PointerEvent): void {
|
|
if (!desktop.value || event.button !== 0 || !event.isPrimary) return;
|
|
const handle = event.currentTarget as HTMLElement;
|
|
handle.setPointerCapture(event.pointerId);
|
|
const move = (e: PointerEvent): void => {
|
|
const delta = e.clientX - event.clientX;
|
|
layout.value = { ...layout.value, w: clampWidth(layout.value.w + (mode.value === "left" ? delta : -delta)) };
|
|
};
|
|
const end = (): void => {
|
|
handle.removeEventListener("pointermove", move);
|
|
handle.removeEventListener("pointerup", end);
|
|
handle.removeEventListener("pointercancel", end);
|
|
};
|
|
handle.addEventListener("pointermove", move);
|
|
handle.addEventListener("pointerup", end);
|
|
handle.addEventListener("pointercancel", end);
|
|
}
|
|
function clampWidth(w: number): number {
|
|
return Math.min(Math.max(w, MIN_W), pinMax.value);
|
|
}
|
|
function onPinKey(event: KeyboardEvent): void {
|
|
if (!desktop.value) return;
|
|
const grow = event.key === (mode.value === "right" ? "ArrowLeft" : "ArrowRight");
|
|
const shrink = event.key === (mode.value === "right" ? "ArrowRight" : "ArrowLeft");
|
|
if (!grow && !shrink) return;
|
|
event.preventDefault();
|
|
layout.value = { ...layout.value, w: clampWidth(layout.value.w + (grow ? 16 : -16)) };
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div
|
|
v-if="snapTarget"
|
|
aria-hidden="true"
|
|
:class="cn('pointer-events-none fixed inset-y-0 z-40 border-primary/40 bg-primary/10', snapTarget === 'left' ? 'left-0 border-r-2' : 'right-0 border-l-2')"
|
|
:style="{ width: `${pinW}px` }"
|
|
/>
|
|
<div
|
|
:class="cn(
|
|
'pointer-events-none fixed z-40 transition-[left,top,bottom,width,height] duration-200 ease-out motion-reduce:transition-none',
|
|
dragging && 'transition-none',
|
|
!desktop && 'inset-x-0 bottom-4 flex justify-center px-3 max-md:bottom-2',
|
|
)"
|
|
:style="wrapStyle"
|
|
>
|
|
<aside
|
|
ref="dock"
|
|
aria-label="Chat with Archie"
|
|
:class="cn(
|
|
'touch-hit pointer-events-auto relative flex flex-col border-border-strong bg-popover shadow-[var(--shadow-md)]',
|
|
desktop ? cn('w-full', pinned || expanded ? 'h-full' : '', pinned ? (mode === 'left' ? 'border-r' : 'border-l') : 'rounded-lg border') : 'w-full max-w-xl rounded-lg border',
|
|
dragging && 'z-50 opacity-90',
|
|
)"
|
|
>
|
|
<template v-if="desktop && !pinned">
|
|
<div
|
|
v-for="dir in visibleDirs"
|
|
:key="dir"
|
|
role="separator"
|
|
tabindex="0"
|
|
aria-label="Resize chat"
|
|
:title="`Resize from the ${DIR_LABEL[dir]} edge. Arrow keys resize; Shift changes faster.`"
|
|
:aria-orientation="handleOrientation(dir)"
|
|
:aria-valuenow="handleValue(dir, winRect)"
|
|
:aria-valuemin="dir === 'n' || dir === 's' ? MIN_H : MIN_W"
|
|
:aria-valuemax="dir === 'n' || dir === 's' ? vh : vw"
|
|
:data-resize="dir"
|
|
:class="cn('absolute z-10 touch-none hover:bg-primary/30 focus-visible:bg-primary/50 focus-visible:outline-none', HANDLE_CLASS[dir])"
|
|
@pointerdown.prevent="startResize(dir, $event)"
|
|
@keydown="onHandleKey(dir, $event)"
|
|
/>
|
|
</template>
|
|
<div
|
|
v-if="desktop && pinned"
|
|
role="separator"
|
|
aria-orientation="vertical"
|
|
aria-label="Resize chat"
|
|
tabindex="0"
|
|
:aria-valuenow="pinW"
|
|
:aria-valuemin="MIN_W"
|
|
:aria-valuemax="pinMax"
|
|
class="absolute inset-y-0 z-10 w-1.5 cursor-col-resize hover:bg-primary/30 focus-visible:bg-primary/50 focus-visible:outline-none"
|
|
:class="mode === 'left' ? '-right-0.5' : '-left-0.5'"
|
|
@pointerdown.prevent="startPinResize"
|
|
@keydown="onPinKey"
|
|
/>
|
|
<div
|
|
v-if="expanded"
|
|
:class="desktop ? 'cursor-grab select-none active:cursor-grabbing' : 'touch-none'"
|
|
@pointerdown="onHeaderPointerDown"
|
|
@dblclick="togglePin"
|
|
>
|
|
<div v-if="desktop" class="flex justify-center pt-1.5" aria-hidden="true">
|
|
<span class="h-1 w-8 rounded-full bg-border-strong" />
|
|
</div>
|
|
<ChatBar>
|
|
<div v-if="desktop" class="flex flex-none items-center gap-0.5" role="group" aria-label="Chat window position">
|
|
<Button
|
|
v-for="m in MODES"
|
|
:key="m.mode"
|
|
variant="ghost"
|
|
size="xs"
|
|
:aria-pressed="mode === m.mode"
|
|
:aria-label="m.aria"
|
|
:title="m.title"
|
|
:class="mode === m.mode && 'bg-muted text-foreground'"
|
|
@click="setMode(m.mode)"
|
|
>
|
|
<component :is="m.icon" aria-hidden="true" />{{ m.label }}
|
|
</Button>
|
|
</div>
|
|
<Tooltip v-if="desktop">
|
|
<TooltipTrigger as-child>
|
|
<Button
|
|
variant="ghost"
|
|
size="icon-sm"
|
|
class="flex-none"
|
|
data-move-handle
|
|
aria-label="Move chat"
|
|
title="Drag to move. Arrow keys move; Shift moves further."
|
|
@keydown="moveByKey"
|
|
>
|
|
<GripVertical />
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>Move chat</TooltipContent>
|
|
</Tooltip>
|
|
<Tooltip>
|
|
<TooltipTrigger as-child>
|
|
<Button
|
|
variant="ghost"
|
|
size="icon-sm"
|
|
class="flex-none"
|
|
aria-label="Hide conversation"
|
|
@click="expanded = false"
|
|
>
|
|
<ChevronDown />
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>Hide conversation</TooltipContent>
|
|
</Tooltip>
|
|
</ChatBar>
|
|
</div>
|
|
<div
|
|
v-if="expanded"
|
|
:class="cn('flex min-h-0 flex-col', desktop ? 'flex-1' : 'h-[min(28rem,55dvh)]')"
|
|
:style="desktop ? undefined : { height: `min(28rem, ${Math.round(visibleHeight * 0.55)}px)` }"
|
|
>
|
|
<ChatTranscript />
|
|
</div>
|
|
<div @focusin="expanded = true" @pointerdown="onBarPointerDown">
|
|
<ChatComposer :open="false" :flat="!expanded">
|
|
<template v-if="!expanded" #actions>
|
|
<Tooltip v-if="desktop">
|
|
<TooltipTrigger as-child>
|
|
<Button
|
|
variant="ghost"
|
|
size="icon-sm"
|
|
data-move-handle
|
|
aria-label="Move chat"
|
|
title="Drag to move. Arrow keys move; Shift moves further."
|
|
@keydown="moveByKey"
|
|
>
|
|
<GripVertical />
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>Move chat</TooltipContent>
|
|
</Tooltip>
|
|
<Tooltip>
|
|
<TooltipTrigger as-child>
|
|
<Button
|
|
variant="ghost"
|
|
size="icon-sm"
|
|
:class="cn(unseenCount && 'w-auto gap-1 px-2')"
|
|
:aria-label="unseenCount ? `Show conversation, ${unseenCount} new` : 'Show conversation'"
|
|
@click="expanded = true"
|
|
>
|
|
<ChevronUp />
|
|
<Badge v-if="unseenCount" variant="default" aria-hidden="true">{{ unseenCount }}</Badge>
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>Show conversation</TooltipContent>
|
|
</Tooltip>
|
|
</template>
|
|
</ChatComposer>
|
|
</div>
|
|
</aside>
|
|
</div>
|
|
</template>
|