fix(desktop): corrige travamento com múltiplos chats
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 <noreply@anthropic.com>
This commit is contained in:
parent
4ad0dc5c1e
commit
c7b6d78ec2
4 changed files with 10 additions and 42 deletions
|
|
@ -1001,21 +1001,16 @@ async fn process_chat_update(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Se ha multiplas sessoes ativas, usar o hub; senao, abrir janela do chat individual
|
// 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 {
|
if current_sessions.len() > 1 {
|
||||||
// Multiplas sessoes - usar hub window
|
// Multiplas sessoes - usar hub window
|
||||||
if app.get_webview_window(HUB_WINDOW_LABEL).is_none() {
|
if app.get_webview_window(HUB_WINDOW_LABEL).is_none() {
|
||||||
// Hub nao existe - criar minimizado
|
// Hub nao existe - criar minimizado
|
||||||
let _ = open_hub_window(app);
|
let _ = open_hub_window(app);
|
||||||
} else {
|
} 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) {
|
if let Some(hub) = app.get_webview_window(HUB_WINDOW_LABEL) {
|
||||||
let _ = hub.show();
|
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 {
|
} else {
|
||||||
|
|
@ -1035,19 +1030,8 @@ async fn process_chat_update(
|
||||||
if let Some(session) = session_to_show {
|
if let Some(session) = session_to_show {
|
||||||
let label = format!("chat-{}", session.ticket_id);
|
let label = format!("chat-{}", session.ticket_id);
|
||||||
if let Some(window) = app.get_webview_window(&label) {
|
if let Some(window) = app.get_webview_window(&label) {
|
||||||
// Janela ja existe - apenas mostrar (NAO minimizar se estiver expandida)
|
// Janela ja existe - apenas mostrar (sem verificar tamanho para evitar bloqueio)
|
||||||
// Isso permite que o usuario mantenha o chat aberto enquanto recebe mensagens
|
|
||||||
let _ = window.show();
|
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 {
|
} else {
|
||||||
// Criar nova janela ja minimizada (menos intrusivo)
|
// Criar nova janela ja minimizada (menos intrusivo)
|
||||||
let _ = open_chat_window_internal(app, &session.ticket_id, session.ticket_ref, true);
|
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
|
.transparent(true) // Permite fundo transparente
|
||||||
.shadow(false) // Desabilitar sombra para transparencia funcionar corretamente
|
.shadow(false) // Desabilitar sombra para transparencia funcionar corretamente
|
||||||
.resizable(false) // Desabilitar redimensionamento manual
|
.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)
|
.skip_taskbar(true)
|
||||||
.focused(true)
|
.focused(true)
|
||||||
.visible(true)
|
.visible(true)
|
||||||
|
|
@ -1273,7 +1257,7 @@ fn open_hub_window_with_state(app: &tauri::AppHandle, start_minimized: bool) ->
|
||||||
.transparent(true)
|
.transparent(true)
|
||||||
.shadow(false)
|
.shadow(false)
|
||||||
.resizable(false) // Desabilitar redimensionamento manual
|
.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)
|
.skip_taskbar(true)
|
||||||
.focused(true)
|
.focused(true)
|
||||||
.visible(true)
|
.visible(true)
|
||||||
|
|
|
||||||
|
|
@ -100,20 +100,11 @@ export function ChatHubWidget() {
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleSelectSession = async (ticketId: string, ticketRef: number) => {
|
const handleSelectSession = async (ticketId: string, ticketRef: number) => {
|
||||||
console.log("[ChatHub] Selecionando sessao:", { ticketId, ticketRef })
|
|
||||||
try {
|
try {
|
||||||
console.log("[ChatHub] Chamando invoke open_chat_window...")
|
|
||||||
// Tauri 2 espera snake_case nos parametros
|
// Tauri 2 espera snake_case nos parametros
|
||||||
const result = await invoke("open_chat_window", { ticket_id: ticketId, ticket_ref: ticketRef })
|
await invoke("open_chat_window", { ticket_id: ticketId, ticket_ref: ticketRef })
|
||||||
console.log("[ChatHub] Janela aberta com sucesso, result:", result)
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("[ChatHub] ERRO ao abrir janela de chat:", err)
|
console.error("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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ export function ChatSessionItem({ session, isActive, onClick }: ChatSessionItemP
|
||||||
const hasUnread = session.unreadCount > 0
|
const hasUnread = session.unreadCount > 0
|
||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
console.log("[ChatSessionItem] Clicado:", session.ticketId, session.ticketRef)
|
|
||||||
onClick()
|
onClick()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,19 +85,13 @@ export function ChatSessionList({
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
sortedSessions.map((session) => {
|
sortedSessions.map((session) => (
|
||||||
console.log("[ChatSessionList] Sessao:", session)
|
|
||||||
return (
|
|
||||||
<ChatSessionItem
|
<ChatSessionItem
|
||||||
key={session.ticketId}
|
key={session.ticketId}
|
||||||
session={session}
|
session={session}
|
||||||
onClick={() => {
|
onClick={() => onSelectSession(session.ticketId, session.ticketRef)}
|
||||||
console.log("[ChatSessionList] Clicando na sessao:", session.ticketId, session.ticketRef)
|
|
||||||
onSelectSession(session.ticketId, session.ticketRef)
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
)
|
))
|
||||||
})
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue