From 3b6b9dfeacbed888206a491e191781beeeb57980 Mon Sep 17 00:00:00 2001 From: rever-tecnologia Date: Mon, 15 Dec 2025 14:24:01 -0300 Subject: [PATCH] =?UTF-8?q?fix(desktop):=20corrige=20par=C3=A2metros=20inv?= =?UTF-8?q?oke=20para=20snake=5Fcase=20no=20Tauri=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tauri 2 espera parâmetros em snake_case nos comandos Rust. Corrigido: ticketId -> ticket_id, ticketRef -> ticket_ref, etc. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- apps/desktop/src/chat/ChatHubWidget.tsx | 3 ++- apps/desktop/src/chat/ChatWidget.tsx | 18 +++++++++--------- apps/desktop/src/main.tsx | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/apps/desktop/src/chat/ChatHubWidget.tsx b/apps/desktop/src/chat/ChatHubWidget.tsx index 8722add..0bc8a51 100644 --- a/apps/desktop/src/chat/ChatHubWidget.tsx +++ b/apps/desktop/src/chat/ChatHubWidget.tsx @@ -103,7 +103,8 @@ export function ChatHubWidget() { console.log("[ChatHub] Selecionando sessao:", { ticketId, ticketRef }) try { console.log("[ChatHub] Chamando invoke open_chat_window...") - const result = await invoke("open_chat_window", { ticketId, ticketRef }) + // 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) } catch (err) { console.error("[ChatHub] ERRO ao abrir janela de chat:", err) diff --git a/apps/desktop/src/chat/ChatWidget.tsx b/apps/desktop/src/chat/ChatWidget.tsx index e4964fc..7686b9d 100644 --- a/apps/desktop/src/chat/ChatWidget.tsx +++ b/apps/desktop/src/chat/ChatWidget.tsx @@ -292,7 +292,7 @@ export function ChatWidget({ ticketId, ticketRef }: ChatWidgetProps) { useEffect(() => { const prevHasSession = prevHasSessionRef.current if (prevHasSession && !hasSession) { - invoke("close_chat_window", { ticketId }).catch((err) => { + invoke("close_chat_window", { ticket_id: ticketId }).catch((err) => { console.error("Erro ao fechar janela ao encerrar sessão:", err) }) } @@ -405,10 +405,10 @@ export function ChatWidget({ ticketId, ticketRef }: ChatWidgetProps) { for (const chunk of chunks) { await invoke("mark_chat_messages_read", { - baseUrl: cfg.apiBaseUrl, + base_url: cfg.apiBaseUrl, token: cfg.token, - ticketId, - messageIds: chunk, + ticket_id: ticketId, + message_ids: chunk, }) } @@ -657,9 +657,9 @@ export function ChatWidget({ ticketId, ticketRef }: ChatWidgetProps) { const bodyToSend = messageText const cfg = await ensureConfig() await invoke("send_chat_message", { - baseUrl: cfg.apiBaseUrl, + base_url: cfg.apiBaseUrl, token: cfg.token, - ticketId, + ticket_id: ticketId, body: bodyToSend, attachments: attachmentsToSend.length > 0 ? attachmentsToSend : undefined, }) @@ -692,7 +692,7 @@ export function ChatWidget({ ticketId, ticketRef }: ChatWidgetProps) { const handleMinimize = async () => { setIsMinimized(true) try { - await invoke("set_chat_minimized", { ticketId, minimized: true }) + await invoke("set_chat_minimized", { ticket_id: ticketId, minimized: true }) } catch (err) { console.error("Erro ao minimizar janela:", err) } @@ -707,14 +707,14 @@ export function ChatWidget({ ticketId, ticketRef }: ChatWidgetProps) { setIsMinimized(false) try { - await invoke("set_chat_minimized", { ticketId, minimized: false }) + await invoke("set_chat_minimized", { ticket_id: ticketId, minimized: false }) } catch (err) { console.error("Erro ao expandir janela:", err) } } const handleClose = () => { - invoke("close_chat_window", { ticketId }) + invoke("close_chat_window", { ticket_id: ticketId }) } const handleKeyDown = (e: React.KeyboardEvent) => { diff --git a/apps/desktop/src/main.tsx b/apps/desktop/src/main.tsx index fe95677..b8b2df0 100644 --- a/apps/desktop/src/main.tsx +++ b/apps/desktop/src/main.tsx @@ -1101,9 +1101,9 @@ const resolvedAppUrl = useMemo(() => { // Abre/minimiza chat quando aparecem novas não lidas if (hasSessions && totalUnread > prevUnread) { const session = payload.sessions[0] - invoke("open_chat_window", { ticketId: session.ticketId, ticketRef: session.ticketRef }).catch(console.error) + invoke("open_chat_window", { ticket_id: session.ticketId, ticket_ref: session.ticketRef }).catch(console.error) // Minimiza para não ser intrusivo - invoke("set_chat_minimized", { ticketId: session.ticketId, minimized: true }).catch(console.error) + invoke("set_chat_minimized", { ticket_id: session.ticketId, minimized: true }).catch(console.error) } prevUnread = totalUnread