fix(desktop): use correct store path in chat widgets

ChatWidget and ChatFloatingWidget were using relative path
"machine-agent.json" instead of the full path with appLocalDataDir().
This caused "Maquina nao registrada" error in chat window.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
esdrasrenan 2025-12-07 12:46:32 -03:00
parent d00c59e0b5
commit 2f89fa33fe
2 changed files with 12 additions and 2 deletions

View file

@ -2,9 +2,12 @@ import { useCallback, useEffect, useRef, useState } from "react"
import { invoke } from "@tauri-apps/api/core"
import { listen } from "@tauri-apps/api/event"
import { Store } from "@tauri-apps/plugin-store"
import { appLocalDataDir, join } from "@tauri-apps/api/path"
import { Send, X, Minus, Loader2, Headphones } from "lucide-react"
import type { ChatMessage, ChatMessagesResponse, SendMessageResponse } from "./types"
const STORE_FILENAME = "machine-agent.json"
interface ChatWidgetProps {
ticketId: string
}
@ -34,7 +37,9 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
// Carregar configuracao do store
const loadConfig = useCallback(async () => {
try {
const store = await Store.load("machine-agent.json")
const appData = await appLocalDataDir()
const storePath = await join(appData, STORE_FILENAME)
const store = await Store.load(storePath)
const token = await store.get<string>("token")
const config = await store.get<{ apiBaseUrl: string }>("config")

View file

@ -1,10 +1,13 @@
import { useCallback, useEffect, useRef, useState } from "react"
import { invoke } from "@tauri-apps/api/core"
import { Store } from "@tauri-apps/plugin-store"
import { appLocalDataDir, join } from "@tauri-apps/api/path"
import { MessageCircle, X, Minus, Send, Loader2, ChevronLeft, ChevronDown, ChevronRight } from "lucide-react"
import { cn } from "../lib/utils"
import type { ChatSession, ChatMessage, ChatMessagesResponse, SendMessageResponse, ChatHistorySession } from "../chat/types"
const STORE_FILENAME = "machine-agent.json"
interface ChatFloatingWidgetProps {
sessions: ChatSession[]
totalUnread: number
@ -53,7 +56,9 @@ export function ChatFloatingWidget({
// Carregar configuracao do store
const loadConfig = useCallback(async () => {
try {
const store = await Store.load("machine-agent.json")
const appData = await appLocalDataDir()
const storePath = await join(appData, STORE_FILENAME)
const store = await Store.load(storePath)
const token = await store.get<string>("token")
const config = await store.get<{ apiBaseUrl: string }>("config")