Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: fix remote avatar broken in desktop again (#8688)

Bryan41b4363802af
diff --git a/src/features/ChatItem/index.tsx b/src/features/ChatItem/index.tsx
index 0d54bf6d5e7..35250ed119a 100644
--- a/src/features/ChatItem/index.tsx
+++ b/src/features/ChatItem/index.tsx
@@ -2,16 +2,39 @@
import { ChatItemProps, ChatItem as ChatItemRaw } from '@lobehub/ui/chat';
import isEqual from 'fast-deep-equal';
-import { memo } from 'react';
+import { memo, useMemo } from 'react';
+import { isDesktop } from '@/const/version';
+import { useElectronStore } from '@/store/electron';
+import { electronSyncSelectors } from '@/store/electron/selectors';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
-const ChatItem = memo<ChatItemProps>(({ markdownProps = {}, ...rest }) => {
+const ChatItem = memo<ChatItemProps>(({ markdownProps = {}, avatar, ...rest }) => {
const { componentProps, ...restMarkdown } = markdownProps;
const { general } = useUserStore(settingsSelectors.currentSettings, isEqual);
+
+ const remoteServerUrl = useElectronStore(electronSyncSelectors.remoteServerUrl);
+ const processedAvatar = useMemo(() => {
+ // only process avatar in desktop environment and when avatar url starts with /
+ if (
+ !isDesktop ||
+ !remoteServerUrl ||
+ !avatar.avatar ||
+ typeof avatar.avatar !== 'string' ||
+ !avatar.avatar.startsWith('/')
+ )
+ return avatar;
+
+ return {
+ ...avatar,
+ avatar: remoteServerUrl + avatar.avatar, // prepend the remote server URL
+ };
+ }, [avatar, remoteServerUrl]);
+
return (
<ChatItemRaw
+ avatar={processedAvatar}
fontSize={general.fontSize}
markdownProps={{
...restMarkdown,