Apps
Chat
Direct and group conversations with pinned threads, replies, reactions, attachments and a contact panel.
Chat follows the email architecture. Threads can be pinned (their own section in the list), groups list their memberIds and render with BaseAvatarGroup, and messages support replyToId (a quoted reply) and reactions. The mock provider also simulates replies so the demo feels alive.
Every app follows the same pattern: typed models in types/models/, demo data in mocks/, state and actions in a composable under composables/apps/, page-only components in components/pages/<app>/ and UI strings in locales/<code>/apps.json. Read the apps overview once and every app looks familiar.
Files
File | Role |
|---|---|
pages/chat.vue | The page: thread list, conversation and info aside. |
composables/apps/useChat.ts | Threads, messages, sending, reactions and unread counts. |
types/models/chat.ts | Contacts, threads, messages and the provider. |
mocks/chat.mock.ts | Demo conversations and createChatMockProvider(). |
components/pages/chat/ | ChatThreadList, ChatConversation, ChatMessageBubble, ChatComposer, ChatContactPanel. |
Data and provider
export interface ChatProvider {
load: () => Promise<ChatState>
send: (message: ChatMessage) => Promise<void>
updateThread: (threadId: string, patch: ChatThreadPatch) => Promise<void>
updateMessage: (messageId: string, patch: Pick<ChatMessage, 'reactions'>) => Promise<void>
}
Connect your backend
The page calls useChat() with the mock provider. Write a provider that calls your API with useApi() and pass it in the page. The composable loads it through useAsyncData and applies every change optimistically, so the interface does not wait for the server.
import type { ChatProvider, ChatState } from '~/types/models/chat'
export function createChatApiProvider(): ChatProvider {
const api = useApi()
return {
load: () => api<ChatState>('/chat'),
send: (message) => api('/chat/messages', { method: 'POST', body: message }),
updateThread: (threadId, patch) => api(`/chat/threads/${threadId}`, { method: 'PATCH', body: patch }),
updateMessage: (messageId, patch) => api(`/chat/messages/${messageId}`, { method: 'PATCH', body: patch }),
}
}
<script setup lang="ts">
import { createChatApiProvider } from '~/providers/chat'
const { ... } = useChat({ provider: createChatApiProvider() })
</script>
Keep ids in your data and labels in the locales: folders, labels and tags resolve their names through apps.<app>.* unless you give them a raw title. See Connect your API for the token, validation errors and the actions the demo only fakes.
Configuration
Chat has no config file: its options are the threads themselves (pinned, muted, members). Live updates are up to your backend: push new messages into the state the composable returns, for example from a WebSocket.
How it works
- The conversation groups consecutive messages from the same author sent within 5 minutes.
- A “new messages” divider marks the unread count captured when the thread opens.
- The info aside (
ChatContactPanel, toggled from the header) splits shared items into files, images and links. - Attachments use
BaseAttachment, the same as email.