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:
parent
d00c59e0b5
commit
2f89fa33fe
2 changed files with 12 additions and 2 deletions
|
|
@ -2,9 +2,12 @@ import { useCallback, useEffect, useRef, useState } from "react"
|
||||||
import { invoke } from "@tauri-apps/api/core"
|
import { invoke } from "@tauri-apps/api/core"
|
||||||
import { listen } from "@tauri-apps/api/event"
|
import { listen } from "@tauri-apps/api/event"
|
||||||
import { Store } from "@tauri-apps/plugin-store"
|
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 { Send, X, Minus, Loader2, Headphones } from "lucide-react"
|
||||||
import type { ChatMessage, ChatMessagesResponse, SendMessageResponse } from "./types"
|
import type { ChatMessage, ChatMessagesResponse, SendMessageResponse } from "./types"
|
||||||
|
|
||||||
|
const STORE_FILENAME = "machine-agent.json"
|
||||||
|
|
||||||
interface ChatWidgetProps {
|
interface ChatWidgetProps {
|
||||||
ticketId: string
|
ticketId: string
|
||||||
}
|
}
|
||||||
|
|
@ -34,7 +37,9 @@ export function ChatWidget({ ticketId }: ChatWidgetProps) {
|
||||||
// Carregar configuracao do store
|
// Carregar configuracao do store
|
||||||
const loadConfig = useCallback(async () => {
|
const loadConfig = useCallback(async () => {
|
||||||
try {
|
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 token = await store.get<string>("token")
|
||||||
const config = await store.get<{ apiBaseUrl: string }>("config")
|
const config = await store.get<{ apiBaseUrl: string }>("config")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
import { useCallback, useEffect, useRef, useState } from "react"
|
import { useCallback, useEffect, useRef, useState } from "react"
|
||||||
import { invoke } from "@tauri-apps/api/core"
|
import { invoke } from "@tauri-apps/api/core"
|
||||||
import { Store } from "@tauri-apps/plugin-store"
|
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 { MessageCircle, X, Minus, Send, Loader2, ChevronLeft, ChevronDown, ChevronRight } from "lucide-react"
|
||||||
import { cn } from "../lib/utils"
|
import { cn } from "../lib/utils"
|
||||||
import type { ChatSession, ChatMessage, ChatMessagesResponse, SendMessageResponse, ChatHistorySession } from "../chat/types"
|
import type { ChatSession, ChatMessage, ChatMessagesResponse, SendMessageResponse, ChatHistorySession } from "../chat/types"
|
||||||
|
|
||||||
|
const STORE_FILENAME = "machine-agent.json"
|
||||||
|
|
||||||
interface ChatFloatingWidgetProps {
|
interface ChatFloatingWidgetProps {
|
||||||
sessions: ChatSession[]
|
sessions: ChatSession[]
|
||||||
totalUnread: number
|
totalUnread: number
|
||||||
|
|
@ -53,7 +56,9 @@ export function ChatFloatingWidget({
|
||||||
// Carregar configuracao do store
|
// Carregar configuracao do store
|
||||||
const loadConfig = useCallback(async () => {
|
const loadConfig = useCallback(async () => {
|
||||||
try {
|
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 token = await store.get<string>("token")
|
||||||
const config = await store.get<{ apiBaseUrl: string }>("config")
|
const config = await store.get<{ apiBaseUrl: string }>("config")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue