fix(ui): clear the chat on /new, show the copy action on hover, fold settings into the bar's menu
This commit is contained in:
8 files changed
+183
-197
No files matched your search
@@ -4,8 +4,7 @@ import { MessageCirclePlus } from "@lucide/vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import ChatSessionActions from "./ChatSessionActions.vue";
|
||||
import ChatSessionList from "./ChatSessionList.vue";
|
||||
import ChatSettings from "./ChatSettings.vue";
|
||||
import { currentSession, newChat } from "./state";
|
||||
import { newChat } from "./state";
|
||||
|
||||
/**
|
||||
* One row for everything that is not the conversation: which conversation is
|
||||
@@ -28,8 +27,7 @@ import { currentSession, newChat } from "./state";
|
||||
>
|
||||
<MessageCirclePlus />
|
||||
</Button>
|
||||
<ChatSettings />
|
||||
<ChatSessionActions v-if="currentSession" />
|
||||
<ChatSessionActions />
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -54,7 +54,10 @@ withDefaults(
|
||||
<slot />
|
||||
</BubbleContent>
|
||||
</Bubble>
|
||||
<MessageFooter v-if="assistant && !streaming && text" class="px-0">
|
||||
<MessageFooter
|
||||
v-if="assistant && !streaming && text"
|
||||
class="px-0 transition-opacity focus-within:opacity-100 [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover/message:opacity-100"
|
||||
>
|
||||
<CodeBlockCopyButton :value="text" />
|
||||
</MessageFooter>
|
||||
</MessageContent>
|
||||
|
||||
@@ -10,21 +10,25 @@ import {
|
||||
import { ref } from "vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
import ChatSettings from "./ChatSettings.vue";
|
||||
import {
|
||||
currentSession,
|
||||
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.
|
||||
* The menu behind the bar's one "more" button: 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), then the provider and model it runs on.
|
||||
*
|
||||
* 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
|
||||
@@ -52,13 +56,14 @@ function prompt(command: string, message: string): void {
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
class="flex-none"
|
||||
aria-label="Session actions"
|
||||
title="Session actions"
|
||||
aria-label="More"
|
||||
title="More"
|
||||
>
|
||||
<Ellipsis />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="end" class="grid w-48 gap-0.5 p-1">
|
||||
<PopoverContent align="end" class="grid w-64 gap-0.5 p-1">
|
||||
<template v-if="currentSession">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
@@ -94,6 +99,9 @@ function prompt(command: string, message: string): void {
|
||||
@click="run('/compress --preview')"
|
||||
><Shrink data-icon="inline-start" />Preview compression</Button
|
||||
>
|
||||
<Separator class="my-1" />
|
||||
</template>
|
||||
<ChatSettings />
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</template>
|
||||
@@ -1,14 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { Settings } from "@lucide/vue";
|
||||
import { computed, ref } from "vue";
|
||||
import { computed } 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,
|
||||
@@ -25,17 +18,11 @@ import {
|
||||
setModel,
|
||||
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.
|
||||
* The chat's own settings: what the panel is doing right now, and the
|
||||
* selectors the server offers. It sits in the session menu.
|
||||
*
|
||||
* 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
|
||||
@@ -44,9 +31,6 @@ import {
|
||||
*/
|
||||
const DEFAULT = "__default__";
|
||||
|
||||
const open = ref(false);
|
||||
useEscapeLayer(open);
|
||||
|
||||
const providerValue = computed(() => selectedProvider.value || DEFAULT);
|
||||
const modelValue = computed(() => selectedModel.value || DEFAULT);
|
||||
|
||||
@@ -56,66 +40,54 @@ function clear(value: unknown): string {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Popover v-model:open="open">
|
||||
<PopoverTrigger as-child>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
aria-label="Chat settings"
|
||||
title="Chat settings"
|
||||
<div class="grid gap-3 p-2">
|
||||
<span v-if="statusText !== 'Ready'" class="text-xs text-fg-subtle">{{ statusText }}</span>
|
||||
|
||||
<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))"
|
||||
>
|
||||
<Settings />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="end" class="grid w-64 gap-3">
|
||||
<span v-if="statusText !== 'Ready'" class="text-xs text-fg-subtle">{{ statusText }}</span>
|
||||
<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 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>
|
||||
<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>
|
||||
</div>
|
||||
</template>
|
||||
@@ -534,10 +534,15 @@ export async function sendMessage(retryOpts?: RetryOptions): Promise<void> {
|
||||
|
||||
if (!finished) throw new Error("chat stream ended before completion");
|
||||
|
||||
messages.value = [
|
||||
...messages.value,
|
||||
{ from: "assistant", text: streamedText, tool_calls: activeTools },
|
||||
];
|
||||
// /new opens an empty conversation, so the window clears instead of
|
||||
// carrying the old one with a confirmation under it.
|
||||
messages.value =
|
||||
!isRetry && text.trim() === "/new"
|
||||
? []
|
||||
: [
|
||||
...messages.value,
|
||||
{ from: "assistant", text: streamedText, tool_calls: activeTools },
|
||||
];
|
||||
streamingTurn.value = null;
|
||||
statusText.value = "Ready";
|
||||
await refreshSessions();
|
||||
|
||||
Reference in new issue
Block a user