fix(ui/chat): give the collapsed composer its own card and reserve its height (#1719)
This commit is contained in:
3 files changed
+31
-14
No files matched your search
+1
-1
@@ -81,7 +81,7 @@ watch(() => accounts.status?.user, (user) => {
|
||||
<AlertsBell />
|
||||
</div>
|
||||
</header>
|
||||
<div id="main-content" ref="main" tabindex="-1" class="scroll-mt-16 w-full flex-1 px-6 py-5 pb-24 outline-none max-lg:p-4 max-lg:pb-24"
|
||||
<div id="main-content" ref="main" tabindex="-1" class="scroll-mt-16 w-full flex-1 px-6 py-5 pb-[calc(var(--chat-dock-clear,6rem)+1rem)] outline-none max-lg:p-4 max-lg:pb-[calc(var(--chat-dock-clear,6rem)+1rem)]"
|
||||
:class="workflowsPage && 'max-md:flex max-md:min-h-0 max-md:flex-col'">
|
||||
<!--
|
||||
Keyed on the path and its parameters but not the query: a query-only
|
||||
|
||||
@@ -41,7 +41,9 @@ import {
|
||||
* and stops at `max-h-40`, so a long draft scrolls rather than eating the
|
||||
* transcript above it.
|
||||
*/
|
||||
const props = withDefaults(defineProps<{ open: boolean; bordered?: boolean }>(), { bordered: true });
|
||||
// Flat drops the field's own border and fill when the card around it already
|
||||
// draws them, so the collapsed dock reads as one surface rather than a box in a box.
|
||||
const props = defineProps<{ open: boolean; flat?: boolean }>();
|
||||
|
||||
// Voice: recorded in the browser, transcribed by the server like a Telegram
|
||||
// voice note. The mic shows only while the composer is empty.
|
||||
@@ -165,7 +167,7 @@ function onKeydown(event: KeyboardEvent): void {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="border-t p-3">
|
||||
<div :class="flat ? 'p-1.5' : 'border-t p-3'">
|
||||
<ul v-if="queuedMessages.length" aria-label="Queued messages" class="mb-2 flex flex-col gap-1">
|
||||
<li
|
||||
v-for="(queued, index) in queuedMessages"
|
||||
@@ -195,8 +197,8 @@ function onKeydown(event: KeyboardEvent): void {
|
||||
<div
|
||||
:class="
|
||||
cn(
|
||||
'relative flex items-end gap-2 rounded-xl border bg-muted px-3 py-2.5 transition-colors duration-200',
|
||||
bordered ? 'border-border-strong' : 'border-transparent',
|
||||
'relative flex items-end gap-2 rounded-xl border px-3 transition-colors duration-200',
|
||||
flat ? 'border-transparent py-1.5' : 'border-border-strong bg-muted py-2.5',
|
||||
)
|
||||
"
|
||||
>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { ChevronDown, ChevronUp } from "@lucide/vue";
|
||||
import { onUnmounted, ref, watch } from "vue";
|
||||
import { onMounted, onUnmounted, ref, watch } from "vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
import ChatBar from "./ChatBar.vue";
|
||||
import ChatComposer from "./ChatComposer.vue";
|
||||
import ChatTranscript from "./ChatTranscript.vue";
|
||||
@@ -52,6 +51,26 @@ watch(expanded, (open) => {
|
||||
});
|
||||
onUnmounted(() => document.removeEventListener("keydown", onKeydown));
|
||||
|
||||
// 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.
|
||||
const dock = ref<HTMLElement | null>(null);
|
||||
let observer: ResizeObserver | null = null;
|
||||
function reserve(): void {
|
||||
if (expanded.value || !dock.value) return;
|
||||
const clear = window.innerHeight - dock.value.getBoundingClientRect().top;
|
||||
document.documentElement.style.setProperty("--chat-dock-clear", `${Math.ceil(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");
|
||||
});
|
||||
|
||||
function usePrompt(text: string): void {
|
||||
composerText.value = text;
|
||||
composer.value?.focus();
|
||||
@@ -61,13 +80,9 @@ function usePrompt(text: string): void {
|
||||
<template>
|
||||
<div class="pointer-events-none fixed inset-x-0 bottom-4 z-40 flex justify-center px-3 max-md:bottom-2">
|
||||
<aside
|
||||
ref="dock"
|
||||
aria-label="Chat with Archie"
|
||||
:class="
|
||||
cn(
|
||||
'pointer-events-auto flex w-full max-w-xl flex-col rounded-lg border transition-[border-color,background-color,box-shadow] duration-200',
|
||||
expanded ? 'border-border-strong bg-popover shadow-[var(--shadow-md)]' : 'border-transparent bg-transparent',
|
||||
)
|
||||
"
|
||||
class="pointer-events-auto flex w-full max-w-xl flex-col rounded-lg border border-border-strong bg-popover shadow-[var(--shadow-md)]"
|
||||
>
|
||||
<ChatBar v-if="expanded">
|
||||
<Tooltip>
|
||||
@@ -89,7 +104,7 @@ function usePrompt(text: string): void {
|
||||
<ChatTranscript @prompt="usePrompt" />
|
||||
</div>
|
||||
<div @focusin="expanded = true">
|
||||
<ChatComposer ref="composer" :open="false" :bordered="expanded" :class="!expanded && 'border-t-0!'">
|
||||
<ChatComposer ref="composer" :open="false" :flat="!expanded">
|
||||
<template v-if="!expanded" #actions>
|
||||
<Tooltip>
|
||||
<TooltipTrigger as-child>
|
||||
|
||||
Reference in new issue
Block a user