From c7b6d78ec269322667f34c5ec427840f9688ccc1 Mon Sep 17 00:00:00 2001
From: rever-tecnologia
Date: Mon, 15 Dec 2025 14:46:39 -0300
Subject: [PATCH] =?UTF-8?q?fix(desktop):=20corrige=20travamento=20com=20m?=
=?UTF-8?q?=C3=BAltiplos=20chats?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Problemas corrigidos:
- Removido always_on_top de todas as janelas (causava competição de Z-order)
- Removido inner_size() síncrono que bloqueava a UI thread
- Simplificado process_chat_update para não fazer múltiplas operações de janela
- Removidos logs de debug
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5
---
apps/desktop/src-tauri/src/chat.rs | 26 +++++------------------
apps/desktop/src/chat/ChatHubWidget.tsx | 13 ++----------
apps/desktop/src/chat/ChatSessionItem.tsx | 1 -
apps/desktop/src/chat/ChatSessionList.tsx | 12 +++--------
4 files changed, 10 insertions(+), 42 deletions(-)
diff --git a/apps/desktop/src-tauri/src/chat.rs b/apps/desktop/src-tauri/src/chat.rs
index fdd68ff..f6a5dcb 100644
--- a/apps/desktop/src-tauri/src/chat.rs
+++ b/apps/desktop/src-tauri/src/chat.rs
@@ -1001,21 +1001,16 @@ async fn process_chat_update(
}
// Se ha multiplas sessoes ativas, usar o hub; senao, abrir janela do chat individual
+ // SIMPLIFICADO: Removido inner_size() que bloqueava a UI thread
if current_sessions.len() > 1 {
// Multiplas sessoes - usar hub window
if app.get_webview_window(HUB_WINDOW_LABEL).is_none() {
// Hub nao existe - criar minimizado
let _ = open_hub_window(app);
} else {
- // Hub ja existe - verificar se esta minimizado
+ // Hub ja existe - apenas mostrar (sem verificar tamanho para evitar bloqueio)
if let Some(hub) = app.get_webview_window(HUB_WINDOW_LABEL) {
let _ = hub.show();
- if let Ok(size) = hub.inner_size() {
- if size.height < 100 {
- // Esta minimizado, manter assim
- let _ = set_hub_minimized(app, true);
- }
- }
}
}
} else {
@@ -1035,19 +1030,8 @@ async fn process_chat_update(
if let Some(session) = session_to_show {
let label = format!("chat-{}", session.ticket_id);
if let Some(window) = app.get_webview_window(&label) {
- // Janela ja existe - apenas mostrar (NAO minimizar se estiver expandida)
- // Isso permite que o usuario mantenha o chat aberto enquanto recebe mensagens
+ // Janela ja existe - apenas mostrar (sem verificar tamanho para evitar bloqueio)
let _ = window.show();
- // Verificar se esta expandida (altura > 100px significa expandido)
- // Se estiver expandida, NAO minimizar - usuario esta usando o chat
- if let Ok(size) = window.inner_size() {
- let is_expanded = size.height > 100;
- if !is_expanded {
- // Janela esta minimizada, manter minimizada
- let _ = set_chat_minimized(app, &session.ticket_id, true);
- }
- // Se esta expandida, nao faz nada - deixa o usuario continuar usando
- }
} else {
// Criar nova janela ja minimizada (menos intrusivo)
let _ = open_chat_window_internal(app, &session.ticket_id, session.ticket_ref, true);
@@ -1170,7 +1154,7 @@ fn open_chat_window_with_state(app: &tauri::AppHandle, ticket_id: &str, ticket_r
.transparent(true) // Permite fundo transparente
.shadow(false) // Desabilitar sombra para transparencia funcionar corretamente
.resizable(false) // Desabilitar redimensionamento manual
- .always_on_top(true)
+ // REMOVIDO: always_on_top(true) causa competicao de Z-order com multiplas janelas
.skip_taskbar(true)
.focused(true)
.visible(true)
@@ -1273,7 +1257,7 @@ fn open_hub_window_with_state(app: &tauri::AppHandle, start_minimized: bool) ->
.transparent(true)
.shadow(false)
.resizable(false) // Desabilitar redimensionamento manual
- .always_on_top(true)
+ // REMOVIDO: always_on_top(true) causa competicao de Z-order com multiplas janelas
.skip_taskbar(true)
.focused(true)
.visible(true)
diff --git a/apps/desktop/src/chat/ChatHubWidget.tsx b/apps/desktop/src/chat/ChatHubWidget.tsx
index 0bc8a51..8d3da45 100644
--- a/apps/desktop/src/chat/ChatHubWidget.tsx
+++ b/apps/desktop/src/chat/ChatHubWidget.tsx
@@ -100,20 +100,11 @@ export function ChatHubWidget() {
}, [])
const handleSelectSession = async (ticketId: string, ticketRef: number) => {
- console.log("[ChatHub] Selecionando sessao:", { ticketId, ticketRef })
try {
- console.log("[ChatHub] Chamando invoke open_chat_window...")
// Tauri 2 espera snake_case nos parametros
- const result = await invoke("open_chat_window", { ticket_id: ticketId, ticket_ref: ticketRef })
- console.log("[ChatHub] Janela aberta com sucesso, result:", result)
+ await invoke("open_chat_window", { ticket_id: ticketId, ticket_ref: ticketRef })
} catch (err) {
- console.error("[ChatHub] ERRO ao abrir janela de chat:", err)
- console.error("[ChatHub] Tipo do erro:", typeof err, err)
- // Tentar mostrar mais detalhes do erro
- if (err instanceof Error) {
- console.error("[ChatHub] Message:", err.message)
- console.error("[ChatHub] Stack:", err.stack)
- }
+ console.error("Erro ao abrir janela de chat:", err)
}
}
diff --git a/apps/desktop/src/chat/ChatSessionItem.tsx b/apps/desktop/src/chat/ChatSessionItem.tsx
index 2c7bd77..142fef7 100644
--- a/apps/desktop/src/chat/ChatSessionItem.tsx
+++ b/apps/desktop/src/chat/ChatSessionItem.tsx
@@ -29,7 +29,6 @@ export function ChatSessionItem({ session, isActive, onClick }: ChatSessionItemP
const hasUnread = session.unreadCount > 0
const handleClick = () => {
- console.log("[ChatSessionItem] Clicado:", session.ticketId, session.ticketRef)
onClick()
}
diff --git a/apps/desktop/src/chat/ChatSessionList.tsx b/apps/desktop/src/chat/ChatSessionList.tsx
index a1879d6..d7d2386 100644
--- a/apps/desktop/src/chat/ChatSessionList.tsx
+++ b/apps/desktop/src/chat/ChatSessionList.tsx
@@ -85,19 +85,13 @@ export function ChatSessionList({
) : (
- sortedSessions.map((session) => {
- console.log("[ChatSessionList] Sessao:", session)
- return (
+ sortedSessions.map((session) => (
{
- console.log("[ChatSessionList] Clicando na sessao:", session.ticketId, session.ticketRef)
- onSelectSession(session.ticketId, session.ticketRef)
- }}
+ onClick={() => onSelectSession(session.ticketId, session.ticketRef)}
/>
- )
- })
+ ))
)}