diff --git a/apps/desktop/src-tauri/src/chat.rs b/apps/desktop/src-tauri/src/chat.rs
index 38f0385..d6ec9dc 100644
--- a/apps/desktop/src-tauri/src/chat.rs
+++ b/apps/desktop/src-tauri/src/chat.rs
@@ -818,26 +818,23 @@ async fn process_chat_update(
);
// Mostrar janela de chat minimizada (menos intrusivo que abrir completo)
+ // Só abre se a janela não existir - se usuário fechou, não reabre automaticamente
if let Some(session) = current_sessions.first() {
- // Abrir janela se nao existir
let label = format!("chat-{}", session.ticket_id);
if app.get_webview_window(&label).is_none() {
let _ = open_chat_window(app, &session.ticket_id);
- // Minimizar imediatamente apos abrir
+ // Minimizar imediatamente após abrir
let _ = set_chat_minimized(app, &session.ticket_id, true);
}
- // Se ja existe, apenas garantir que esta visivel (pode estar escondida)
- else if let Some(window) = app.get_webview_window(&label) {
- let _ = window.show();
- }
+ // Se janela já existe, não força reabrir - respeita decisão do usuário
}
// Notificacao nativa
let notification_title = "Nova mensagem de suporte";
let notification_body = if new_count == 1 {
- "Voce recebeu 1 nova mensagem no chat".to_string()
+ "Você recebeu 1 nova mensagem no chat".to_string()
} else {
- format!("Voce recebeu {} novas mensagens no chat", new_count)
+ format!("Você recebeu {} novas mensagens no chat", new_count)
};
let _ = app
.notification()
@@ -929,7 +926,7 @@ pub fn minimize_chat_window(app: &tauri::AppHandle, ticket_id: &str) -> Result<(
/// Redimensiona a janela de chat para modo minimizado (chip) ou expandido
pub fn set_chat_minimized(app: &tauri::AppHandle, ticket_id: &str, minimized: bool) -> Result<(), String> {
let label = format!("chat-{}", ticket_id);
- let window = app.get_webview_window(&label).ok_or("Janela nao encontrada")?;
+ let window = app.get_webview_window(&label).ok_or("Janela não encontrada")?;
// Tamanhos - chip minimizado com margem extra para badge (absolute -top-1 -right-1)
let (width, height) = if minimized {
diff --git a/apps/desktop/src/chat/ChatWidget.tsx b/apps/desktop/src/chat/ChatWidget.tsx
index 348c39f..9958919 100644
--- a/apps/desktop/src/chat/ChatWidget.tsx
+++ b/apps/desktop/src/chat/ChatWidget.tsx
@@ -302,7 +302,7 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
setMessages(prev => [...prev, {
id: response.messageId,
body: messageText || (attachmentsToSend.length > 0 ? "[Anexo]" : ""),
- authorName: "Voce",
+ authorName: "Você",
isFromMachine: true,
createdAt: response.createdAt,
attachments: attachmentsToSend.map(a => ({
diff --git a/apps/desktop/src/chat/index.tsx b/apps/desktop/src/chat/index.tsx
index afe7f7a..7e99526 100644
--- a/apps/desktop/src/chat/index.tsx
+++ b/apps/desktop/src/chat/index.tsx
@@ -8,7 +8,7 @@ export function ChatApp() {
if (!ticketId) {
return (
-
Erro: ticketId nao fornecido
+
Erro: ticketId não fornecido
)
}
diff --git a/apps/desktop/src/components/ChatFloatingWidget.tsx b/apps/desktop/src/components/ChatFloatingWidget.tsx
index c68f5f3..84161c1 100644
--- a/apps/desktop/src/components/ChatFloatingWidget.tsx
+++ b/apps/desktop/src/components/ChatFloatingWidget.tsx
@@ -172,7 +172,7 @@ export function ChatFloatingWidget({
setMessages(prev => [...prev, {
id: response.messageId,
body: messageText,
- authorName: "Voce",
+ authorName: "Você",
isFromMachine: true,
createdAt: response.createdAt,
attachments: [],
diff --git a/src/components/tickets/ticket-chat-panel.tsx b/src/components/tickets/ticket-chat-panel.tsx
index 98cb122..c5abc4c 100644
--- a/src/components/tickets/ticket-chat-panel.tsx
+++ b/src/components/tickets/ticket-chat-panel.tsx
@@ -138,7 +138,17 @@ export function TicketChatPanel({ ticketId }: TicketChatPanelProps) {
toast.info("Já existe uma sessão de chat ativa", { id: "live-chat" })
}
} catch (error: unknown) {
- const message = error instanceof Error ? error.message : "Não foi possível iniciar o chat"
+ console.error("[LiveChat] Erro ao iniciar chat:", error)
+ // Extrair mensagem amigável do erro do Convex
+ let message = "Não foi possível iniciar o chat"
+ if (error instanceof Error) {
+ const errorMsg = error.message.toLowerCase()
+ if (errorMsg.includes("offline")) {
+ message = "Máquina offline. Aguarde a máquina ficar online para iniciar o chat."
+ } else if (errorMsg.includes("não encontrad") || errorMsg.includes("not found")) {
+ message = "Máquina não encontrada"
+ }
+ }
toast.error(message, { id: "live-chat" })
} finally {
setIsStartingChat(false)
diff --git a/src/components/tickets/ticket-summary-header.tsx b/src/components/tickets/ticket-summary-header.tsx
index 7b136b6..fd1a1e7 100644
--- a/src/components/tickets/ticket-summary-header.tsx
+++ b/src/components/tickets/ticket-summary-header.tsx
@@ -351,12 +351,22 @@ export function TicketSummaryHeader({ ticket }: TicketHeaderProps) {
actorId: convexUserId as Id<"users">,
})
if (result.isNew) {
- toast.success("Chat ao vivo iniciado! O cliente será notificado.", { id: "live-chat" })
+ toast.success("Chat ao vivo iniciado", { id: "live-chat" })
} else {
- toast.info("Já existe uma sessão de chat ativa.", { id: "live-chat" })
+ toast.info("Já existe uma sessão de chat ativa", { id: "live-chat" })
}
} catch (error: unknown) {
- const message = error instanceof Error ? error.message : "Não foi possível iniciar o chat"
+ console.error("[LiveChat] Erro ao iniciar chat:", error)
+ // Extrair mensagem amigável do erro do Convex
+ let message = "Não foi possível iniciar o chat"
+ if (error instanceof Error) {
+ const errorMsg = error.message.toLowerCase()
+ if (errorMsg.includes("offline")) {
+ message = "Máquina offline. Aguarde a máquina ficar online para iniciar o chat."
+ } else if (errorMsg.includes("não encontrad") || errorMsg.includes("not found")) {
+ message = "Máquina não encontrada"
+ }
+ }
toast.error(message, { id: "live-chat" })
} finally {
setIsStartingChat(false)