Files
vue-chat-layer/app/components/Chat/Page.vue
Jakub Zych fa6f9950a6 feat: chat layer tracer: bootstrap, channel list, messages, composer
- createChatClient: bearer auth, one refresh-and-retry on 401, 422 field errors
- useChat over useState: host bootstrap, open a channel, send
- ChatPage, ChatChannelList, ChatMessageList, ChatComposer
- runtime config chat.apiBase, public.chat.{apiBase,channelsApiBase,botsApiBase,hostApiBase}
2026-10-31 13:40:39 +01:00

27 lines
941 B
Vue

<script setup lang="ts">
// The full chat: the channel sidebar and the open conversation. Render it
// inside <ClientOnly> (it uses window and the DOM).
const { t } = useI18n()
const chat = useChat()
onMounted(() => {
void chat.start()
})
const active = computed(() => chat.channels.value.find((c) => c.conversation_id === chat.activeId.value) ?? null)
</script>
<template>
<div class="chat-page">
<ChatChannelList />
<section class="chat-pane" :aria-label="active ? `# ${active.name}` : t('chat.name')">
<template v-if="chat.activeId.value !== null">
<ChatMessageList :conversation-id="chat.activeId.value" />
<ChatComposer :conversation-id="chat.activeId.value" />
</template>
<p v-else class="chat-pane-empty">{{ t('chat.pickChannel') }}</p>
<p v-if="chat.error.value" class="chat-error" role="alert">{{ t(`chat.error.${chat.error.value}`) }}</p>
</section>
</div>
</template>