Files
archie/ui/src/chat/ChatSessionActions.vue
T
sam fa14e7da80
Quality / check (push) Canceled after 1m18s
deploy / gate (push) Successful in 4m47s
deploy / archied-image (push) Successful in 3m27s
deploy / agent-image (push) Successful in 11s
deploy / dist-zip (push) Skipped
fix(ui): chat failures are shown where they happen and leave the real state (#1748)
Mic permission failure shows an inline alert; setModel only switches on
server confirmation and reverts + reports in the transcript on failure;
a failed session refresh after a turn no longer becomes a retryable turn
error; a voice clip during a turn queues instead of dropping; blocked
localStorage falls back to a per-load channel id; a failed install offers
Retry/Not now again; rename/branch use a labelled Dialog instead of
window.prompt; a failed cancel is reported; a stopped turn no longer
blocks transcript reloads.
2026-11-07 00:17:44 +11:00

143 lines
4.1 KiB
Vue

<script setup lang="ts">
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
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 {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import ChatSettings from "./ChatSettings.vue";
import {
currentSession,
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 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);
}
// Rename and branch ask for a value in a labelled dialog, not window.prompt.
const promptOpen = ref(false);
const promptCommand = ref("");
const promptMessage = ref("");
const promptValue = ref("");
function prompt(command: string, message: string): void {
open.value = false;
promptCommand.value = command;
promptMessage.value = message;
promptValue.value = "";
promptOpen.value = true;
}
function submitPrompt(): void {
const value = promptValue.value.trim();
promptOpen.value = false;
if (value) void runSessionCommand(`${promptCommand.value} ${value}`);
}
</script>
<template>
<Popover v-model:open="open">
<PopoverTrigger as-child>
<Tooltip>
<TooltipTrigger as-child>
<Button
variant="ghost"
size="icon-sm"
class="flex-none"
aria-label="More"
>
<Ellipsis />
</Button>
</TooltipTrigger>
<TooltipContent>More</TooltipContent>
</Tooltip>
</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>
<Dialog :open="promptOpen" @update:open="(v: boolean) => (promptOpen = v)">
<DialogContent>
<DialogHeader><DialogTitle>{{ promptMessage }}</DialogTitle></DialogHeader>
<Input v-model="promptValue" :aria-label="promptMessage" @keydown.enter.prevent="submitPrompt" />
<DialogFooter>
<Button variant="ghost" @click="promptOpen = false">Cancel</Button>
<Button :disabled="!promptValue.trim()" @click="submitPrompt">OK</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</template>