feat: melhorias no sistema de chat ao vivo
- Chat do agente abre expandido automaticamente ao iniciar nova sessao - Toasts fecham apos tempo fixo independente do foco da janela - Janela de chat do desktop com transparencia (sem fundo branco) - Chat reabre quando usuario abre o Raven (duplo clique no tray) - Chat nao reabre sozinho com novas mensagens (apenas notificacao) - Mensagem de toast simplificada: "Chat ao vivo iniciado" - Reduz intervalo de polling SSE de 2s para 1s (mais responsivo) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
3700ac9dad
commit
24dee5d5eb
9 changed files with 74 additions and 31 deletions
|
|
@ -252,6 +252,7 @@ export function ChatWidget() {
|
|||
const inputRef = useRef<HTMLTextAreaElement | null>(null)
|
||||
const fileInputRef = useRef<HTMLInputElement | null>(null)
|
||||
const dropAreaRef = useRef<HTMLDivElement | null>(null)
|
||||
const prevSessionCountRef = useRef<number>(0)
|
||||
|
||||
// Buscar sessões de chat ativas do agente
|
||||
const activeSessions = useQuery(
|
||||
|
|
@ -285,6 +286,26 @@ export function ChatWidget() {
|
|||
}
|
||||
}, [activeTicketId, activeSessions])
|
||||
|
||||
// Auto-abrir widget quando uma nova sessão é iniciada
|
||||
useEffect(() => {
|
||||
if (!activeSessions) return
|
||||
const currentCount = activeSessions.length
|
||||
const prevCount = prevSessionCountRef.current
|
||||
|
||||
// Se aumentou o número de sessões, é uma nova sessão - abrir o widget expandido
|
||||
if (currentCount > prevCount && prevCount >= 0) {
|
||||
setIsOpen(true)
|
||||
setIsMinimized(false)
|
||||
// Selecionar a sessão mais recente (última da lista ou primeira se única)
|
||||
const newestSession = activeSessions[activeSessions.length - 1] ?? activeSessions[0]
|
||||
if (newestSession) {
|
||||
setActiveTicketId(newestSession.ticketId)
|
||||
}
|
||||
}
|
||||
|
||||
prevSessionCountRef.current = currentCount
|
||||
}, [activeSessions])
|
||||
|
||||
// Scroll para última mensagem
|
||||
useEffect(() => {
|
||||
if (messagesEndRef.current && isOpen && !isMinimized) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue