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}
This commit is contained in:
26
app/components/Chat/Page.vue
Normal file
26
app/components/Chat/Page.vue
Normal file
@@ -0,0 +1,26 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user