Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 80fb496

Browse files
authored
🐛 fix(share): shared group topic not show avatar (lobehub#11894)
1 parent 9da1354 commit 80fb496

File tree

9 files changed

+87
-7
lines changed

9 files changed

+87
-7
lines changed

locales/ja-JP/error.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"response.InvalidComfyUIArgs": "ComfyUI 設定が正しくありません。設定を確認してから再試行してください",
9595
"response.InvalidGithubToken": "GitHub PAT が空または正しくありません。確認してから再試行してください",
9696
"response.InvalidOllamaArgs": "Ollama 設定が正しくありません。設定を確認してから再試行してください",
97-
"response.InvalidProviderAPIKey": "LobeHub API Key が空または正しくありません。確認してから再試行してください",
97+
"response.InvalidProviderAPIKey": "{{provider}} API Key が空または正しくありません。{{provider}} API Key を確認してから再試行してください",
9898
"response.InvalidVertexCredentials": "Vertex 認証に失敗しました。認証情報を確認してから再試行してください",
9999
"response.LocationNotSupportError": "現在の地域ではこのモデルサービスはサポートされていません(地域制限またはサービス未开通)。利用可能な地域に切り替えるか、別のモデルプロバイダーに変更してから再試行してください",
100100
"response.ModelNotFound": "利用可能なモデルが見つからないかアクセス権限がありません。API キーを切り替えるか、権限を調整してから再試行してください",

locales/ko-KR/error.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"response.InvalidComfyUIArgs": "ComfyUI 설정이 올바르지 않습니다. 설정을 확인한 후 다시 시도하세요",
9595
"response.InvalidGithubToken": "GitHub PAT가 비어 있거나 올바르지 않습니다. 확인한 후 다시 시도하세요",
9696
"response.InvalidOllamaArgs": "Ollama 설정이 올바르지 않습니다. 설정을 확인한 후 다시 시도하세요",
97-
"response.InvalidProviderAPIKey": "LobeHub API Key가 비어 있거나 올바르지 않습니다. 확인한 후 다시 시도하세요",
97+
"response.InvalidProviderAPIKey": "{{provider}} API Key가 비어 있거나 올바르지 않습니다. {{provider}} API Key를 확인한 후 다시 시도하세요",
9898
"response.InvalidVertexCredentials": "Vertex 인증에 실패했습니다. 인증 정보를 확인한 후 다시 시도하세요",
9999
"response.LocationNotSupportError": "현재 지역에서는 이 모델 서비스가 지원되지 않습니다(지역 제한 또는 서비스 미개통). 지원 가능한 지역으로 전환하거나 다른 모델 제공자로 변경한 후 다시 시도하세요",
100100
"response.ModelNotFound": "사용 가능한 모델을 찾을 수 없거나 액세스 권한이 없습니다. API 키를 전환하거나 권한을 조정한 후 다시 시도하세요",

locales/zh-CN/error.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"response.InvalidComfyUIArgs": "ComfyUI 配置不正确。请检查配置后重试",
9595
"response.InvalidGithubToken": "GitHub PAT 为空或不正确。请检查后重试",
9696
"response.InvalidOllamaArgs": "Ollama 配置不正确。请检查配置后重试",
97-
"response.InvalidProviderAPIKey": "LobeHub API Key 为空或不正确。请检查后重试",
97+
"response.InvalidProviderAPIKey": "{{provider}} API Key 为空或不正确,请检查 {{provider}} API Key 后重试",
9898
"response.InvalidVertexCredentials": "Vertex 鉴权失败。请检查凭证后重试",
9999
"response.LocationNotSupportError": "当前地区暂不支持该模型服务(可能受区域限制或服务未开通)。请切换可用地区或更换模型服务商后重试",
100100
"response.ModelNotFound": "未找到可用模型或无访问权限。请更换 API Key 或调整权限后重试",

packages/database/src/models/topicShare.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,11 @@ export class TopicShareModel {
106106
agentTitle: agents.title,
107107
groupAvatar: chatGroups.avatar,
108108
groupBackgroundColor: chatGroups.backgroundColor,
109+
groupCreatedAt: chatGroups.createdAt,
109110
groupId: topics.groupId,
110111
groupTitle: chatGroups.title,
112+
groupUpdatedAt: chatGroups.updatedAt,
113+
groupUserId: chatGroups.userId,
111114
ownerId: topicShares.userId,
112115
shareId: topicShares.id,
113116
title: topics.title,
@@ -126,12 +129,16 @@ export class TopicShareModel {
126129
const share = result[0];
127130

128131
// Fetch group members if this is a group topic
129-
let groupMembers: { avatar: string | null; backgroundColor: string | null }[] | undefined;
132+
let groupMembers:
133+
| { avatar: string | null; backgroundColor: string | null; id: string; title: string | null }[]
134+
| undefined;
130135
if (share.groupId) {
131136
const members = await db
132137
.select({
133138
avatar: agents.avatar,
134139
backgroundColor: agents.backgroundColor,
140+
id: agents.id,
141+
title: agents.title,
135142
})
136143
.from(chatGroupsAgents)
137144
.innerJoin(agents, eq(chatGroupsAgents.agentId, agents.id))

packages/types/src/agent/item.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { LobeAgentTTSConfig } from './tts';
88

99
export interface LobeAgentConfig {
1010
avatar?: string;
11+
backgroundColor?: string;
1112

1213
chatConfig: LobeAgentChatConfig;
1314

@@ -59,6 +60,11 @@ export interface LobeAgentConfig {
5960
*/
6061
systemRole: string;
6162

63+
/**
64+
* Agent title/name
65+
*/
66+
title?: string;
67+
6268
/**
6369
* Text-to-speech service
6470
*/

packages/types/src/topic/topic.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@ export interface SharedTopicData {
155155
groupMeta?: {
156156
avatar?: string | null;
157157
backgroundColor?: string | null;
158-
members?: { avatar: string | null; backgroundColor: string | null }[];
158+
createdAt?: Date | null;
159+
members?: { avatar: string | null; backgroundColor: string | null; id: string; title: string | null }[];
159160
title?: string | null;
161+
updatedAt?: Date | null;
162+
userId?: string | null;
160163
};
161164
shareId: string;
162165
title: string | null;

src/app/[variants]/share/t/[id]/_layout/Title.tsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client';
22

3+
import type { AgentGroupDetail, AgentGroupMember } from '@lobechat/types';
34
import { Text } from '@lobehub/ui';
45
import { memo, useEffect } from 'react';
56
import { useParams } from 'react-router-dom';
@@ -8,6 +9,7 @@ import useSWR from 'swr';
89
import PageTitle from '@/components/PageTitle';
910
import { lambdaClient } from '@/libs/trpc/client';
1011
import { useAgentStore } from '@/store/agent';
12+
import { useAgentGroupStore } from '@/store/agentGroup';
1113

1214
const Title = memo(() => {
1315
const { id } = useParams<{ id: string }>();
@@ -31,6 +33,53 @@ const Title = memo(() => {
3133
}
3234
}, [data?.agentId, data?.agentMeta, dispatchAgentMap]);
3335

36+
// Set group meta to agentGroupStore for group avatar display
37+
useEffect(() => {
38+
if (data?.groupId && data.groupMeta) {
39+
const members = data.groupMeta.members || [];
40+
41+
// Sync each member to agentStore for subagent avatar display
42+
for (const member of members) {
43+
dispatchAgentMap(member.id, {
44+
avatar: member.avatar ?? undefined,
45+
backgroundColor: member.backgroundColor ?? undefined,
46+
title: member.title ?? undefined,
47+
});
48+
}
49+
50+
// Build AgentGroupDetail for groupMap
51+
const groupDetail: AgentGroupDetail = {
52+
agents: members.map((m) => ({
53+
avatar: m.avatar,
54+
backgroundColor: m.backgroundColor,
55+
id: m.id,
56+
isSupervisor: false,
57+
title: m.title,
58+
})) as AgentGroupMember[],
59+
avatar: data.groupMeta.avatar,
60+
backgroundColor: data.groupMeta.backgroundColor,
61+
createdAt: data.groupMeta.createdAt ? new Date(data.groupMeta.createdAt) : new Date(),
62+
id: data.groupId,
63+
title: data.groupMeta.title,
64+
updatedAt: data.groupMeta.updatedAt ? new Date(data.groupMeta.updatedAt) : new Date(),
65+
userId: data.groupMeta.userId || '',
66+
};
67+
68+
// Set activeGroupId and update groupMap
69+
useAgentGroupStore.setState(
70+
(state) => ({
71+
activeGroupId: data.groupId!,
72+
groupMap: {
73+
...state.groupMap,
74+
[data.groupId!]: groupDetail,
75+
},
76+
}),
77+
false,
78+
'syncSharedGroupMeta',
79+
);
80+
}
81+
}, [data?.groupId, data?.groupMeta, dispatchAgentMap]);
82+
3483
return (
3584
data?.title && (
3685
<>

src/server/routers/lambda/__tests__/share.test.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ describe('shareRouter', () => {
2626
agentTitle: 'Test Agent',
2727
groupAvatar: null,
2828
groupBackgroundColor: null,
29+
groupCreatedAt: null,
2930
groupId: null,
3031
groupMembers: undefined,
3132
groupTitle: null,
33+
groupUpdatedAt: null,
34+
groupUserId: null,
3235
ownerId: 'user-1',
3336
shareId: 'share-123',
3437
title: 'Test Topic',
@@ -74,9 +77,12 @@ describe('shareRouter', () => {
7477
agentTitle: 'Test Agent Title',
7578
groupAvatar: null,
7679
groupBackgroundColor: null,
80+
groupCreatedAt: null,
7781
groupId: null,
7882
groupMembers: undefined,
7983
groupTitle: null,
84+
groupUpdatedAt: null,
85+
groupUserId: null,
8086
ownerId: 'user-1',
8187
shareId: 'share-123',
8288
title: 'Topic with Agent',
@@ -114,12 +120,15 @@ describe('shareRouter', () => {
114120
agentTitle: null,
115121
groupAvatar: 'group-avatar.png',
116122
groupBackgroundColor: '#000000',
123+
groupCreatedAt: new Date('2024-01-01'),
117124
groupId: 'group-1',
118125
groupMembers: [
119-
{ avatar: 'member1.png', backgroundColor: '#111' },
120-
{ avatar: 'member2.png', backgroundColor: '#222' },
126+
{ avatar: 'member1.png', backgroundColor: '#111', id: 'member-1', title: 'Member 1' },
127+
{ avatar: 'member2.png', backgroundColor: '#222', id: 'member-2', title: 'Member 2' },
121128
],
122129
groupTitle: 'Test Group',
130+
groupUpdatedAt: new Date('2024-01-02'),
131+
groupUserId: 'user-1',
123132
ownerId: 'user-1',
124133
shareId: 'share-456',
125134
title: 'Group Topic',
@@ -196,9 +205,12 @@ describe('shareRouter', () => {
196205
agentTitle: null,
197206
groupAvatar: null,
198207
groupBackgroundColor: null,
208+
groupCreatedAt: null,
199209
groupId: null,
200210
groupMembers: undefined,
201211
groupTitle: null,
212+
groupUpdatedAt: null,
213+
groupUserId: null,
202214
ownerId: 'owner-user',
203215
shareId: 'private-share',
204216
title: 'Private Topic',

src/server/routers/lambda/share.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ export const shareRouter = router({
4040
? {
4141
avatar: share.groupAvatar,
4242
backgroundColor: share.groupBackgroundColor,
43+
createdAt: share.groupCreatedAt,
4344
members: share.groupMembers,
4445
title: share.groupTitle,
46+
updatedAt: share.groupUpdatedAt,
47+
userId: share.groupUserId,
4548
}
4649
: undefined,
4750
shareId: share.shareId,

0 commit comments

Comments
 (0)