Files
archie/ui/src/chat/ChatSessionActions.vue
T

108 lines
2.8 KiB
Vue

<script setup lang="ts">
import {
Ellipsis,
GitBranch,
Pencil,
RotateCw,
Shrink,
Undo2,
} from "@lucide/vue";
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 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
* do the work. The popover closes as the command goes, because its answer comes
* back into the transcript and the status line, not into the menu.
*/
const open = ref(false);
useEscapeLayer(open);
function run(command: string): void {
open.value = false;
void runSessionCommand(command);
}
function prompt(command: string, message: string): void {
open.value = false;
promptSessionCommand(command, message);
}
</script>
<template>
<Popover v-model:open="open">
<PopoverTrigger as-child>
<Button
variant="ghost"
size="icon-sm"
class="flex-none"
aria-label="More"
title="More"
>
<Ellipsis />
</Button>
</PopoverTrigger>
<PopoverContent align="end" class="grid w-64 gap-0.5 p-1">
<template v-if="currentSession">
<Button
variant="ghost"
size="sm"
class="justify-start"
@click="run('/retry')"
><RotateCw data-icon="inline-start" />Retry</Button
>
<Button
variant="ghost"
size="sm"
class="justify-start"
@click="run('/undo')"
><Undo2 data-icon="inline-start" />Undo</Button
>
<Button
variant="ghost"
size="sm"
class="justify-start"
@click="prompt('/title', 'Session title')"
><Pencil data-icon="inline-start" />Rename</Button
>
<Button
variant="ghost"
size="sm"
class="justify-start"
@click="prompt('/branch', 'Branch name (optional)')"
><GitBranch data-icon="inline-start" />Branch</Button
>
<Button
variant="ghost"
size="sm"
class="justify-start"
@click="run('/compress --preview')"
><Shrink data-icon="inline-start" />Preview compression</Button
>
<Separator class="my-1" />
</template>
<ChatSettings />
</PopoverContent>
</Popover>
</template>