fix(desktop): corrige parâmetros invoke para snake_case no Tauri 2

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 <noreply@anthropic.com>
This commit is contained in:
rever-tecnologia 2025-12-15 14:24:01 -03:00
parent 915ca6d8ff
commit 3b6b9dfeac
3 changed files with 13 additions and 12 deletions

View file

@ -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)

View file

@ -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) => {

View file

@ -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