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