godcrm/components/AIChatPanel/hooks/useChatActions.ts
GOD CRM Release f89e074dd1
Some checks failed
CI / Lint / Typecheck / Test / Build (push) Has been cancelled
CI / PostgreSQL Integration Tests (push) Has been cancelled
GOD CRM — public scrubbed snapshot
Governed substrate for autonomous agents: scoped identity (passports),
audited actions, MCP workspace. Infra IPs and secrets redacted for public release.
2026-08-10 04:01:45 +03:00

74 lines
1.6 KiB
TypeScript

/**
* useChatActions Hook
* Handles chat message actions extracted from AIChatPanel
*/
import { useCallback } from 'react';
import { useAIChat } from '../../../context/AIChatContext';
import type { AIAgent } from '../../../types';
interface Mention {
id: number;
name: string;
type: 'human' | 'agent' | 'bot' | 'service';
}
interface SendMessageData {
content: string;
attachments?: File[];
modelId?: number;
mentions?: Mention[];
agentMode?: boolean;
systemPromptPrefix?: string;
}
export function useChatActions() {
const {
sendMessage,
clearMessages,
selectAgent,
createNewConversation,
deleteConversation,
isLoading,
isStreaming,
error
} = useAIChat();
const handleSendMessage = useCallback(async (data: SendMessageData) => {
await sendMessage(
data.content,
data.attachments,
data.modelId,
data.mentions,
data.agentMode,
data.systemPromptPrefix
);
}, [sendMessage]);
const handleClearMessages = useCallback(() => {
clearMessages();
}, [clearMessages]);
const handleSelectAgent = useCallback((agent: AIAgent) => {
selectAgent(agent);
}, [selectAgent]);
const handleCreateConversation = useCallback(async () => {
await createNewConversation();
}, [createNewConversation]);
const handleDeleteConversation = useCallback(async (conversationId: number) => {
await deleteConversation(conversationId);
}, [deleteConversation]);
return {
handleSendMessage,
handleClearMessages,
handleSelectAgent,
handleCreateConversation,
handleDeleteConversation,
isLoading,
isStreaming,
error
};
}