fix: redimensiona janela de chat ao minimizar/expandir

- Adiciona funcao set_chat_minimized que redimensiona a janela
- Modo minimizado: 200x56 (tamanho do chip)
- Modo expandido: 380x520 (tamanho completo)
- Janela reposiciona automaticamente no canto inferior direito
- Adiciona comando is_chat_using_sse para verificar modo de conexao

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
esdrasrenan 2025-12-07 17:12:29 -03:00
parent 53376fe5b0
commit a0edaf8adb
3 changed files with 69 additions and 5 deletions

View file

@ -68,9 +68,13 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
useEffect(() => {
if (hadSessionRef.current && !hasSession) {
setIsMinimized(true)
// Redimensionar janela para modo minimizado
invoke("set_chat_minimized", { ticketId, minimized: true }).catch(err => {
console.error("Erro ao minimizar janela automaticamente:", err)
})
}
hadSessionRef.current = hasSession
}, [hasSession])
}, [hasSession, ticketId])
// Carregar configuracao do store
const loadConfig = useCallback(async () => {
@ -306,8 +310,22 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
}
}
const handleMinimize = () => {
const handleMinimize = async () => {
setIsMinimized(true)
try {
await invoke("set_chat_minimized", { ticketId, minimized: true })
} catch (err) {
console.error("Erro ao minimizar janela:", err)
}
}
const handleExpand = async () => {
setIsMinimized(false)
try {
await invoke("set_chat_minimized", { ticketId, minimized: false })
} catch (err) {
console.error("Erro ao expandir janela:", err)
}
}
const handleClose = () => {
@ -357,9 +375,9 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
// Versão minimizada (chip compacto igual web)
if (isMinimized) {
return (
<div className="flex h-screen flex-col items-center justify-end bg-transparent p-4">
<div className="flex h-full w-full items-center justify-center bg-transparent">
<button
onClick={() => setIsMinimized(false)}
onClick={handleExpand}
className="flex items-center gap-2 rounded-full bg-black px-4 py-2 text-white shadow-lg hover:bg-black/90"
>
<MessageCircle className="size-4" />