mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
🐛 fix(share): shared group topic not show avatar (#11894)
This commit is contained in:
@@ -94,7 +94,7 @@
|
||||
"response.InvalidComfyUIArgs": "ComfyUI 設定が正しくありません。設定を確認してから再試行してください",
|
||||
"response.InvalidGithubToken": "GitHub PAT が空または正しくありません。確認してから再試行してください",
|
||||
"response.InvalidOllamaArgs": "Ollama 設定が正しくありません。設定を確認してから再試行してください",
|
||||
"response.InvalidProviderAPIKey": "LobeHub API Key が空または正しくありません。確認してから再試行してください",
|
||||
"response.InvalidProviderAPIKey": "{{provider}} API Key が空または正しくありません。{{provider}} API Key を確認してから再試行してください",
|
||||
"response.InvalidVertexCredentials": "Vertex 認証に失敗しました。認証情報を確認してから再試行してください",
|
||||
"response.LocationNotSupportError": "現在の地域ではこのモデルサービスはサポートされていません(地域制限またはサービス未开通)。利用可能な地域に切り替えるか、別のモデルプロバイダーに変更してから再試行してください",
|
||||
"response.ModelNotFound": "利用可能なモデルが見つからないかアクセス権限がありません。API キーを切り替えるか、権限を調整してから再試行してください",
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
"response.InvalidComfyUIArgs": "ComfyUI 설정이 올바르지 않습니다. 설정을 확인한 후 다시 시도하세요",
|
||||
"response.InvalidGithubToken": "GitHub PAT가 비어 있거나 올바르지 않습니다. 확인한 후 다시 시도하세요",
|
||||
"response.InvalidOllamaArgs": "Ollama 설정이 올바르지 않습니다. 설정을 확인한 후 다시 시도하세요",
|
||||
"response.InvalidProviderAPIKey": "LobeHub API Key가 비어 있거나 올바르지 않습니다. 확인한 후 다시 시도하세요",
|
||||
"response.InvalidProviderAPIKey": "{{provider}} API Key가 비어 있거나 올바르지 않습니다. {{provider}} API Key를 확인한 후 다시 시도하세요",
|
||||
"response.InvalidVertexCredentials": "Vertex 인증에 실패했습니다. 인증 정보를 확인한 후 다시 시도하세요",
|
||||
"response.LocationNotSupportError": "현재 지역에서는 이 모델 서비스가 지원되지 않습니다(지역 제한 또는 서비스 미개통). 지원 가능한 지역으로 전환하거나 다른 모델 제공자로 변경한 후 다시 시도하세요",
|
||||
"response.ModelNotFound": "사용 가능한 모델을 찾을 수 없거나 액세스 권한이 없습니다. API 키를 전환하거나 권한을 조정한 후 다시 시도하세요",
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
"response.InvalidComfyUIArgs": "ComfyUI 配置不正确。请检查配置后重试",
|
||||
"response.InvalidGithubToken": "GitHub PAT 为空或不正确。请检查后重试",
|
||||
"response.InvalidOllamaArgs": "Ollama 配置不正确。请检查配置后重试",
|
||||
"response.InvalidProviderAPIKey": "LobeHub API Key 为空或不正确。请检查后重试",
|
||||
"response.InvalidProviderAPIKey": "{{provider}} API Key 为空或不正确,请检查 {{provider}} API Key 后重试",
|
||||
"response.InvalidVertexCredentials": "Vertex 鉴权失败。请检查凭证后重试",
|
||||
"response.LocationNotSupportError": "当前地区暂不支持该模型服务(可能受区域限制或服务未开通)。请切换可用地区或更换模型服务商后重试",
|
||||
"response.ModelNotFound": "未找到可用模型或无访问权限。请更换 API Key 或调整权限后重试",
|
||||
|
||||
@@ -106,8 +106,11 @@ export class TopicShareModel {
|
||||
agentTitle: agents.title,
|
||||
groupAvatar: chatGroups.avatar,
|
||||
groupBackgroundColor: chatGroups.backgroundColor,
|
||||
groupCreatedAt: chatGroups.createdAt,
|
||||
groupId: topics.groupId,
|
||||
groupTitle: chatGroups.title,
|
||||
groupUpdatedAt: chatGroups.updatedAt,
|
||||
groupUserId: chatGroups.userId,
|
||||
ownerId: topicShares.userId,
|
||||
shareId: topicShares.id,
|
||||
title: topics.title,
|
||||
@@ -126,12 +129,16 @@ export class TopicShareModel {
|
||||
const share = result[0];
|
||||
|
||||
// Fetch group members if this is a group topic
|
||||
let groupMembers: { avatar: string | null; backgroundColor: string | null }[] | undefined;
|
||||
let groupMembers:
|
||||
| { avatar: string | null; backgroundColor: string | null; id: string; title: string | null }[]
|
||||
| undefined;
|
||||
if (share.groupId) {
|
||||
const members = await db
|
||||
.select({
|
||||
avatar: agents.avatar,
|
||||
backgroundColor: agents.backgroundColor,
|
||||
id: agents.id,
|
||||
title: agents.title,
|
||||
})
|
||||
.from(chatGroupsAgents)
|
||||
.innerJoin(agents, eq(chatGroupsAgents.agentId, agents.id))
|
||||
|
||||
@@ -8,6 +8,7 @@ import { LobeAgentTTSConfig } from './tts';
|
||||
|
||||
export interface LobeAgentConfig {
|
||||
avatar?: string;
|
||||
backgroundColor?: string;
|
||||
|
||||
chatConfig: LobeAgentChatConfig;
|
||||
|
||||
@@ -59,6 +60,11 @@ export interface LobeAgentConfig {
|
||||
*/
|
||||
systemRole: string;
|
||||
|
||||
/**
|
||||
* Agent title/name
|
||||
*/
|
||||
title?: string;
|
||||
|
||||
/**
|
||||
* Text-to-speech service
|
||||
*/
|
||||
|
||||
@@ -155,8 +155,11 @@ export interface SharedTopicData {
|
||||
groupMeta?: {
|
||||
avatar?: string | null;
|
||||
backgroundColor?: string | null;
|
||||
members?: { avatar: string | null; backgroundColor: string | null }[];
|
||||
createdAt?: Date | null;
|
||||
members?: { avatar: string | null; backgroundColor: string | null; id: string; title: string | null }[];
|
||||
title?: string | null;
|
||||
updatedAt?: Date | null;
|
||||
userId?: string | null;
|
||||
};
|
||||
shareId: string;
|
||||
title: string | null;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import type { AgentGroupDetail, AgentGroupMember } from '@lobechat/types';
|
||||
import { Text } from '@lobehub/ui';
|
||||
import { memo, useEffect } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
@@ -8,6 +9,7 @@ import useSWR from 'swr';
|
||||
import PageTitle from '@/components/PageTitle';
|
||||
import { lambdaClient } from '@/libs/trpc/client';
|
||||
import { useAgentStore } from '@/store/agent';
|
||||
import { useAgentGroupStore } from '@/store/agentGroup';
|
||||
|
||||
const Title = memo(() => {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
@@ -31,6 +33,53 @@ const Title = memo(() => {
|
||||
}
|
||||
}, [data?.agentId, data?.agentMeta, dispatchAgentMap]);
|
||||
|
||||
// Set group meta to agentGroupStore for group avatar display
|
||||
useEffect(() => {
|
||||
if (data?.groupId && data.groupMeta) {
|
||||
const members = data.groupMeta.members || [];
|
||||
|
||||
// Sync each member to agentStore for subagent avatar display
|
||||
for (const member of members) {
|
||||
dispatchAgentMap(member.id, {
|
||||
avatar: member.avatar ?? undefined,
|
||||
backgroundColor: member.backgroundColor ?? undefined,
|
||||
title: member.title ?? undefined,
|
||||
});
|
||||
}
|
||||
|
||||
// Build AgentGroupDetail for groupMap
|
||||
const groupDetail: AgentGroupDetail = {
|
||||
agents: members.map((m) => ({
|
||||
avatar: m.avatar,
|
||||
backgroundColor: m.backgroundColor,
|
||||
id: m.id,
|
||||
isSupervisor: false,
|
||||
title: m.title,
|
||||
})) as AgentGroupMember[],
|
||||
avatar: data.groupMeta.avatar,
|
||||
backgroundColor: data.groupMeta.backgroundColor,
|
||||
createdAt: data.groupMeta.createdAt ? new Date(data.groupMeta.createdAt) : new Date(),
|
||||
id: data.groupId,
|
||||
title: data.groupMeta.title,
|
||||
updatedAt: data.groupMeta.updatedAt ? new Date(data.groupMeta.updatedAt) : new Date(),
|
||||
userId: data.groupMeta.userId || '',
|
||||
};
|
||||
|
||||
// Set activeGroupId and update groupMap
|
||||
useAgentGroupStore.setState(
|
||||
(state) => ({
|
||||
activeGroupId: data.groupId!,
|
||||
groupMap: {
|
||||
...state.groupMap,
|
||||
[data.groupId!]: groupDetail,
|
||||
},
|
||||
}),
|
||||
false,
|
||||
'syncSharedGroupMeta',
|
||||
);
|
||||
}
|
||||
}, [data?.groupId, data?.groupMeta, dispatchAgentMap]);
|
||||
|
||||
return (
|
||||
data?.title && (
|
||||
<>
|
||||
|
||||
@@ -26,9 +26,12 @@ describe('shareRouter', () => {
|
||||
agentTitle: 'Test Agent',
|
||||
groupAvatar: null,
|
||||
groupBackgroundColor: null,
|
||||
groupCreatedAt: null,
|
||||
groupId: null,
|
||||
groupMembers: undefined,
|
||||
groupTitle: null,
|
||||
groupUpdatedAt: null,
|
||||
groupUserId: null,
|
||||
ownerId: 'user-1',
|
||||
shareId: 'share-123',
|
||||
title: 'Test Topic',
|
||||
@@ -74,9 +77,12 @@ describe('shareRouter', () => {
|
||||
agentTitle: 'Test Agent Title',
|
||||
groupAvatar: null,
|
||||
groupBackgroundColor: null,
|
||||
groupCreatedAt: null,
|
||||
groupId: null,
|
||||
groupMembers: undefined,
|
||||
groupTitle: null,
|
||||
groupUpdatedAt: null,
|
||||
groupUserId: null,
|
||||
ownerId: 'user-1',
|
||||
shareId: 'share-123',
|
||||
title: 'Topic with Agent',
|
||||
@@ -114,12 +120,15 @@ describe('shareRouter', () => {
|
||||
agentTitle: null,
|
||||
groupAvatar: 'group-avatar.png',
|
||||
groupBackgroundColor: '#000000',
|
||||
groupCreatedAt: new Date('2024-01-01'),
|
||||
groupId: 'group-1',
|
||||
groupMembers: [
|
||||
{ avatar: 'member1.png', backgroundColor: '#111' },
|
||||
{ avatar: 'member2.png', backgroundColor: '#222' },
|
||||
{ avatar: 'member1.png', backgroundColor: '#111', id: 'member-1', title: 'Member 1' },
|
||||
{ avatar: 'member2.png', backgroundColor: '#222', id: 'member-2', title: 'Member 2' },
|
||||
],
|
||||
groupTitle: 'Test Group',
|
||||
groupUpdatedAt: new Date('2024-01-02'),
|
||||
groupUserId: 'user-1',
|
||||
ownerId: 'user-1',
|
||||
shareId: 'share-456',
|
||||
title: 'Group Topic',
|
||||
@@ -196,9 +205,12 @@ describe('shareRouter', () => {
|
||||
agentTitle: null,
|
||||
groupAvatar: null,
|
||||
groupBackgroundColor: null,
|
||||
groupCreatedAt: null,
|
||||
groupId: null,
|
||||
groupMembers: undefined,
|
||||
groupTitle: null,
|
||||
groupUpdatedAt: null,
|
||||
groupUserId: null,
|
||||
ownerId: 'owner-user',
|
||||
shareId: 'private-share',
|
||||
title: 'Private Topic',
|
||||
|
||||
@@ -40,8 +40,11 @@ export const shareRouter = router({
|
||||
? {
|
||||
avatar: share.groupAvatar,
|
||||
backgroundColor: share.groupBackgroundColor,
|
||||
createdAt: share.groupCreatedAt,
|
||||
members: share.groupMembers,
|
||||
title: share.groupTitle,
|
||||
updatedAt: share.groupUpdatedAt,
|
||||
userId: share.groupUserId,
|
||||
}
|
||||
: undefined,
|
||||
shareId: share.shareId,
|
||||
|
||||
Reference in New Issue
Block a user