Files
archie/ui/src/chat/ChatTranscript.vue
T
sam a7efb9bb00 feat(webui): show attachment metadata in the session transcript
A message's attachments persist as metadata (messaging.Message.Media) and
cross the gateway wire, but the dashboard transcript rendered text only, so
a photo was invisible to the operator while the model had seen it.

The transcript view now carries the persisted metadata, and the browser
labels each attachment in the placeholder vocabulary the channels already
write into a message's text ('[photo]', '[document: report.pdf]'), with the
surviving metadata (mime, name, size, dimensions, duration) in the chip's
tooltip.

Bytes are never rendered: they are turn-scoped and stripped before a record
is stored, so there is nothing to fetch and no broken image or 404 link. The
platform file id is deliberately not served either -- it is a download
handle, not an address -- so the chip links out only when the attachment
itself carried a URL. A message with no attachments omits the media key, so
transcripts written before this change keep the payload they had.
2026-09-30 03:57:39 +10:00

107 lines
3.4 KiB
Vue

<script setup lang="ts">
import { computed } from "vue";
import { Button } from "@/components/ui/button";
import {
MessageScroller,
MessageScrollerButton,
MessageScrollerContent,
MessageScrollerItem,
MessageScrollerProvider,
MessageScrollerViewport,
} from "@/components/ui/message-scroller";
import ChatBubble from "./ChatBubble.vue";
import ChatEmptyState from "./ChatEmptyState.vue";
import {
messages,
sendMessage,
streamingTurn,
type ChatMessage,
} from "./state";
/**
* The conversation: the messages so far, the turn still arriving, and what the
* panel says before either exists.
*
* The scroller follows the tail, and stops following the moment the reader
* scrolls up rather than yanking them back on every streamed token. That is
* what MessageScroller is for, so it is used rather than re-derived: an
* earlier version set scrollTop from a watcher, which has neither the
* "reader scrolled away" state nor a way back down.
*/
const emit = defineEmits<{ prompt: [text: string] }>();
function parts(message: ChatMessage) {
const from = message.from ?? message.From ?? "";
// Anything this browser's composer did not send is Archie's answer.
return {
text: message.text ?? message.Text ?? "",
tools: message.tool_calls || message.ToolCalls || [],
// Attachments have no bytes left to render -- the record kept their
// metadata only -- so the bubble labels them.
media: message.media || [],
assistant: from !== "web",
};
}
const bubbles = computed(() => messages.value.map(parts));
</script>
<template>
<MessageScrollerProvider auto-scroll default-scroll-position="end">
<MessageScroller class="min-h-0 flex-1">
<MessageScrollerViewport>
<MessageScrollerContent class="gap-4 p-4">
<ChatEmptyState
v-if="!bubbles.length && !streamingTurn"
@prompt="emit('prompt', $event)"
/>
<template v-else>
<MessageScrollerItem
v-for="(bubble, i) in bubbles"
:key="i"
:message-id="`m${i}`"
>
<ChatBubble
:text="bubble.text"
:tools="bubble.tools"
:media="bubble.media"
:assistant="bubble.assistant"
/>
</MessageScrollerItem>
<!-- The live turn is a bubble like any other, so what arrives is
rendered by the same rules as what was already there. It is the
scroll anchor while it streams. -->
<MessageScrollerItem
v-if="streamingTurn"
message-id="streaming"
scroll-anchor
>
<ChatBubble
:text="streamingTurn.text || '…'"
:tools="streamingTurn.tools"
assistant
streaming
>
<Button
v-if="streamingTurn.isError && streamingTurn.turn"
variant="outline"
size="sm"
class="mt-2"
@click="sendMessage({ turn: streamingTurn.turn })"
>
Retry
</Button>
</ChatBubble>
</MessageScrollerItem>
</template>
</MessageScrollerContent>
</MessageScrollerViewport>
<MessageScrollerButton />
</MessageScroller>
</MessageScrollerProvider>
</template>