diff --git a/src/components/ChatBox/MessageItem/UserMessageRichContent.tsx b/src/components/ChatBox/MessageItem/UserMessageRichContent.tsx index adf30735..acadfe03 100644 --- a/src/components/ChatBox/MessageItem/UserMessageRichContent.tsx +++ b/src/components/ChatBox/MessageItem/UserMessageRichContent.tsx @@ -12,6 +12,7 @@ // limitations under the License. // ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. ========= +import { useHost } from '@/host'; import { RICH_SKILL_STYLE_CLASSES, hashSkillLabel, @@ -113,11 +114,12 @@ export function UserMessageRichContent({ variant = 'card', className, }: UserMessageRichContentProps) { + const host = useHost(); const contentNodes = parseContentWithTags(content); const handleOpenSkillFolder = (skillName: string) => { if (!isSafeSkillFolderName(skillName)) return; - window.electronAPI?.openSkillFolder?.(skillName); + host?.electronAPI?.openSkillFolder?.(skillName); }; const bodyClass = diff --git a/src/components/ChatBox/index.tsx b/src/components/ChatBox/index.tsx index 9a4a87bc..8cbc5e19 100644 --- a/src/components/ChatBox/index.tsx +++ b/src/components/ChatBox/index.tsx @@ -20,6 +20,7 @@ import { proxyFetchGet, } from '@/api/http'; import useChatStoreAdapter from '@/hooks/useChatStoreAdapter'; +import { useHost } from '@/host'; import { generateUniqueId } from '@/lib'; import { proxyUpdateTriggerExecution } from '@/service/triggerApi'; import { useAuthStore } from '@/store/authStore'; @@ -46,6 +47,7 @@ const CHAT_SCROLL_BOTTOM_MIN_PX = 128; const CHAT_SCROLL_BOTTOM_GAP_PX = 8; export default function ChatBox(): JSX.Element { const [message, setMessage] = useState(''); + const host = useHost(); //Get Chatstore for the active project's task const { chatStore, projectStore } = useChatStoreAdapter(); @@ -675,7 +677,7 @@ export default function ChatBox(): JSX.Element { // File selection handler const handleFileSelect = async () => { try { - const result = await window.electronAPI.selectFile({ + const result = await host?.electronAPI?.selectFile({ title: t('chat.select-file'), filters: [{ name: t('chat.all-files'), extensions: ['*'] }], });