Skip to content

Commit 5d115ef

Browse files
arvinxxclaude
andauthored
🐛 fix: fix favorite refresh bug and group topic refresh issue (lobehub#11745)
* fix memory i18n * fix history limit issue and favorite topic * fix tests * fix tests * fix tests * 🧪 test(chat): fix getChatCompletion second parameter assertion Update test assertions to use expect.anything() instead of undefined for the second parameter of getChatCompletion, as it now receives { agentId, topicId } context object. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix group topic * fix lobeai link --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 36bcc50 commit 5d115ef

File tree

24 files changed

+231
-210
lines changed

24 files changed

+231
-210
lines changed

locales/en-US/plugin.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@
177177
"builtins.lobe-user-memory.apiName.searchUserMemory": "Search memory",
178178
"builtins.lobe-user-memory.apiName.updateIdentityMemory": "Update identity memory",
179179
"builtins.lobe-user-memory.inspector.noResults": "No results",
180+
"builtins.lobe-user-memory.render.contexts": "Contexts",
181+
"builtins.lobe-user-memory.render.experiences": "Experiences",
182+
"builtins.lobe-user-memory.render.preferences": "Preferences",
180183
"builtins.lobe-user-memory.title": "Memory",
181184
"builtins.lobe-web-browsing.apiName.crawlMultiPages": "Read multiple pages",
182185
"builtins.lobe-web-browsing.apiName.crawlSinglePage": "Read page content",

locales/zh-CN/plugin.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@
177177
"builtins.lobe-user-memory.apiName.searchUserMemory": "搜索记忆",
178178
"builtins.lobe-user-memory.apiName.updateIdentityMemory": "更新身份记忆",
179179
"builtins.lobe-user-memory.inspector.noResults": "无结果",
180+
"builtins.lobe-user-memory.render.contexts": "情境",
181+
"builtins.lobe-user-memory.render.experiences": "经验",
182+
"builtins.lobe-user-memory.render.preferences": "偏好",
180183
"builtins.lobe-user-memory.title": "记忆",
181184
"builtins.lobe-web-browsing.apiName.crawlMultiPages": "读取多个页面内容",
182185
"builtins.lobe-web-browsing.apiName.crawlSinglePage": "读取页面内容",

packages/builtin-tool-memory/src/client/Render/SearchUserMemory/index.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { createStaticStyles } from 'antd-style';
66
import { memo } from 'react';
77
import { useTranslation } from 'react-i18next';
88

9-
import { highlightTextStyles } from '@/styles';
10-
119
import type { SearchMemoryParams, SearchUserMemoryState } from '../../../types';
1210

1311
const styles = createStaticStyles(({ css, cssVar }) => ({
@@ -120,9 +118,7 @@ const SearchUserMemoryRender = memo<BuiltinRenderProps<SearchMemoryParams, Searc
120118
paddingInline={12}
121119
title={
122120
<Text className={styles.sectionHeader}>
123-
<span className={highlightTextStyles.info}>
124-
{t('builtins.lobe-user-memory.render.contexts' as any)}
125-
</span>
121+
<span>{t('builtins.lobe-user-memory.render.contexts')}</span>
126122
<Text as={'span'} type={'secondary'}>
127123
{' '}
128124
({contexts.length})
@@ -152,9 +148,7 @@ const SearchUserMemoryRender = memo<BuiltinRenderProps<SearchMemoryParams, Searc
152148
paddingInline={12}
153149
title={
154150
<Text className={styles.sectionHeader}>
155-
<span className={highlightTextStyles.gold}>
156-
{t('builtins.lobe-user-memory.render.experiences' as any)}
157-
</span>
151+
<span>{t('builtins.lobe-user-memory.render.experiences')}</span>
158152
<Text as={'span'} type={'secondary'}>
159153
{' '}
160154
({experiences.length})
@@ -184,9 +178,7 @@ const SearchUserMemoryRender = memo<BuiltinRenderProps<SearchMemoryParams, Searc
184178
paddingInline={12}
185179
title={
186180
<Text className={styles.sectionHeader}>
187-
<span className={highlightTextStyles.warning}>
188-
{t('builtins.lobe-user-memory.render.preferences' as any)}
189-
</span>
181+
<span>{t('builtins.lobe-user-memory.render.preferences')}</span>
190182
<Text as={'span'} type={'secondary'}>
191183
{' '}
192184
({preferences.length})

packages/context-engine/src/engine/messages/MessagesEngine.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
GroupMessageFlattenProcessor,
1010
GroupOrchestrationFilterProcessor,
1111
GroupRoleTransformProcessor,
12-
HistoryTruncateProcessor,
1312
InputTemplateProcessor,
1413
MessageCleanupProcessor,
1514
MessageContentProcessor,
@@ -113,8 +112,6 @@ export class MessagesEngine {
113112
provider,
114113
systemRole,
115114
inputTemplate,
116-
enableHistoryCount,
117-
historyCount,
118115
historySummary,
119116
formatHistorySummary,
120117
knowledge,
@@ -145,16 +142,6 @@ export class MessagesEngine {
145142
const isGTDTodoEnabled = gtd?.enabled && gtd?.todos;
146143

147144
return [
148-
// =============================================
149-
// Phase 1: History Management
150-
// =============================================
151-
152-
// 1. History truncation (MUST be first, before any message injection)
153-
new HistoryTruncateProcessor({
154-
enableHistoryCount,
155-
historyCount,
156-
}),
157-
158145
// =============================================
159146
// Phase 2: System Role Injection
160147
// =============================================

packages/context-engine/src/engine/messages/__tests__/MessagesEngine.test.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -113,31 +113,6 @@ describe('MessagesEngine', () => {
113113
expect(result.messages[0].content).toBe(systemRole);
114114
});
115115

116-
it('should truncate history when enabled', async () => {
117-
const messages: UIChatMessage[] = [];
118-
for (let i = 0; i < 20; i++) {
119-
messages.push({
120-
content: `Message ${i}`,
121-
createdAt: Date.now(),
122-
id: `msg-${i}`,
123-
role: i % 2 === 0 ? 'user' : 'assistant',
124-
updatedAt: Date.now(),
125-
} as UIChatMessage);
126-
}
127-
128-
const params = createBasicParams({
129-
enableHistoryCount: true,
130-
historyCount: 5,
131-
messages,
132-
});
133-
const engine = new MessagesEngine(params);
134-
135-
const result = await engine.process();
136-
137-
// Should have truncated to 5 messages
138-
expect(result.messages.length).toBeLessThanOrEqual(5);
139-
});
140-
141116
it('should inject history summary when provided', async () => {
142117
const historySummary = 'We discussed AI and machine learning';
143118
const params = createBasicParams({ historySummary });

packages/database/src/models/__tests__/topics/topic.create.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { eq, inArray } from 'drizzle-orm';
1+
import { asc, eq, inArray } from 'drizzle-orm';
22
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
33

44
import { getTestDB } from '../../../core/getTestDB';
@@ -188,12 +188,12 @@ describe('TopicModel - Create', () => {
188188
userId,
189189
});
190190

191-
const items = await serverDB.select().from(topics);
191+
const items = await serverDB.select().from(topics).orderBy(asc(topics.title));
192192
expect(items).toHaveLength(2);
193193
expect(items[0]).toMatchObject({ title: 'Topic 1', favorite: true, sessionId, userId });
194194
expect(items[1]).toMatchObject({ title: 'Topic 2', favorite: false, sessionId, userId });
195195

196-
const updatedMessages = await serverDB.select().from(messages);
196+
const updatedMessages = await serverDB.select().from(messages).orderBy(asc(messages.id));
197197
expect(updatedMessages).toHaveLength(3);
198198
expect(updatedMessages[0].topicId).toBe(createdTopics[0].id);
199199
expect(updatedMessages[1].topicId).toBe(createdTopics[0].id);

src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/List/Item/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ const TopicItem = memo<TopicItemProps>(({ id, title, fav, active, threadId }) =>
110110
fill={fav ? cssVar.colorWarning : 'transparent'}
111111
icon={Star}
112112
onClick={(e) => {
113+
e.preventDefault();
113114
e.stopPropagation();
114115
favoriteTopic(id, !fav);
115116
}}

src/app/[variants]/(main)/agent/features/Conversation/ConversationArea.tsx

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

33
import { Flexbox } from '@lobehub/ui';
4+
import debug from 'debug';
45
import { Suspense, memo, useMemo } from 'react';
56

67
import ChatMiniMap from '@/features/ChatMiniMap';
@@ -18,6 +19,8 @@ import ThreadHydration from './ThreadHydration';
1819
import { useActionsBarConfig } from './useActionsBarConfig';
1920
import { useAgentContext } from './useAgentContext';
2021

22+
const log = debug('lobe-render:agent:ConversationArea');
23+
2124
/**
2225
* ConversationArea
2326
*
@@ -35,6 +38,7 @@ const Conversation = memo(() => {
3538
);
3639
const replaceMessages = useChatStore((s) => s.replaceMessages);
3740
const messages = useChatStore((s) => s.dbMessagesMap[chatKey]);
41+
log('contextKey %s: %o', chatKey, messages);
3842

3943
// Get operation state from ChatStore for reactive updates
4044
const operationState = useOperationState(context);

src/app/[variants]/(main)/group/_layout/Sidebar/Topic/List/Item/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ const TopicItem = memo<TopicItemProps>(({ id, title, fav, active, threadId }) =>
111111
fill={fav ? cssVar.colorWarning : 'transparent'}
112112
icon={Star}
113113
onClick={(e) => {
114+
e.preventDefault();
114115
e.stopPropagation();
115116
favoriteTopic(id, !fav);
116117
}}

src/app/[variants]/(main)/home/_layout/Body/Agent/List/AgentItem/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const AgentItem = memo<AgentItemProps>(({ item, style, className }) => {
106106

107107
return (
108108
<>
109-
<Link aria-label={id} to={agentUrl}>
109+
<Link aria-label={displayTitle} to={agentUrl}>
110110
<NavItem
111111
actions={<Actions dropdownMenu={dropdownMenu} />}
112112
className={className}

0 commit comments

Comments
 (0)