feat(ui): topbar chat button; a docked chat hides when minimised
This commit is contained in:
4 files changed
+51
-2
No files matched your search
@@ -11,6 +11,7 @@ import AppSidebar from "@/components/AppSidebar.vue";
|
||||
import CommandPalette from "@/components/command-palette/CommandPalette.vue";
|
||||
import AccountMenu from "@/components/topbar/AccountMenu.vue";
|
||||
import OrgCrumb from "@/components/topbar/OrgCrumb.vue";
|
||||
import ChatTopbarButton from "@/chat/ChatTopbarButton.vue";
|
||||
import SectionCrumb from "@/components/topbar/SectionCrumb.vue";
|
||||
import Brand from "@/components/topbar/Brand.vue";
|
||||
import Logo from "@/components/topbar/Logo.vue";
|
||||
@@ -112,6 +113,7 @@ watch(() => accounts.status?.user, (user) => {
|
||||
<ConnectionPill />
|
||||
<CommandPalette :hidden="hidden" @new-task="newTaskOpen = true" />
|
||||
<NewTaskDialog v-if="!hidden.includes('/workflows')" v-model:open="newTaskOpen" />
|
||||
<ChatTopbarButton />
|
||||
<AlertsBell />
|
||||
<span class="max-md:hidden"><AccountMenu /></span>
|
||||
</div>
|
||||
|
||||
@@ -43,7 +43,7 @@ import {
|
||||
type Rect,
|
||||
type ResizeDir,
|
||||
} from "./ChatDockLayout";
|
||||
import { escapeOwnedByLayer, isSending, reloadTranscript, useChat, useEscapeLayer } from "./state";
|
||||
import { dockExpanded, escapeOwnedByLayer, isSending, reloadTranscript, useChat, useEscapeLayer } from "./state";
|
||||
import { setDockOpen, unseenCount } from "./unseen";
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ useChat();
|
||||
// mounted while collapsed, so a reply that lands then is still read and counted.
|
||||
useLiveResource("chat", () => void reloadTranscript());
|
||||
|
||||
const expanded = ref(false);
|
||||
const expanded = dockExpanded;
|
||||
watch(expanded, setDockOpen, { immediate: true });
|
||||
|
||||
// The old edge-pin preference moves into the new key before useStorage reads it.
|
||||
@@ -438,6 +438,9 @@ function onPinKey(event: KeyboardEvent): void {
|
||||
'pointer-events-none fixed z-40 transition-[left,top,bottom,width,height] duration-200 ease-out motion-reduce:transition-none',
|
||||
(dragging || resizing) && 'transition-none',
|
||||
!desktop && 'inset-x-0 bottom-4 flex justify-center px-3 max-md:bottom-2',
|
||||
// Docked, minimising hides the dock; the topbar button and Ctrl+/ bring
|
||||
// it back. It stays mounted so the session and a turn in flight survive.
|
||||
desktop && mode !== 'float' && !expanded && 'hidden',
|
||||
)"
|
||||
:style="wrapStyle"
|
||||
>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<script setup lang="ts">
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { MessageCircle } from "@lucide/vue";
|
||||
import { computed } from "vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Kbd } from "@/components/ui/kbd";
|
||||
import { dockExpanded } from "./state";
|
||||
import { unseenCount } from "./unseen";
|
||||
|
||||
/**
|
||||
* Opens and closes the chat dock from the topbar, so a dock that is minimised,
|
||||
* or hidden because it is docked, is one click away without knowing Ctrl+/.
|
||||
*/
|
||||
const shortcut = navigator.platform.startsWith("Mac") ? "⌘/" : "Ctrl /";
|
||||
const label = computed(() => {
|
||||
const action = dockExpanded.value ? "Hide chat" : "Chat with Archie";
|
||||
return unseenCount.value ? `${action}, ${unseenCount.value} new` : action;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Tooltip>
|
||||
<TooltipTrigger as-child>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
class="relative"
|
||||
:aria-label="label"
|
||||
:aria-pressed="dockExpanded"
|
||||
@click="dockExpanded = !dockExpanded"
|
||||
>
|
||||
<MessageCircle class="size-4" aria-hidden="true" />
|
||||
<Badge v-if="unseenCount" class="absolute -top-0.5 -right-1.5 h-4 min-w-4 px-1 text-caption tabular-nums" aria-hidden="true">
|
||||
{{ unseenCount }}
|
||||
</Badge>
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>{{ dockExpanded ? "Hide chat" : "Chat with Archie" }} <Kbd>{{ shortcut }}</Kbd></TooltipContent>
|
||||
</Tooltip>
|
||||
</template>
|
||||
@@ -206,6 +206,8 @@ export const sessions = ref<ChatSession[]>([]);
|
||||
export const currentSession = ref("");
|
||||
export const messages = ref<ChatMessage[]>([]);
|
||||
const drafts = ref<Record<string, string>>({});
|
||||
/** Whether the chat dock shows the conversation; the dock, Ctrl+/ and the topbar button share it. */
|
||||
export const dockExpanded = ref(false);
|
||||
/** A suggested prompt the pointer or focus rests on, previewed as the composer placeholder. */
|
||||
export const placeholderHint = ref("");
|
||||
/** The unsent text of the open conversation; each conversation keeps its own. */
|
||||
|
||||
Reference in new issue
Block a user