feat: Unified Messaging System — kommunikation plugin, AI/Proactive/System participants, MessageSidebar, Rich Content Renderer

Phase 1: Backend plugin kommunikation (13 files, 10 tables, REST API, WebSocket, RBAC, DMS Bridge, Participant Registry, Mini-App Registry, Search Provider)
Phase 2: AI plugins as participants (ai_assistant + ai_proactive dock as participants, heartbeat job)
Phase 3: system_notif plugin (system events → chat messages, pinned System room)
Phase 4: Frontend MessageSidebar (replaces AISidebar, same design, comm API client, WebSocket hook, commStore)
Phase 5: Rich Content Block Renderer (11 components: Markdown, HTML, Image, Audio, Video, File, ActionCard, ContactCard, MiniApp, BlockRenderer)
BasePlugin: added services property + _container in on_activate
This commit is contained in:
Agent Zero
2026-07-22 01:22:15 +02:00
parent 5980d38c66
commit cc3ac9a43d
45 changed files with 8154 additions and 113 deletions
+107
View File
@@ -0,0 +1,107 @@
import { create } from 'zustand';
export interface Participant {
id: string;
conversation_id: string;
participant_id: string | null;
participant_type: string;
display_name: string | null;
role: string;
}
export interface Conversation {
id: string;
title: string | null;
is_locked: boolean;
locked_by: string | null;
is_direct: boolean;
is_archived: boolean;
is_pinned: boolean;
created_by: string | null;
created_by_type: string;
last_msg_at: string | null;
last_msg_preview: string | null;
last_msg_sender_type: string | null;
participants: Participant[];
unread_count: number;
metadata: Record<string, any>;
}
export interface MessageBlock {
id: string;
block_type: string;
block_data: Record<string, any>;
sort_order: number;
}
export interface MessageAttachment {
id: string;
file_id: string | null;
file_source: string;
file_name: string;
file_type: string;
file_size: number | null;
thumbnail_path: string | null;
}
export interface Message {
id: string;
conversation_id: string;
sender_id: string | null;
sender_type: string;
content: string;
content_format: string;
metadata: Record<string, any>;
reply_to_id: string | null;
is_pinned: boolean;
created_at: string | null;
edited_at: string | null;
blocks: MessageBlock[];
attachments: MessageAttachment[];
reactions: any[];
}
export interface CommState {
conversations: Conversation[];
activeConversationId: string | null;
messages: Record<string, Message[]>;
typingUsers: Record<string, string[]>;
unreadCounts: Record<string, number>;
loading: boolean;
setConversations: (convs: Conversation[]) => void;
setActiveConversation: (id: string | null) => void;
addMessage: (convId: string, msg: Message) => void;
setMessages: (convId: string, msgs: Message[]) => void;
updateConversation: (conv: Conversation) => void;
setTyping: (convId: string, userIds: string[]) => void;
setUnread: (convId: string, count: number) => void;
setLoading: (loading: boolean) => void;
}
export const useCommStore = create<CommState>((set) => ({
conversations: [],
activeConversationId: null,
messages: {},
typingUsers: {},
unreadCounts: {},
loading: false,
setConversations: (conversations) => set({ conversations }),
setActiveConversation: (activeConversationId) => set({ activeConversationId }),
addMessage: (convId, msg) => set((s) => ({
messages: { ...s.messages, [convId]: [...(s.messages[convId] || []), msg] },
})),
setMessages: (convId, msgs) => set((s) => ({
messages: { ...s.messages, [convId]: msgs },
})),
updateConversation: (conv) => set((s) => ({
conversations: s.conversations.map((c) => (c.id === conv.id ? conv : c)),
})),
setTyping: (convId, userIds) => set((s) => ({
typingUsers: { ...s.typingUsers, [convId]: userIds },
})),
setUnread: (convId, count) => set((s) => ({
unreadCounts: { ...s.unreadCounts, [convId]: count },
})),
setLoading: (loading) => set({ loading }),
}));
+7 -5
View File
@@ -18,6 +18,7 @@ export interface UIState {
suggestionSidebarOpen: boolean;
aiSidebarCollapsed: boolean;
aiSidebarTab: AISidebarTab;
messageSidebarCollapsed: boolean;
toasts: Toast[];
notifications: string[];
setTheme: (theme: Theme) => void;
@@ -29,6 +30,8 @@ export interface UIState {
setAISidebarCollapsed: (collapsed: boolean) => void;
setAISidebarTab: (tab: AISidebarTab) => void;
openAISidebarProactive: () => void;
toggleMessageSidebar: () => void;
setMessageSidebarCollapsed: (collapsed: boolean) => void;
addToast: (toast: Omit<Toast, 'id'>) => void;
removeToast: (id: string) => void;
clearToasts: () => void;
@@ -45,12 +48,9 @@ export const useUIStore = create<UIState>((set) => ({
suggestionSidebarOpen: false,
aiSidebarCollapsed: true,
aiSidebarTab: 'chat',
messageSidebarCollapsed: true,
toasts: [],
notifications: [
'Neuer Kontakt hinzugefügt: Max Mustermann',
'Firma aktualisiert: TechCorp GmbH',
'Meeting um 14:00 Uhr mit Müller AG',
],
notifications: [],
setTheme: (theme) => {
localStorage.setItem('leocrm_theme', theme);
set({ theme });
@@ -66,6 +66,8 @@ export const useUIStore = create<UIState>((set) => ({
setAISidebarCollapsed: (collapsed) => set({ aiSidebarCollapsed: collapsed }),
setAISidebarTab: (tab) => set({ aiSidebarTab: tab }),
openAISidebarProactive: () => set({ aiSidebarCollapsed: false, aiSidebarTab: 'proactive' }),
toggleMessageSidebar: () => set((s) => ({ messageSidebarCollapsed: !s.messageSidebarCollapsed })),
setMessageSidebarCollapsed: (collapsed) => set({ messageSidebarCollapsed: collapsed }),
addToast: (toast) => {
const id = `toast-${++toastIdCounter}`;
set((s) => ({ toasts: [...s.toasts, { ...toast, id }] }));