mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-05-28 01:25:54 +00:00
refactor(ChatBox): use Host abstraction for Electron APIs
Use useHost() for file selection and opening skill folders instead of window.electronAPI. Made-with: Cursor
This commit is contained in:
parent
ae753dc7cd
commit
43ee2b7b53
2 changed files with 6 additions and 2 deletions
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -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<string>('');
|
||||
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: ['*'] }],
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue