@lobehub/lobehub 2.0.0-next.295 → 2.0.0-next.296

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/changelog/v1.json +9 -0
  3. package/locales/en-US/plugin.json +4 -0
  4. package/locales/zh-CN/plugin.json +4 -0
  5. package/package.json +1 -1
  6. package/packages/agent-runtime/src/core/__tests__/runtime.test.ts +5 -5
  7. package/packages/agent-runtime/src/utils/stepContextComputer.test.ts +5 -5
  8. package/packages/builtin-tool-gtd/src/client/Inspector/index.ts +0 -4
  9. package/packages/builtin-tool-gtd/src/client/Intervention/AddTodo.tsx +1 -1
  10. package/packages/builtin-tool-gtd/src/client/Render/TodoList/index.tsx +39 -10
  11. package/packages/builtin-tool-gtd/src/client/Render/index.ts +0 -2
  12. package/packages/builtin-tool-gtd/src/client/components/SortableTodoList/TodoItemRow.tsx +26 -12
  13. package/packages/builtin-tool-gtd/src/client/components/SortableTodoList/store/actions.ts +5 -5
  14. package/packages/builtin-tool-gtd/src/client/components/SortableTodoList/store/store.test.ts +14 -8
  15. package/packages/builtin-tool-gtd/src/executor/index.test.ts +48 -227
  16. package/packages/builtin-tool-gtd/src/executor/index.ts +15 -158
  17. package/packages/builtin-tool-gtd/src/manifest.ts +12 -42
  18. package/packages/builtin-tool-gtd/src/systemRole.ts +14 -8
  19. package/packages/builtin-tool-gtd/src/types.ts +47 -41
  20. package/packages/builtin-tool-memory/package.json +8 -0
  21. package/packages/builtin-tool-memory/src/client/Inspector/AddContextMemory/index.tsx +60 -0
  22. package/packages/builtin-tool-memory/src/client/Inspector/AddExperienceMemory/index.tsx +60 -0
  23. package/packages/builtin-tool-memory/src/client/Inspector/AddIdentityMemory/index.tsx +60 -0
  24. package/packages/builtin-tool-memory/src/client/Inspector/AddPreferenceMemory/index.tsx +60 -0
  25. package/packages/builtin-tool-memory/src/client/Inspector/RemoveIdentityMemory/index.tsx +60 -0
  26. package/packages/builtin-tool-memory/src/client/Inspector/SearchUserMemory/index.tsx +67 -0
  27. package/packages/builtin-tool-memory/src/client/Inspector/UpdateIdentityMemory/index.tsx +60 -0
  28. package/packages/builtin-tool-memory/src/client/Inspector/index.ts +35 -0
  29. package/packages/builtin-tool-memory/src/client/Intervention/AddExperienceMemory/index.tsx +17 -0
  30. package/packages/builtin-tool-memory/src/client/Intervention/index.ts +13 -0
  31. package/packages/builtin-tool-memory/src/client/Render/AddExperienceMemory/index.tsx +17 -0
  32. package/packages/builtin-tool-memory/src/client/Render/SearchUserMemory/index.tsx +217 -0
  33. package/packages/builtin-tool-memory/src/client/Render/index.ts +15 -0
  34. package/packages/builtin-tool-memory/src/client/Streaming/AddExperienceMemory/index.tsx +17 -0
  35. package/packages/builtin-tool-memory/src/client/Streaming/index.ts +18 -0
  36. package/packages/builtin-tool-memory/src/client/components/ExperienceMemoryCard.tsx +231 -0
  37. package/packages/builtin-tool-memory/src/client/components/index.ts +1 -0
  38. package/packages/builtin-tool-memory/src/client/index.ts +27 -0
  39. package/packages/builtin-tool-memory/src/executor/index.ts +9 -1
  40. package/packages/builtin-tool-memory/src/types.ts +61 -0
  41. package/packages/context-engine/src/providers/GTDTodoInjector.ts +15 -7
  42. package/packages/conversation-flow/src/__tests__/fixtures/outputs/assistantGroup/tools-with-branches.json +4 -0
  43. package/packages/conversation-flow/src/transformation/FlatListBuilder.ts +1 -0
  44. package/packages/prompts/src/prompts/gtd/index.test.ts +32 -16
  45. package/packages/prompts/src/prompts/gtd/index.ts +9 -5
  46. package/packages/types/src/stepContext.ts +4 -1
  47. package/src/app/[variants]/(main)/community/(detail)/assistant/features/Details/Versions/index.tsx +2 -2
  48. package/src/app/[variants]/(main)/community/features/Search.tsx +1 -1
  49. package/src/app/[variants]/(main)/resource/features/DndContextWrapper.tsx +4 -2
  50. package/src/app/[variants]/(main)/resource/library/_layout/Header/LibraryHead.tsx +30 -35
  51. package/src/app/[variants]/(main)/resource/library/_layout/Header/index.tsx +9 -11
  52. package/src/features/Conversation/Messages/AssistantGroup/Tool/Actions/index.tsx +11 -17
  53. package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/LoadingPlaceholder/index.tsx +13 -3
  54. package/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Render/CustomRender.tsx +43 -0
  55. package/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Render/FallbacktArgumentRender.tsx +59 -0
  56. package/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Render/index.tsx +46 -0
  57. package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/index.tsx +13 -19
  58. package/src/features/Conversation/Messages/AssistantGroup/Tool/index.tsx +17 -17
  59. package/src/features/Conversation/Messages/Tool/Tool/index.tsx +10 -9
  60. package/src/features/Conversation/TodoProgress/index.tsx +56 -23
  61. package/src/features/PluginsUI/Render/MCPType/index.tsx +1 -1
  62. package/src/features/ResourceManager/components/Explorer/Header/index.tsx +57 -4
  63. package/src/features/ResourceManager/components/Explorer/ListView/ListItem/index.tsx +6 -4
  64. package/src/features/ResourceManager/components/Explorer/ListView/index.tsx +16 -5
  65. package/src/features/ResourceManager/components/LibraryHierarchy/styles.ts +5 -4
  66. package/src/hooks/useActiveTabKey.ts +1 -2
  67. package/src/locales/default/plugin.ts +1 -0
  68. package/src/store/chat/slices/message/selectors/dbMessage.test.ts +11 -11
  69. package/src/store/file/slices/resource/action.ts +4 -2
  70. package/src/tools/inspectors.ts +2 -0
  71. package/src/tools/interventions.ts +2 -0
  72. package/src/tools/renders.ts +3 -1
  73. package/src/tools/streamings.ts +2 -0
  74. package/packages/builtin-tool-gtd/src/client/Inspector/CompleteTodos/index.tsx +0 -52
  75. package/packages/builtin-tool-gtd/src/client/Inspector/RemoveTodos/index.tsx +0 -52
  76. package/src/features/Conversation/Messages/AssistantGroup/Tool/Render/CustomRender.tsx +0 -113
  77. package/src/features/Conversation/Messages/Tool/Tool/Render.tsx +0 -47
  78. /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/AbortResponse.tsx +0 -0
  79. /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/Arguments/index.tsx +0 -0
  80. /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/ErrorResponse.tsx +0 -0
  81. /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/Intervention/ApprovalActions.tsx +0 -0
  82. /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/Intervention/Fallback.tsx +0 -0
  83. /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/Intervention/KeyValueEditor.tsx +0 -0
  84. /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/Intervention/ModeSelector.tsx +0 -0
  85. /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/Intervention/index.tsx +0 -0
  86. /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/PluginSettings.tsx +0 -0
  87. /package/src/features/Conversation/Messages/AssistantGroup/Tool/{Render → Detail}/RejectedResponse.tsx +0 -0
@@ -41,6 +41,7 @@ class MemoryExecutor extends BaseExecutor<typeof MemoryApiName> {
41
41
  } catch (error) {
42
42
  const err = error as Error;
43
43
  return {
44
+ content: `searchUserMemory with error detail: ${err.message}`,
44
45
  error: {
45
46
  body: error,
46
47
  message: err.message,
@@ -80,6 +81,7 @@ class MemoryExecutor extends BaseExecutor<typeof MemoryApiName> {
80
81
  } catch (error) {
81
82
  const err = error as Error;
82
83
  return {
84
+ content: `addContextMemory with error detail: ${err.message}`,
83
85
  error: {
84
86
  body: error,
85
87
  message: err.message,
@@ -110,13 +112,15 @@ class MemoryExecutor extends BaseExecutor<typeof MemoryApiName> {
110
112
  }
111
113
 
112
114
  return {
113
- content: `🧠 Experience memory saved: "${params.title}"`,
115
+ content: `Experience memory "${params.title}" saved with memoryId: "${result.memoryId}" and experienceId: "${result.experienceId}"`,
114
116
  state: { experienceId: result.experienceId, memoryId: result.memoryId },
115
117
  success: true,
116
118
  };
117
119
  } catch (error) {
118
120
  const err = error as Error;
121
+
119
122
  return {
123
+ content: `addExperienceMemory with error detail: ${err.message}`,
120
124
  error: {
121
125
  body: error,
122
126
  message: err.message,
@@ -154,6 +158,7 @@ class MemoryExecutor extends BaseExecutor<typeof MemoryApiName> {
154
158
  } catch (error) {
155
159
  const err = error as Error;
156
160
  return {
161
+ content: `addIdentityMemory with error detail: ${err.message}`,
157
162
  error: {
158
163
  body: error,
159
164
  message: err.message,
@@ -191,6 +196,7 @@ class MemoryExecutor extends BaseExecutor<typeof MemoryApiName> {
191
196
  } catch (error) {
192
197
  const err = error as Error;
193
198
  return {
199
+ content: `addPreferenceMemory with error detail: ${err.message}`,
194
200
  error: {
195
201
  body: error,
196
202
  message: err.message,
@@ -230,6 +236,7 @@ class MemoryExecutor extends BaseExecutor<typeof MemoryApiName> {
230
236
  } catch (error) {
231
237
  const err = error as Error;
232
238
  return {
239
+ content: `updateIdentityMemory with error detail: ${err.message}`,
233
240
  error: {
234
241
  body: error,
235
242
  message: err.message,
@@ -264,6 +271,7 @@ class MemoryExecutor extends BaseExecutor<typeof MemoryApiName> {
264
271
  } catch (error) {
265
272
  const err = error as Error;
266
273
  return {
274
+ content: `removeIdentityMemory with error detail: ${err.message}`,
267
275
  error: {
268
276
  body: error,
269
277
  message: err.message,
@@ -1,3 +1,14 @@
1
+ import type {
2
+ AddIdentityActionSchema,
3
+ ContextMemoryItemSchema,
4
+ ExperienceMemoryItemSchema,
5
+ PreferenceMemoryItemSchema,
6
+ RemoveIdentityActionSchema,
7
+ UpdateIdentityActionSchema,
8
+ } from '@lobechat/memory-user-memory/schemas';
9
+ import type { SearchMemoryResult } from '@lobechat/types';
10
+ import type { z } from 'zod';
11
+
1
12
  export const MemoryApiName = {
2
13
  addContextMemory: 'addContextMemory',
3
14
  addExperienceMemory: 'addExperienceMemory',
@@ -12,3 +23,53 @@ export type MemoryApiNameType = (typeof MemoryApiName)[keyof typeof MemoryApiNam
12
23
 
13
24
  /** @deprecated Use MemoryApiName instead */
14
25
  export const UserMemoryApiName = MemoryApiName;
26
+
27
+ // ==================== Inspector Types ====================
28
+
29
+ // Search
30
+
31
+ // SearchUserMemoryState is the same as SearchMemoryResult (executor returns result directly as state)
32
+ export type SearchUserMemoryState = SearchMemoryResult;
33
+
34
+ // Add Context
35
+ export type AddContextMemoryParams = z.infer<typeof ContextMemoryItemSchema>;
36
+ export interface AddContextMemoryState {
37
+ contextId?: string;
38
+ memoryId?: string;
39
+ }
40
+
41
+ // Add Experience
42
+ export type AddExperienceMemoryParams = z.infer<typeof ExperienceMemoryItemSchema>;
43
+ export interface AddExperienceMemoryState {
44
+ experienceId?: string;
45
+ memoryId?: string;
46
+ }
47
+
48
+ // Add Identity
49
+ export type AddIdentityMemoryParams = z.infer<typeof AddIdentityActionSchema>;
50
+ export interface AddIdentityMemoryState {
51
+ identityId?: string;
52
+ memoryId?: string;
53
+ }
54
+
55
+ // Add Preference
56
+ export type AddPreferenceMemoryParams = z.infer<typeof PreferenceMemoryItemSchema>;
57
+ export interface AddPreferenceMemoryState {
58
+ memoryId?: string;
59
+ preferenceId?: string;
60
+ }
61
+
62
+ // Update Identity
63
+ export type UpdateIdentityMemoryParams = z.infer<typeof UpdateIdentityActionSchema>;
64
+ export interface UpdateIdentityMemoryState {
65
+ identityId?: string;
66
+ }
67
+
68
+ // Remove Identity
69
+ export type RemoveIdentityMemoryParams = z.infer<typeof RemoveIdentityActionSchema>;
70
+ export interface RemoveIdentityMemoryState {
71
+ identityId?: string;
72
+ reason?: string;
73
+ }
74
+
75
+ export {type SearchMemoryParams, type SearchMemoryResult} from '@lobechat/types';
@@ -5,12 +5,15 @@ import type { PipelineContext, ProcessorOptions } from '../types';
5
5
 
6
6
  const log = debug('context-engine:provider:GTDTodoInjector');
7
7
 
8
+ /** Status of a todo item */
9
+ export type GTDTodoStatus = 'todo' | 'processing' | 'completed';
10
+
8
11
  /**
9
12
  * GTD Todo item structure
10
13
  */
11
14
  export interface GTDTodoItem {
12
- /** Whether the item is completed */
13
- completed: boolean;
15
+ /** Status of the todo item */
16
+ status: GTDTodoStatus;
14
17
  /** The todo item text */
15
18
  text: string;
16
19
  }
@@ -43,13 +46,15 @@ function formatGTDTodos(todos: GTDTodoList): string | null {
43
46
  const lines: string[] = ['<gtd_todos>'];
44
47
 
45
48
  items.forEach((item, index) => {
46
- const status = item.completed ? 'done' : 'pending';
47
- lines.push(`<todo index="${index}" status="${status}">${item.text}</todo>`);
49
+ lines.push(`<todo index="${index}" status="${item.status}">${item.text}</todo>`);
48
50
  });
49
51
 
50
- const completedCount = items.filter((item) => item.completed).length;
52
+ const completedCount = items.filter((item) => item.status === 'completed').length;
53
+ const processingCount = items.filter((item) => item.status === 'processing').length;
51
54
  const totalCount = items.length;
52
- lines.push(`<progress completed="${completedCount}" total="${totalCount}" />`);
55
+ lines.push(
56
+ `<progress completed="${completedCount}" processing="${processingCount}" total="${totalCount}" />`,
57
+ );
53
58
 
54
59
  lines.push('</gtd_todos>');
55
60
 
@@ -117,7 +122,10 @@ export class GTDTodoInjector extends BaseLastUserContentProvider {
117
122
  clonedContext.metadata.gtdTodoInjected = true;
118
123
  clonedContext.metadata.gtdTodoCount = this.config.todos.items.length;
119
124
  clonedContext.metadata.gtdTodoCompletedCount = this.config.todos.items.filter(
120
- (item) => item.completed,
125
+ (item) => item.status === 'completed',
126
+ ).length;
127
+ clonedContext.metadata.gtdTodoProcessingCount = this.config.todos.items.filter(
128
+ (item) => item.status === 'processing',
121
129
  ).length;
122
130
 
123
131
  log('GTD Todo context appended to last user message');
@@ -90,6 +90,10 @@
90
90
  "id": "msg-504",
91
91
  "state": {
92
92
  "cached": false
93
+ },
94
+ "error": {
95
+ "type": "NameError",
96
+ "message": "name 'result' is not defined"
93
97
  }
94
98
  },
95
99
  "result_msg_id": "msg-504"
@@ -644,6 +644,7 @@ export class FlatListBuilder {
644
644
  id: toolMsg.id,
645
645
  };
646
646
  if (toolMsg.error) result.error = toolMsg.error;
647
+ if (toolMsg.pluginError) result.error = toolMsg.pluginError;
647
648
  if (toolMsg.pluginState) result.state = toolMsg.pluginState;
648
649
 
649
650
  const toolWithResult: ChatToolPayloadWithResult = {
@@ -15,12 +15,12 @@ describe('formatTodoStateSummary', () => {
15
15
 
16
16
  it('should format todo list with only pending items', () => {
17
17
  const todos = [
18
- { text: 'Task A', completed: false },
19
- { text: 'Task B', completed: false },
20
- { text: 'Task C', completed: false },
18
+ { text: 'Task A', status: 'todo' as const },
19
+ { text: 'Task B', status: 'todo' as const },
20
+ { text: 'Task C', status: 'todo' as const },
21
21
  ];
22
22
  expect(formatTodoStateSummary(todos)).toMatchInlineSnapshot(`
23
- "📋 Current Todo List (3 pending, 0 completed):
23
+ "📋 Current Todo List (3 todo, 0 processing, 0 completed):
24
24
  - [ ] Task A
25
25
  - [ ] Task B
26
26
  - [ ] Task C"
@@ -29,11 +29,11 @@ describe('formatTodoStateSummary', () => {
29
29
 
30
30
  it('should format todo list with only completed items', () => {
31
31
  const todos = [
32
- { text: 'Done task 1', completed: true },
33
- { text: 'Done task 2', completed: true },
32
+ { text: 'Done task 1', status: 'completed' as const },
33
+ { text: 'Done task 2', status: 'completed' as const },
34
34
  ];
35
35
  expect(formatTodoStateSummary(todos)).toMatchInlineSnapshot(`
36
- "📋 Current Todo List (0 pending, 2 completed):
36
+ "📋 Current Todo List (0 todo, 0 processing, 2 completed):
37
37
  - [x] Done task 1
38
38
  - [x] Done task 2"
39
39
  `);
@@ -41,12 +41,12 @@ describe('formatTodoStateSummary', () => {
41
41
 
42
42
  it('should format todo list with mixed items', () => {
43
43
  const todos = [
44
- { text: 'Pending task', completed: false },
45
- { text: 'Completed task', completed: true },
46
- { text: 'Another pending', completed: false },
44
+ { text: 'Pending task', status: 'todo' as const },
45
+ { text: 'Completed task', status: 'completed' as const },
46
+ { text: 'Another pending', status: 'todo' as const },
47
47
  ];
48
48
  expect(formatTodoStateSummary(todos)).toMatchInlineSnapshot(`
49
- "📋 Current Todo List (2 pending, 1 completed):
49
+ "📋 Current Todo List (2 todo, 0 processing, 1 completed):
50
50
  - [ ] Pending task
51
51
  - [x] Completed task
52
52
  - [ ] Another pending"
@@ -55,21 +55,37 @@ describe('formatTodoStateSummary', () => {
55
55
 
56
56
  it('should format todo list with timestamp', () => {
57
57
  const todos = [
58
- { text: 'Task 1', completed: false },
59
- { text: 'Task 2', completed: true },
58
+ { text: 'Task 1', status: 'todo' as const },
59
+ { text: 'Task 2', status: 'completed' as const },
60
60
  ];
61
61
  expect(formatTodoStateSummary(todos, '2025-01-15T10:30:00.000Z')).toMatchInlineSnapshot(`
62
- "📋 Current Todo List (1 pending, 1 completed) | Updated: 2025-01-15T10:30:00.000Z:
62
+ "📋 Current Todo List (1 todo, 0 processing, 1 completed) | Updated: 2025-01-15T10:30:00.000Z:
63
63
  - [ ] Task 1
64
64
  - [x] Task 2"
65
65
  `);
66
66
  });
67
67
 
68
68
  it('should handle single item', () => {
69
- const todos = [{ text: 'Only task', completed: false }];
69
+ const todos = [{ text: 'Only task', status: 'todo' as const }];
70
70
  expect(formatTodoStateSummary(todos)).toMatchInlineSnapshot(`
71
- "📋 Current Todo List (1 pending, 0 completed):
71
+ "📋 Current Todo List (1 todo, 0 processing, 0 completed):
72
72
  - [ ] Only task"
73
73
  `);
74
74
  });
75
+
76
+ it('should format todo list with processing items', () => {
77
+ const todos = [
78
+ { text: 'Todo task', status: 'todo' as const },
79
+ { text: 'Processing task 1', status: 'processing' as const },
80
+ { text: 'Processing task 2', status: 'processing' as const },
81
+ { text: 'Done task', status: 'completed' as const },
82
+ ];
83
+ expect(formatTodoStateSummary(todos)).toMatchInlineSnapshot(`
84
+ "📋 Current Todo List (1 todo, 2 processing, 1 completed):
85
+ - [ ] Todo task
86
+ - [~] Processing task 1
87
+ - [~] Processing task 2
88
+ - [x] Done task"
89
+ `);
90
+ });
75
91
  });
@@ -1,5 +1,7 @@
1
+ export type TodoStatus = 'todo' | 'processing' | 'completed';
2
+
1
3
  export interface TodoItem {
2
- completed: boolean;
4
+ status: TodoStatus;
3
5
  text: string;
4
6
  }
5
7
 
@@ -17,13 +19,15 @@ export const formatTodoStateSummary = (todos: TodoItem[], updatedAt?: string): s
17
19
  return `📋 Current Todo List: (empty)${timeInfo}`;
18
20
  }
19
21
 
20
- const completed = todos.filter((t) => t.completed).length;
21
- const pending = todos.length - completed;
22
+ const completed = todos.filter((t) => t.status === 'completed').length;
23
+ const processing = todos.filter((t) => t.status === 'processing').length;
24
+ const pending = todos.length - completed - processing;
22
25
 
23
26
  const lines = todos.map((item) => {
24
- const checkbox = item.completed ? '- [x]' : '- [ ]';
27
+ const checkbox =
28
+ item.status === 'completed' ? '- [x]' : item.status === 'processing' ? '- [~]' : '- [ ]';
25
29
  return `${checkbox} ${item.text}`;
26
30
  });
27
31
 
28
- return `📋 Current Todo List (${pending} pending, ${completed} completed)${timeInfo}:\n${lines.join('\n')}`;
32
+ return `📋 Current Todo List (${pending} todo, ${processing} processing, ${completed} completed)${timeInfo}:\n${lines.join('\n')}`;
29
33
  };
@@ -10,12 +10,15 @@
10
10
  * 3. Replaces the deprecated pluginState passing pattern
11
11
  */
12
12
 
13
+ /** Status of a todo item */
14
+ export type StepContextTodoStatus = 'todo' | 'processing' | 'completed';
15
+
13
16
  /**
14
17
  * Todo item structure
15
18
  * Duplicated here to avoid circular dependency with builtin-tool-gtd
16
19
  */
17
20
  export interface StepContextTodoItem {
18
- completed: boolean;
21
+ status: StepContextTodoStatus;
19
22
  text: string;
20
23
  }
21
24
 
@@ -5,10 +5,10 @@ import qs from 'query-string';
5
5
  import { memo, useMemo } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
 
8
- import Link from '@/libs/router/Link';
9
- import { usePathname , useQuery } from '@/libs/router/navigation';
10
8
  import InlineTable from '@/components/InlineTable';
11
9
  import PublishedTime from '@/components/PublishedTime';
10
+ import Link from '@/libs/router/Link';
11
+ import { usePathname, useQuery } from '@/libs/router/navigation';
12
12
  import { type AssistantMarketSource, AssistantNavKey } from '@/types/discover';
13
13
 
14
14
  import Title from '../../../../../features/Title';
@@ -6,9 +6,9 @@ import { memo, useState } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import urlJoin from 'url-join';
8
8
 
9
- import { usePathname , useQuery } from '@/libs/router/navigation';
10
9
  import { withSuspense } from '@/components/withSuspense';
11
10
  import { useQueryRoute } from '@/hooks/useQueryRoute';
11
+ import { usePathname, useQuery } from '@/libs/router/navigation';
12
12
 
13
13
  const prefixCls = 'ant';
14
14
 
@@ -193,14 +193,16 @@ export const DndContextWrapper = memo<PropsWithChildren>(({ children }) => {
193
193
 
194
194
  document.addEventListener('dragstart', handleDragStart);
195
195
  document.addEventListener('drag', handleDrag);
196
- document.addEventListener('drop', handleDrop);
196
+ // Use capture phase so drops still work even if some UI stops propagation
197
+ // (e.g., header dropdowns / menus).
198
+ document.addEventListener('drop', handleDrop, true);
197
199
  document.addEventListener('dragover', handleDragOver);
198
200
  document.addEventListener('dragend', handleDragEnd);
199
201
 
200
202
  return () => {
201
203
  document.removeEventListener('dragstart', handleDragStart);
202
204
  document.removeEventListener('drag', handleDrag);
203
- document.removeEventListener('drop', handleDrop);
205
+ document.removeEventListener('drop', handleDrop, true);
204
206
  document.removeEventListener('dragover', handleDragOver);
205
207
  document.removeEventListener('dragend', handleDragEnd);
206
208
  };
@@ -1,8 +1,16 @@
1
1
  'use client';
2
2
 
3
- import { Center, type DropdownItem, DropdownMenu, Flexbox, Skeleton, Text } from '@lobehub/ui';
3
+ import {
4
+ ActionIcon,
5
+ Block,
6
+ Center,
7
+ type DropdownItem,
8
+ DropdownMenu,
9
+ Skeleton,
10
+ Text,
11
+ } from '@lobehub/ui';
4
12
  import { createStaticStyles, cx } from 'antd-style';
5
- import { ChevronsUpDown } from 'lucide-react';
13
+ import { ChevronsUpDownIcon } from 'lucide-react';
6
14
  import { type DragEvent, memo, useCallback, useMemo, useState } from 'react';
7
15
  import { useNavigate } from 'react-router-dom';
8
16
 
@@ -12,15 +20,6 @@ import RepoIcon from '@/components/LibIcon';
12
20
  import { knowledgeBaseSelectors, useKnowledgeBaseStore } from '@/store/library';
13
21
 
14
22
  const styles = createStaticStyles(({ css, cssVar }) => ({
15
- clickableHeader: css`
16
- cursor: pointer;
17
- border-radius: ${cssVar.borderRadius}px;
18
- transition: all 0.2s;
19
-
20
- &:hover {
21
- background-color: ${cssVar.colorFillTertiary};
22
- }
23
- `,
24
23
  dropZoneActive: css`
25
24
  color: ${cssVar.colorBgElevated} !important;
26
25
  background-color: ${cssVar.colorText} !important;
@@ -29,14 +28,6 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
29
28
  color: ${cssVar.colorBgElevated} !important;
30
29
  }
31
30
  `,
32
- icon: css`
33
- color: ${cssVar.colorTextSecondary};
34
- transition: all 0.2s;
35
-
36
- &:hover {
37
- color: ${cssVar.colorText};
38
- }
39
- `,
40
31
  menuIcon: css`
41
32
  color: ${cssVar.colorTextTertiary};
42
33
  `,
@@ -101,43 +92,47 @@ const Head = memo<{ id: string }>(({ id }) => {
101
92
  }, [libraries, handleLibrarySwitch, id, styles.menuIcon]);
102
93
 
103
94
  return (
104
- <Flexbox
95
+ <Block
105
96
  align={'center'}
106
- className={cx(styles.clickableHeader, isDropZoneActive && styles.dropZoneActive)}
97
+ className={cx(isDropZoneActive && styles.dropZoneActive)}
98
+ clickable
107
99
  data-drop-target-id="root"
108
100
  data-is-folder="true"
109
101
  data-root-drop="true"
110
102
  gap={8}
111
103
  horizontal
104
+ onClick={handleClick}
112
105
  onDragLeave={handleDragLeave}
113
106
  onDragOver={handleDragOver}
114
107
  onDrop={handleDrop}
115
- paddingBlock={6}
116
- paddingInline={'12px 14px'}
108
+ padding={2}
109
+ style={{ minWidth: 32, overflow: 'hidden' }}
110
+ variant={'borderless'}
117
111
  >
118
- <Center style={{ minWidth: 24 }} width={24}>
119
- <RepoIcon />
112
+ <Center style={{ minWidth: 32 }} width={32}>
113
+ <RepoIcon size={18} />
120
114
  </Center>
121
115
  {!name ? (
122
116
  <Skeleton active paragraph={false} title={{ style: { marginBottom: 0 }, width: 80 }} />
123
117
  ) : (
124
- <Flexbox align={'center'} flex={1} gap={4} horizontal onClick={handleClick}>
125
- <Text ellipsis strong style={{ flex: 1, fontSize: 16 }}>
126
- {name}
127
- </Text>
128
- </Flexbox>
118
+ <Text ellipsis style={{ flex: 1 }} weight={500}>
119
+ {name}
120
+ </Text>
129
121
  )}
130
122
  {name && (
131
123
  <DropdownMenu items={menuItems} placement="bottomRight">
132
- <ChevronsUpDown
133
- className={styles.icon}
124
+ <ActionIcon
125
+ icon={ChevronsUpDownIcon}
134
126
  onClick={(e) => e.stopPropagation()}
135
- size={16}
136
- style={{ cursor: 'pointer', flex: 'none' }}
127
+ size={{
128
+ blockSize: 28,
129
+ size: 16,
130
+ }}
131
+ style={{ width: 24 }}
137
132
  />
138
133
  </DropdownMenu>
139
134
  )}
140
- </Flexbox>
135
+ </Block>
141
136
  );
142
137
  });
143
138
 
@@ -12,17 +12,15 @@ const Header = memo(() => {
12
12
  const { id } = useParams<{ id: string }>();
13
13
  const { t } = useTranslation('common');
14
14
  return (
15
- <>
16
- <SideBarHeaderLayout
17
- breadcrumb={[
18
- {
19
- href: '/resource',
20
- title: t('tab.resource'),
21
- },
22
- ]}
23
- />
24
- <LibraryHead id={id || ''} />
25
- </>
15
+ <SideBarHeaderLayout
16
+ breadcrumb={[
17
+ {
18
+ href: '/resource',
19
+ title: t('tab.resource'),
20
+ },
21
+ ]}
22
+ left={<LibraryHead id={id || ''} />}
23
+ />
26
24
  );
27
25
  });
28
26
 
@@ -8,49 +8,43 @@ import Settings from './Settings';
8
8
 
9
9
  interface ActionsProps {
10
10
  assistantMessageId: string;
11
- handleExpand?: (expand?: boolean) => void;
11
+ canToggleCustomToolRender?: boolean;
12
12
  identifier: string;
13
+ setShowCustomToolRender?: (show: boolean) => void;
13
14
  setShowDebug?: (show: boolean) => void;
14
- setShowPluginRender: (show: boolean) => void;
15
- showCustomPluginRender: boolean;
15
+ showCustomToolRender?: boolean;
16
16
  showDebug?: boolean;
17
- showPluginRender: boolean;
18
17
  }
19
18
 
20
19
  const Actions = memo<ActionsProps>(
21
20
  ({
22
21
  assistantMessageId,
22
+ canToggleCustomToolRender,
23
23
  identifier,
24
+ setShowCustomToolRender,
24
25
  setShowDebug,
25
- setShowPluginRender,
26
- showCustomPluginRender,
26
+ showCustomToolRender,
27
27
  showDebug,
28
- showPluginRender,
29
- handleExpand,
30
28
  }) => {
31
29
  const { t } = useTranslation('plugin');
32
30
  const deleteAssistantMessage = useConversationStore((s) => s.deleteAssistantMessage);
33
31
 
34
32
  return (
35
33
  <>
36
- {showCustomPluginRender && (
34
+ {canToggleCustomToolRender && (
37
35
  <ActionIcon
38
- icon={showPluginRender ? LogsIcon : LayoutPanelTop}
36
+ icon={showCustomToolRender ? LogsIcon : LayoutPanelTop}
39
37
  onClick={() => {
40
- setShowPluginRender(!showPluginRender);
41
- handleExpand?.(true);
38
+ setShowCustomToolRender?.(!showCustomToolRender);
42
39
  }}
43
40
  size={'small'}
44
- title={showPluginRender ? t('inspector.args') : t('inspector.pluginRender')}
41
+ title={showCustomToolRender ? t('inspector.args') : t('inspector.pluginRender')}
45
42
  />
46
43
  )}
47
44
  <ActionIcon
48
45
  active={showDebug}
49
46
  icon={showDebug ? LucideBugOff : LucideBug}
50
- onClick={() => {
51
- setShowDebug?.(!showDebug);
52
- handleExpand?.(true);
53
- }}
47
+ onClick={() => setShowDebug?.(!showDebug)}
54
48
  size={'small'}
55
49
  title={t(showDebug ? 'debug.off' : 'debug.on')}
56
50
  />
@@ -2,6 +2,7 @@ import { safeParseJSON } from '@lobechat/utils';
2
2
  import { memo } from 'react';
3
3
 
4
4
  import { getBuiltinPlaceholder } from '@/tools/placeholders';
5
+ import { getBuiltinStreaming } from '@/tools/streamings';
5
6
 
6
7
  import Arguments from '../Arguments';
7
8
 
@@ -9,16 +10,25 @@ interface LoadingPlaceholderProps {
9
10
  apiName: string;
10
11
  identifier: string;
11
12
  loading?: boolean;
13
+ messageId: string;
12
14
  requestArgs?: string;
15
+ toolCallId: string;
13
16
  }
14
17
 
15
18
  const LoadingPlaceholder = memo<LoadingPlaceholderProps>(
16
- ({ identifier, requestArgs, apiName, loading }) => {
17
- const Render = getBuiltinPlaceholder(identifier, apiName);
19
+ ({ identifier, requestArgs, apiName, loading, toolCallId, messageId }) => {
20
+ const Render =
21
+ getBuiltinPlaceholder(identifier, apiName) || getBuiltinStreaming(identifier, apiName);
18
22
 
19
23
  if (Render) {
20
24
  return (
21
- <Render apiName={apiName} args={safeParseJSON(requestArgs) || {}} identifier={identifier} />
25
+ <Render
26
+ apiName={apiName}
27
+ args={safeParseJSON(requestArgs) || {}}
28
+ identifier={identifier}
29
+ messageId={messageId}
30
+ toolCallId={toolCallId}
31
+ />
22
32
  );
23
33
  }
24
34