@tuturuuu/ui 0.3.1 → 0.4.0

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 (28) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.json +7 -7
  3. package/src/components/ui/chat/chat-agent-details-operations-panel.test.tsx +396 -2
  4. package/src/components/ui/chat/chat-agent-details-operations-panel.tsx +36 -8
  5. package/src/components/ui/chat/chat-agent-details-setup-panel.tsx +14 -0
  6. package/src/components/ui/chat/chat-agent-details-sidebar.test.tsx +5 -0
  7. package/src/components/ui/chat/chat-agent-details-sidebar.tsx +21 -7
  8. package/src/components/ui/chat/chat-agent-details-utils.test.ts +73 -0
  9. package/src/components/ui/chat/chat-agent-details-utils.tsx +100 -26
  10. package/src/components/ui/chat/chat-agent-details-zalo-personal-panel.tsx +517 -0
  11. package/src/components/ui/chat/chat-sidebar-groups.test.ts +13 -3
  12. package/src/components/ui/chat/chat-sidebar-panel.test.tsx +56 -2
  13. package/src/components/ui/chat/chat-sidebar-panel.tsx +36 -19
  14. package/src/components/ui/chat/chat-sidebar.tsx +7 -0
  15. package/src/components/ui/chat/chat-utils.test.ts +14 -1
  16. package/src/components/ui/chat/chat-workspace.tsx +115 -44
  17. package/src/components/ui/chat/create-conversation-dialog-utils.tsx +56 -0
  18. package/src/components/ui/chat/create-conversation-dialog.test.tsx +105 -0
  19. package/src/components/ui/chat/create-conversation-dialog.tsx +176 -170
  20. package/src/components/ui/chat/create-integration-panel.tsx +110 -0
  21. package/src/components/ui/chat/hooks-integrations.ts +28 -0
  22. package/src/components/ui/chat/hooks-messages.test.tsx +45 -1
  23. package/src/components/ui/chat/hooks-messages.ts +1 -1
  24. package/src/components/ui/chat/hooks-realtime.ts +13 -16
  25. package/src/components/ui/chat/hooks.ts +1 -0
  26. package/src/components/ui/chat/selection.ts +74 -0
  27. package/src/components/ui/chat/utils.ts +7 -1
  28. package/src/hooks/use-semantic-task-search.ts +10 -33
@@ -0,0 +1,74 @@
1
+ 'use client';
2
+
3
+ type SearchParamsLike = {
4
+ toString: () => string;
5
+ };
6
+
7
+ type RouterLike = {
8
+ replace: (href: string, options?: { scroll?: boolean }) => void;
9
+ };
10
+
11
+ export type ChatDetailsTarget = 'agent' | null;
12
+
13
+ export function buildChatSelectionHref({
14
+ conversationId,
15
+ details = null,
16
+ pathname,
17
+ searchParams,
18
+ }: {
19
+ conversationId: string | null;
20
+ details?: ChatDetailsTarget;
21
+ pathname: string;
22
+ searchParams: SearchParamsLike;
23
+ }) {
24
+ const nextParams = new URLSearchParams(searchParams.toString());
25
+
26
+ if (conversationId) {
27
+ nextParams.set('conversationId', conversationId);
28
+ } else {
29
+ nextParams.delete('conversationId');
30
+ }
31
+
32
+ if (details) {
33
+ nextParams.set('details', details);
34
+ } else {
35
+ nextParams.delete('details');
36
+ }
37
+
38
+ const nextQuery = nextParams.toString();
39
+ return nextQuery ? `${pathname}?${nextQuery}` : pathname;
40
+ }
41
+
42
+ export function replaceChatSelection({
43
+ conversationId,
44
+ details,
45
+ pathname,
46
+ router,
47
+ searchParams,
48
+ storageKey,
49
+ }: {
50
+ conversationId: string | null;
51
+ details?: ChatDetailsTarget;
52
+ pathname: string;
53
+ router: RouterLike;
54
+ searchParams: SearchParamsLike;
55
+ storageKey?: string | null;
56
+ }) {
57
+ if (storageKey && typeof window !== 'undefined') {
58
+ if (conversationId) {
59
+ window.localStorage.setItem(storageKey, conversationId);
60
+ } else {
61
+ window.localStorage.removeItem(storageKey);
62
+ }
63
+ }
64
+
65
+ router.replace(
66
+ buildChatSelectionHref({
67
+ conversationId,
68
+ details,
69
+ pathname,
70
+ searchParams,
71
+ }),
72
+ { scroll: false }
73
+ );
74
+ }
@@ -25,6 +25,10 @@ export function normalizeChatConversationScope(
25
25
  export function getChatConversationScope(
26
26
  conversation: Pick<ChatConversation, 'metadata' | 'type'>
27
27
  ): ChatConversationScope {
28
+ if (conversation.metadata?.scope === 'personal') {
29
+ return 'personal';
30
+ }
31
+
28
32
  if (conversation.type === 'direct' || conversation.type === 'group') {
29
33
  return 'personal';
30
34
  }
@@ -59,7 +63,9 @@ export function isChatConversation(value: unknown): value is ChatConversation {
59
63
  export function getChatConversationTypesForScope(
60
64
  scope: ChatConversationScope
61
65
  ): ChatConversationType[] {
62
- return scope === 'personal' ? ['direct', 'group', 'ai'] : ['channel', 'ai'];
66
+ return scope === 'personal'
67
+ ? ['direct', 'group', 'channel', 'ai']
68
+ : ['channel', 'ai'];
63
69
  }
64
70
 
65
71
  export function filterChatConversationsByScope(
@@ -1,16 +1,10 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
+ import {
3
+ searchWorkspaceTasks,
4
+ type WorkspaceTaskSearchResult,
5
+ } from '@tuturuuu/internal-api/tasks';
2
6
 
3
- interface SemanticSearchResult {
4
- id: string;
5
- name: string;
6
- description: string | null;
7
- list_id: string;
8
- start_date: string | null;
9
- end_date: string | null;
10
- completed: boolean;
11
- archived: boolean;
12
- similarity: number;
13
- }
7
+ type SemanticSearchResult = WorkspaceTaskSearchResult;
14
8
 
15
9
  interface UseSemanticTaskSearchOptions {
16
10
  wsId: string;
@@ -41,28 +35,11 @@ export function useSemanticTaskSearch({
41
35
  }
42
36
 
43
37
  try {
44
- // Call the API endpoint to perform semantic search
45
- const response = await fetch(
46
- `/api/v1/workspaces/${wsId}/tasks/search`,
47
- {
48
- method: 'POST',
49
- headers: {
50
- 'Content-Type': 'application/json',
51
- },
52
- body: JSON.stringify({
53
- query: query.trim(),
54
- matchThreshold,
55
- matchCount,
56
- }),
57
- }
58
- );
59
-
60
- if (!response.ok) {
61
- console.error('Semantic search failed:', await response.text());
62
- return [];
63
- }
64
-
65
- const data = await response.json();
38
+ const data = await searchWorkspaceTasks(wsId, {
39
+ query: query.trim(),
40
+ matchThreshold,
41
+ matchCount,
42
+ });
66
43
  return (data.tasks || []) as SemanticSearchResult[];
67
44
  } catch (error) {
68
45
  console.error('Error performing semantic search:', error);