Files
rhema-together/web/app/components/ChatMessage.vue
T
vhaudiquet a8f7e74ba0
ci / checks (push) Successful in 1m58s
ci / test (push) Successful in 1m54s
ci / chart (push) Successful in 5s
ci / web (push) Successful in 18s
ci / docker (push) Successful in 16s
ci / publish-edge-image (push) Successful in 9s
ci / publish-edge-chart (push) Successful in 3s
feat(web): render messages as markdown
Messages were plain text, so headings, lists, code, tables, and links
from people and the agent showed as literal markup. Render them with
markdown-it, with raw HTML off and unsafe link schemes blocked.
External links open in a new tab, and @rhema stays highlighted.

Code, tables, quotes, and images get styles that fit the message body.
2026-11-28 22:23:41 +01:00

38 lines
1.4 KiB
Vue

<script setup lang="ts">
import { computed } from 'vue'
import type { Message } from '~/types'
import { fullTime, relativeTime } from '~/utils/format'
import { memberColorVar } from '~/utils/member'
import { renderMarkdown } from '~/utils/markdown'
const props = defineProps<{ message: Message; color?: string | null; avatar?: string | null }>()
const html = computed(() => renderMarkdown(props.message.text))
const style = computed(() => ({ '--member': memberColorVar(props.color) }))
</script>
<template>
<div v-if="message.author_kind === 'system'" class="msg msg-system">
{{ message.text }}
</div>
<div v-else-if="message.author_kind === 'agent'" class="msg msg-agent">
<div class="msg-head">
<span class="msg-agent-label">rhema</span>
<span class="msg-time" :title="fullTime(message.created_at)">{{ relativeTime(message.created_at) }}</span>
</div>
<div class="msg-text" v-html="html"></div>
</div>
<div v-else class="msg msg-human">
<AppAvatar :name="message.author_name" :color="color" :src="avatar" size="sm" />
<div class="msg-body">
<div class="msg-head">
<span class="msg-author member-name" :style="style">{{ message.author_name }}</span>
<span class="msg-time" :title="fullTime(message.created_at)">{{ relativeTime(message.created_at) }}</span>
</div>
<div class="msg-text" v-html="html"></div>
</div>
</div>
</template>