@messenger-box/tailwind-ui-inbox 10.0.3-alpha.108 → 10.0.3-alpha.110
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.
- package/CHANGELOG.md +8 -0
- package/lib/components/AIAgent/AIAgent.d.ts.map +1 -1
- package/lib/components/AIAgent/AIAgent.js +39 -224
- package/lib/components/AIAgent/AIAgent.js.map +1 -1
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts +2 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts.map +1 -1
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js +32 -60
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js.map +1 -1
- package/lib/components/slot-fill/chat-message-filler.js +1 -1
- package/lib/components/slot-fill/chat-message-filler.js.map +1 -1
- package/lib/compute.d.ts.map +1 -1
- package/lib/compute.js +18 -8
- package/lib/compute.js.map +1 -1
- package/lib/container/AiLandingInput.d.ts.map +1 -1
- package/lib/container/AiLandingInput.js +8 -9
- package/lib/container/AiLandingInput.js.map +1 -1
- package/lib/container/Inbox.js +1 -1
- package/lib/container/Inbox.js.map +1 -1
- package/lib/container/InboxAiMessagesLoader.d.ts.map +1 -1
- package/lib/container/InboxAiMessagesLoader.js +5 -2
- package/lib/container/InboxAiMessagesLoader.js.map +1 -1
- package/lib/container/ServiceInbox.js +1 -1
- package/lib/container/ServiceInbox.js.map +1 -1
- package/lib/container/ThreadMessages.js +1 -1
- package/lib/container/ThreadMessages.js.map +1 -1
- package/lib/container/ThreadMessagesInbox.js +1 -1
- package/lib/container/ThreadMessagesInbox.js.map +1 -1
- package/lib/container/Threads.js +1 -1
- package/lib/container/Threads.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/routes.json +22 -9
- package/lib/templates/InboxWithAi.d.ts.map +1 -1
- package/lib/templates/InboxWithAi.js +0 -1
- package/lib/templates/InboxWithAi.js.map +1 -1
- package/lib/templates/InboxWithAi.tsx +0 -1
- package/package.json +4 -4
- package/src/components/AIAgent/AIAgent.tsx +39 -229
- package/src/components/InboxMessage/message-widgets/ModernMessageGroup.tsx +44 -16
- package/src/compute.ts +20 -10
- package/src/container/AiLandingInput.tsx +12 -8
- package/src/container/InboxAiMessagesLoader.tsx +2 -1
- package/src/templates/InboxWithAi.tsx +0 -1
|
@@ -6,7 +6,7 @@ import { format, isToday, isYesterday, formatDistanceToNow } from 'date-fns';
|
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import { ModernMessageGroupComponent } from '../InboxMessage/message-widgets/ModernMessageGroup';
|
|
8
8
|
import { useUploadFiles } from '@messenger-box/platform-client';
|
|
9
|
-
import { IFileInfo, PostTypeEnum, ISandboxError } from 'common';
|
|
9
|
+
import { IFileInfo, PostTypeEnum, ISandboxError, AiAgentMessageRole } from 'common';
|
|
10
10
|
import { useSelector, shallowEqual } from 'react-redux';
|
|
11
11
|
import { Store, userSelector } from '@adminide-stack/user-auth0-client';
|
|
12
12
|
import { IUserState } from '@adminide-stack/core';
|
|
@@ -18,10 +18,8 @@ import {
|
|
|
18
18
|
useMessagesQuery,
|
|
19
19
|
OnChatMessageAddedDocument as CHAT_MESSAGE_ADDED,
|
|
20
20
|
useCreateChannelWorkflowJobMutation,
|
|
21
|
-
useGenerateAiCodeMutation,
|
|
22
21
|
useOnChatMessageAddedSubscription,
|
|
23
22
|
useSandboxErrorSubscription,
|
|
24
|
-
useRecreateSandboxMutation,
|
|
25
23
|
} from 'common/graphql';
|
|
26
24
|
import { config } from '../../config';
|
|
27
25
|
import { orderBy, uniqBy } from 'lodash-es';
|
|
@@ -30,7 +28,7 @@ import { RoomType } from 'common';
|
|
|
30
28
|
import { SubscriptionHandler } from '../InboxMessage/SubscriptionHandler';
|
|
31
29
|
import { usePersistentModelConfig } from '../../hooks/usePersistentModelConfig';
|
|
32
30
|
|
|
33
|
-
const { MESSAGES_PER_PAGE } = config;
|
|
31
|
+
// const { MESSAGES_PER_PAGE } = config;
|
|
34
32
|
|
|
35
33
|
interface AIAgentProps {
|
|
36
34
|
channelId?: string;
|
|
@@ -74,12 +72,12 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
74
72
|
const { id: pathChannelId } = useParams();
|
|
75
73
|
const navigate = useNavigate();
|
|
76
74
|
const { modelConfig, updateModelConfig, getValidatedConfig, hasApiKey } = usePersistentModelConfig();
|
|
75
|
+
const [postId, setPostId] = useState<string | null>(null);
|
|
77
76
|
// const [isLoading, setIsLoading] = useState(false);
|
|
78
77
|
const [errorData, setError] = useState<string | null>(null);
|
|
79
78
|
// Get channelId from props or path params
|
|
80
79
|
const actualChannelId = channelId || pathChannelId;
|
|
81
|
-
|
|
82
|
-
const [recreateSandbox] = useRecreateSandboxMutation();
|
|
80
|
+
|
|
83
81
|
const { data: chatMessageAddedData } = useOnChatMessageAddedSubscription({
|
|
84
82
|
variables: { channelId: actualChannelId?.toString() || '' },
|
|
85
83
|
skip: !actualChannelId,
|
|
@@ -94,11 +92,12 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
94
92
|
// Direct message query from InboxWithAiLoader.tsx
|
|
95
93
|
const messagesQuery = useMessagesQuery({
|
|
96
94
|
variables: {
|
|
97
|
-
props: {
|
|
98
|
-
|
|
99
|
-
},
|
|
95
|
+
// props: {
|
|
96
|
+
// projectId: actualChannelId?.toString(),
|
|
97
|
+
// },
|
|
98
|
+
channelId: actualChannelId?.toString(),
|
|
100
99
|
parentId: null,
|
|
101
|
-
limit:
|
|
100
|
+
limit: 1,
|
|
102
101
|
},
|
|
103
102
|
skip: !actualChannelId,
|
|
104
103
|
fetchPolicy: 'cache-and-network',
|
|
@@ -133,14 +132,14 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
133
132
|
fetchMore: fetchMoreMessages,
|
|
134
133
|
subscribeToMore,
|
|
135
134
|
} = messagesQuery;
|
|
135
|
+
console.log('messagesData', JSON.stringify(messagesData, null, 2));
|
|
136
136
|
|
|
137
137
|
useEffect(() => {
|
|
138
138
|
if (actualChannelId) {
|
|
139
139
|
refetchMessages({
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
},
|
|
140
|
+
channelId: actualChannelId?.toString(),
|
|
141
|
+
parentId: null,
|
|
142
|
+
limit: 1,
|
|
144
143
|
});
|
|
145
144
|
}
|
|
146
145
|
}, [actualChannelId, refetchMessages]);
|
|
@@ -163,12 +162,13 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
163
162
|
}
|
|
164
163
|
}, [chatMessageAddedData?.chatMessageAdded]);
|
|
165
164
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
if (messagesData?.messages?.data?.length == 1) {
|
|
167
|
+
setPostId(messagesData.messages.data[0]?.id);
|
|
168
|
+
///handleGenerateAiCode(messagesData.messages.data[0].id);
|
|
169
|
+
}
|
|
170
|
+
// console.log('messagesData?.messages?.data',JSON.stringify(messagesData?.messages?.data,null,2))
|
|
171
|
+
}, [messagesData?.messages?.data]);
|
|
172
172
|
|
|
173
173
|
// Handle sandbox error subscription updates
|
|
174
174
|
useEffect(() => {
|
|
@@ -181,7 +181,10 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
181
181
|
|
|
182
182
|
const regularMessages = useMemo(() => {
|
|
183
183
|
if (!messagesData?.messages?.data) return [];
|
|
184
|
-
|
|
184
|
+
const mainMessages = messagesData.messages.data || [];
|
|
185
|
+
const replyMessages = messagesData.messages.data[0]?.replies?.data || [];
|
|
186
|
+
const allMessages = [...mainMessages, ...replyMessages];
|
|
187
|
+
return orderBy(uniqBy(allMessages, 'id'), ['createdAt'], ['asc']);
|
|
185
188
|
}, [messagesData?.messages?.data]);
|
|
186
189
|
|
|
187
190
|
// Send regular messages to AI agent machine for context
|
|
@@ -280,198 +283,6 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
280
283
|
}, delay);
|
|
281
284
|
}, []);
|
|
282
285
|
|
|
283
|
-
const recreateSandboxForFragment = useCallback(
|
|
284
|
-
async (messageId: string) => {
|
|
285
|
-
if (!actualChannelId) {
|
|
286
|
-
console.error('No project ID available for sandbox recreation');
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
try {
|
|
291
|
-
setIsLoading(true);
|
|
292
|
-
setError(null);
|
|
293
|
-
|
|
294
|
-
const response = await recreateSandbox({
|
|
295
|
-
variables: {
|
|
296
|
-
projectId: actualChannelId,
|
|
297
|
-
messageId,
|
|
298
|
-
},
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
if (response.data?.recreateSandbox?.success) {
|
|
302
|
-
console.log('Sandbox recreation initiated successfully');
|
|
303
|
-
// The subscription will handle updating the UI with the new sandbox URL
|
|
304
|
-
} else {
|
|
305
|
-
const errorMsg = response.data?.recreateSandbox?.message || 'Failed to recreate sandbox';
|
|
306
|
-
throw new Error(errorMsg);
|
|
307
|
-
}
|
|
308
|
-
} catch (err) {
|
|
309
|
-
console.error('Error recreating sandbox:', err);
|
|
310
|
-
setError(err instanceof Error ? err.message : 'Failed to recreate sandbox');
|
|
311
|
-
setIsLoading(false);
|
|
312
|
-
}
|
|
313
|
-
},
|
|
314
|
-
[recreateSandbox, actualChannelId],
|
|
315
|
-
);
|
|
316
|
-
|
|
317
|
-
// Updated handleSend function from InboxWithAi.tsx
|
|
318
|
-
// const handleSend = useCallback(
|
|
319
|
-
// async (message: string, files: any[] = []) => {
|
|
320
|
-
// // Allow sending if there's either a message or files
|
|
321
|
-
// if ((!message || !message.trim()) && (!files || files.length === 0)) return;
|
|
322
|
-
|
|
323
|
-
// const validated = getValidatedConfig();
|
|
324
|
-
// if (!validated && !hasApiKey) {
|
|
325
|
-
// // No API key/config; do nothing (AiLandingInput would prompt config UI)
|
|
326
|
-
// return;
|
|
327
|
-
// }
|
|
328
|
-
|
|
329
|
-
// // Start the AI thinking loader immediately on send
|
|
330
|
-
// if (successThinkingTimeoutRef.current) {
|
|
331
|
-
// clearTimeout(successThinkingTimeoutRef.current);
|
|
332
|
-
// successThinkingTimeoutRef.current = null;
|
|
333
|
-
// }
|
|
334
|
-
// setIsSuccessThinking(true);
|
|
335
|
-
// setIsLoading(true);
|
|
336
|
-
// // Safety auto-stop in case no event arrives
|
|
337
|
-
// successThinkingTimeoutRef.current = setTimeout(() => {
|
|
338
|
-
// setIsSuccessThinking(false);
|
|
339
|
-
// successThinkingTimeoutRef.current = null;
|
|
340
|
-
// }, 15000);
|
|
341
|
-
|
|
342
|
-
// // If we already have a channel, send message (with optional file upload) similar to Inbox
|
|
343
|
-
// if (actualChannelId) {
|
|
344
|
-
// try {
|
|
345
|
-
// const postId = objectId();
|
|
346
|
-
// const channelId = objectId();
|
|
347
|
-
// const currentDate = new Date();
|
|
348
|
-
|
|
349
|
-
// const createOptimisticMessage = (uploadedFiles?: any[]) => ({
|
|
350
|
-
// __typename: 'Post' as const,
|
|
351
|
-
// id: postId,
|
|
352
|
-
// message,
|
|
353
|
-
// createdAt: currentDate.toISOString(),
|
|
354
|
-
// updatedAt: currentDate.toISOString(),
|
|
355
|
-
// author: {
|
|
356
|
-
// __typename: 'UserAccount' as const,
|
|
357
|
-
// id: auth?.id,
|
|
358
|
-
// givenName: auth?.profile?.given_name || '',
|
|
359
|
-
// familyName: auth?.profile?.family_name || '',
|
|
360
|
-
// email: auth?.profile?.email || '',
|
|
361
|
-
// username: auth?.profile?.nickname || '',
|
|
362
|
-
// fullName: auth?.profile?.name || '',
|
|
363
|
-
// picture: auth?.profile?.picture || '',
|
|
364
|
-
// alias: [auth?.authUserId ?? ''],
|
|
365
|
-
// tokens: [],
|
|
366
|
-
// },
|
|
367
|
-
// isDelivered: false,
|
|
368
|
-
// isRead: false,
|
|
369
|
-
// type: 'TEXT' as PostTypeEnum,
|
|
370
|
-
// parentId: null,
|
|
371
|
-
// fromServer: false,
|
|
372
|
-
// channel: {
|
|
373
|
-
// __typename: 'Channel' as const,
|
|
374
|
-
// id: actualChannelId,
|
|
375
|
-
// },
|
|
376
|
-
// propsConfiguration: {
|
|
377
|
-
// __typename: 'MachineConfiguration' as const,
|
|
378
|
-
// id: null,
|
|
379
|
-
// resource: '' as any,
|
|
380
|
-
// contents: null,
|
|
381
|
-
// keys: null,
|
|
382
|
-
// target: null,
|
|
383
|
-
// overrides: null,
|
|
384
|
-
// },
|
|
385
|
-
// props: {},
|
|
386
|
-
// files: {
|
|
387
|
-
// __typename: 'FilesInfo' as const,
|
|
388
|
-
// data: uploadedFiles || [],
|
|
389
|
-
// totalCount: uploadedFiles?.length || 0,
|
|
390
|
-
// },
|
|
391
|
-
// replies: {
|
|
392
|
-
// __typename: 'Messages' as const,
|
|
393
|
-
// data: [],
|
|
394
|
-
// totalCount: 0,
|
|
395
|
-
// },
|
|
396
|
-
// });
|
|
397
|
-
|
|
398
|
-
// const cacheMessagesQuery = {
|
|
399
|
-
// query: MessagesDocument,
|
|
400
|
-
// variables: {
|
|
401
|
-
// // Match variables used in useMessagesQuery above
|
|
402
|
-
// props: { projectId: actualChannelId.toString() },
|
|
403
|
-
// parentId: null,
|
|
404
|
-
// limit: MESSAGES_PER_PAGE,
|
|
405
|
-
// },
|
|
406
|
-
// } as const;
|
|
407
|
-
|
|
408
|
-
// const extraProps = {
|
|
409
|
-
// projectId: actualChannelId,
|
|
410
|
-
// template: modelConfig?.template || 'vite-react',
|
|
411
|
-
// role: 'USER',
|
|
412
|
-
// sendNotificationWithProjectId: true,
|
|
413
|
-
// } as any;
|
|
414
|
-
|
|
415
|
-
// if (files?.length > 0) {
|
|
416
|
-
// const uploadResponse = await startUpload({
|
|
417
|
-
// file: files,
|
|
418
|
-
// saveUploadedFile: { variables: { postId } },
|
|
419
|
-
// createUploadLink: { variables: { postId } },
|
|
420
|
-
// });
|
|
421
|
-
|
|
422
|
-
// const uploadedFiles = uploadResponse.data as unknown as IFileInfo[];
|
|
423
|
-
// const fileIds = (uploadedFiles || []).map((f: any) => f.id);
|
|
424
|
-
|
|
425
|
-
// await sendMsg({
|
|
426
|
-
// variables: {
|
|
427
|
-
// postId,
|
|
428
|
-
// channelId: actualChannelId,
|
|
429
|
-
// content: message,
|
|
430
|
-
// files: fileIds,
|
|
431
|
-
// extraProps,
|
|
432
|
-
// },
|
|
433
|
-
// optimisticResponse: {
|
|
434
|
-
// __typename: 'Mutation',
|
|
435
|
-
// sendMessage: createOptimisticMessage(uploadedFiles),
|
|
436
|
-
// },
|
|
437
|
-
// update: (cache, { data: mutationData }) => {
|
|
438
|
-
// if (!mutationData?.sendMessage) return;
|
|
439
|
-
// // if (mutationData?.sendMessage?.id) {
|
|
440
|
-
// // handleGenerateAiCode(mutationData.sendMessage.id);
|
|
441
|
-
// // }
|
|
442
|
-
// },
|
|
443
|
-
// });
|
|
444
|
-
// } else {
|
|
445
|
-
// await sendMsg({
|
|
446
|
-
// variables: { channelId: actualChannelId, content: message, extraProps },
|
|
447
|
-
// optimisticResponse: {
|
|
448
|
-
// __typename: 'Mutation',
|
|
449
|
-
// sendMessage: createOptimisticMessage(),
|
|
450
|
-
// },
|
|
451
|
-
// update: (cache, { data: mutationData }) => {
|
|
452
|
-
// if (!mutationData?.sendMessage) return;
|
|
453
|
-
// console.log('mutationData', JSON.stringify(mutationData, null, 2));
|
|
454
|
-
// // if (mutationData?.sendMessage?.id) {
|
|
455
|
-
// // handleGenerateAiCode(mutationData.sendMessage.id);
|
|
456
|
-
// // }
|
|
457
|
-
// },
|
|
458
|
-
// });
|
|
459
|
-
// }
|
|
460
|
-
|
|
461
|
-
// // Scroll to bottom after send
|
|
462
|
-
// scrollToBottom('smooth', 0);
|
|
463
|
-
// } catch (error) {
|
|
464
|
-
// console.error('Error sending message from AIAgent:', error);
|
|
465
|
-
// setIsLoading(false);
|
|
466
|
-
// }
|
|
467
|
-
|
|
468
|
-
// return;
|
|
469
|
-
// }
|
|
470
|
-
// // If no channelId, we skip sending here.
|
|
471
|
-
// },
|
|
472
|
-
// [actualChannelId, auth, startUpload, sendMsg, scrollToBottom, getValidatedConfig, hasApiKey, modelConfig],
|
|
473
|
-
// );
|
|
474
|
-
|
|
475
286
|
const handleSend = useCallback(
|
|
476
287
|
async (message: string, files: any[] = []) => {
|
|
477
288
|
// Allow sending if there's either a message or files
|
|
@@ -497,10 +308,7 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
497
308
|
}, 15000);
|
|
498
309
|
// If no channelId, mirror AiLandingInput: create channel+project, seed first post, then navigate
|
|
499
310
|
try {
|
|
500
|
-
const
|
|
501
|
-
const postId = objectId();
|
|
502
|
-
const channelId = objectId();
|
|
503
|
-
|
|
311
|
+
// const postId = objectId();
|
|
504
312
|
// Do not include extensionId inside modelConfig when sending additionalProperties
|
|
505
313
|
const { extensionId: _omitExtensionId, ...modelConfigWithoutExtensionId } =
|
|
506
314
|
(modelConfig as any) || ({} as any);
|
|
@@ -508,24 +316,22 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
508
316
|
await createChannelWorkflowJob({
|
|
509
317
|
variables: {
|
|
510
318
|
createChannelInput: {
|
|
511
|
-
channelId,
|
|
319
|
+
channelId: actualChannelId,
|
|
512
320
|
title: 'AI Assistant',
|
|
513
321
|
description: 'AI Assistant',
|
|
514
322
|
displayName: 'AI Assistant',
|
|
515
323
|
topic: 'AI Assistant',
|
|
516
|
-
projectId: projectId,
|
|
324
|
+
// projectId: projectId,
|
|
517
325
|
type: RoomType.Aiassistant,
|
|
518
326
|
postData: {
|
|
519
|
-
postId: postId,
|
|
327
|
+
postId: postId || undefined,
|
|
520
328
|
type: PostTypeEnum.Aiassistant,
|
|
521
329
|
content: message,
|
|
522
330
|
props: {
|
|
523
|
-
generateAiCode: true,
|
|
524
331
|
template: modelConfig?.template || 'vite-react',
|
|
525
|
-
projectId: projectId,
|
|
526
|
-
role:
|
|
332
|
+
//projectId: projectId,
|
|
333
|
+
role: AiAgentMessageRole.User,
|
|
527
334
|
fragment: {},
|
|
528
|
-
sendNotificationWithProjectId: true,
|
|
529
335
|
},
|
|
530
336
|
},
|
|
531
337
|
additionalProperties: {
|
|
@@ -566,6 +372,7 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
566
372
|
},
|
|
567
373
|
[
|
|
568
374
|
actualChannelId,
|
|
375
|
+
postId,
|
|
569
376
|
auth,
|
|
570
377
|
startUpload,
|
|
571
378
|
sendMsg,
|
|
@@ -867,7 +674,7 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
867
674
|
<div key={msg.id || index} className="mb-4">
|
|
868
675
|
{/* Restore to this point button */}
|
|
869
676
|
<div className="flex items-center justify-end mb-2">
|
|
870
|
-
<button className="text-blue-600 text-sm underline hover:text-blue-800 flex items-center">
|
|
677
|
+
{/* <button className="text-blue-600 text-sm underline hover:text-blue-800 flex items-center">
|
|
871
678
|
<svg
|
|
872
679
|
className="w-4 h-4 mr-1"
|
|
873
680
|
fill="none"
|
|
@@ -882,7 +689,7 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
882
689
|
/>
|
|
883
690
|
</svg>
|
|
884
691
|
Restore to this point
|
|
885
|
-
</button>
|
|
692
|
+
</button> */}
|
|
886
693
|
</div>
|
|
887
694
|
|
|
888
695
|
{/* Message using same container as Chat tab */}
|
|
@@ -913,7 +720,8 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
913
720
|
tokens: [],
|
|
914
721
|
},
|
|
915
722
|
createdAt: msg.createdAt,
|
|
916
|
-
type: 'Simple' as any,
|
|
723
|
+
//type: 'Simple' as any,
|
|
724
|
+
type: PostTypeEnum.Aiassistant,
|
|
917
725
|
isDelivered: false,
|
|
918
726
|
isRead: false,
|
|
919
727
|
parentId: null,
|
|
@@ -932,6 +740,8 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
932
740
|
onMessageClick={(msg) => setSelectedPost(msg)}
|
|
933
741
|
isDesktopView={isDesktopView}
|
|
934
742
|
isSmallScreen={isSmallScreen}
|
|
743
|
+
showAuthorName={true}
|
|
744
|
+
showAvatar={true}
|
|
935
745
|
/>
|
|
936
746
|
</div>
|
|
937
747
|
);
|
|
@@ -1057,7 +867,8 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
1057
867
|
tokens: [],
|
|
1058
868
|
},
|
|
1059
869
|
createdAt: msg.createdAt,
|
|
1060
|
-
type: 'Simple' as any,
|
|
870
|
+
//type: 'Simple' as any,
|
|
871
|
+
type: PostTypeEnum.Aiassistant,
|
|
1061
872
|
isDelivered: false,
|
|
1062
873
|
isRead: false,
|
|
1063
874
|
parentId: null,
|
|
@@ -1079,7 +890,6 @@ export const AIAgent: React.FC<AIAgentProps> = ({
|
|
|
1079
890
|
sandboxErrors={sandboxErrors}
|
|
1080
891
|
currentFiles={currentFiles}
|
|
1081
892
|
onFixError={fixError}
|
|
1082
|
-
onRecreateSandbox={recreateSandboxForFragment}
|
|
1083
893
|
/>
|
|
1084
894
|
)}
|
|
1085
895
|
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import { format, differenceInMinutes } from 'date-fns';
|
|
3
|
-
import { IAuthUser, IPost, ISandboxError } from 'common';
|
|
3
|
+
import { AiAgentMessageRole, IAuthUser, IPost, ISandboxError, PostTypeEnum } from 'common';
|
|
4
4
|
import { FilesList } from '../../inbox';
|
|
5
5
|
import { ErrorFixCard } from './ErrorFixCard';
|
|
6
6
|
import ReactMarkdown from 'react-markdown';
|
|
@@ -400,6 +400,8 @@ const useInjectStyles = () => {
|
|
|
400
400
|
};
|
|
401
401
|
|
|
402
402
|
interface ModernMessageGroupProps {
|
|
403
|
+
showAuthorName?: boolean;
|
|
404
|
+
showAvatar?: boolean;
|
|
403
405
|
messages: IPost[];
|
|
404
406
|
currentUser: IAuthUser;
|
|
405
407
|
onOpen: (element?: any) => void;
|
|
@@ -413,6 +415,8 @@ interface ModernMessageGroupProps {
|
|
|
413
415
|
}
|
|
414
416
|
|
|
415
417
|
interface MessageGroupProps {
|
|
418
|
+
showAuthorName?: boolean;
|
|
419
|
+
showAvatar?: boolean;
|
|
416
420
|
author: any;
|
|
417
421
|
messages: IPost[];
|
|
418
422
|
currentUser: IAuthUser;
|
|
@@ -913,6 +917,8 @@ const ModernMessageGroup: React.FC<MessageGroupProps> = ({
|
|
|
913
917
|
author,
|
|
914
918
|
messages,
|
|
915
919
|
currentUser,
|
|
920
|
+
showAuthorName = false,
|
|
921
|
+
showAvatar = false,
|
|
916
922
|
onOpen,
|
|
917
923
|
onMessageClick,
|
|
918
924
|
isDesktopView = false,
|
|
@@ -921,7 +927,16 @@ const ModernMessageGroup: React.FC<MessageGroupProps> = ({
|
|
|
921
927
|
// Inject CSS styles for HTML content
|
|
922
928
|
useInjectStyles();
|
|
923
929
|
|
|
924
|
-
const isOwnMessage = author?.id === currentUser?.id;
|
|
930
|
+
//const isOwnMessage = author?.id === currentUser?.id;
|
|
931
|
+
//const isOwnMessage = messages.some((message: any) => (message as any)?.propsConfiguration?.contents?.role === AiAgentMessageRole.User);
|
|
932
|
+
const isOwnMessage =
|
|
933
|
+
messages.some(
|
|
934
|
+
(message: any) => (message as any)?.propsConfiguration?.contents?.role === AiAgentMessageRole.User,
|
|
935
|
+
) ||
|
|
936
|
+
(Array.isArray(author?.alias) &&
|
|
937
|
+
typeof currentUser?.authUserId === 'string' &&
|
|
938
|
+
author.alias.some((alias: string) => alias?.toLowerCase() === currentUser.authUserId.toLowerCase()));
|
|
939
|
+
|
|
925
940
|
const authorName =
|
|
926
941
|
author?.givenName && author?.familyName
|
|
927
942
|
? `${author.givenName} ${author.familyName}`
|
|
@@ -938,6 +953,9 @@ const ModernMessageGroup: React.FC<MessageGroupProps> = ({
|
|
|
938
953
|
author?.username?.toLowerCase().includes('ai') ||
|
|
939
954
|
author?.username?.toLowerCase().includes('assistant') ||
|
|
940
955
|
author?.username?.toLowerCase().includes('system');
|
|
956
|
+
// const isSystemMessage = messages.some(
|
|
957
|
+
// (message: any) => (message as any)?.propsConfiguration?.contents?.role === AiAgentMessageRole.Assistant,
|
|
958
|
+
// );
|
|
941
959
|
|
|
942
960
|
// For user messages, don't show group header, just individual messages with avatars
|
|
943
961
|
if (isOwnMessage) {
|
|
@@ -957,6 +975,8 @@ const ModernMessageGroup: React.FC<MessageGroupProps> = ({
|
|
|
957
975
|
isLastInGroup={index === messages.length - 1}
|
|
958
976
|
onMessageClick={onMessageClick}
|
|
959
977
|
formatTime={formatTime}
|
|
978
|
+
showAuthorName={showAuthorName}
|
|
979
|
+
showAvatar={showAvatar}
|
|
960
980
|
/>
|
|
961
981
|
))}
|
|
962
982
|
</div>
|
|
@@ -976,7 +996,7 @@ const ModernMessageGroup: React.FC<MessageGroupProps> = ({
|
|
|
976
996
|
}`}
|
|
977
997
|
>
|
|
978
998
|
{/* Enhanced Avatar - Only show for non-system messages */}
|
|
979
|
-
{!isSystemMessage && (
|
|
999
|
+
{/* {!isSystemMessage && (
|
|
980
1000
|
<div className="flex-shrink-0 mt-1">
|
|
981
1001
|
<div className="relative rounded-lg overflow-hidden">
|
|
982
1002
|
<img
|
|
@@ -992,15 +1012,15 @@ const ModernMessageGroup: React.FC<MessageGroupProps> = ({
|
|
|
992
1012
|
/>
|
|
993
1013
|
</div>
|
|
994
1014
|
</div>
|
|
995
|
-
)}
|
|
1015
|
+
)} */}
|
|
996
1016
|
|
|
997
1017
|
<div className="flex-1 min-w-0 overflow-hidden">
|
|
998
1018
|
{/* Enhanced author header - Only show for non-system messages */}
|
|
999
|
-
{!isSystemMessage && (
|
|
1019
|
+
{/* {!isSystemMessage && (
|
|
1000
1020
|
<div className="flex items-center space-x-3 mb-2">
|
|
1001
1021
|
<span className="font-semibold truncate text-gray-900">{authorName}</span>
|
|
1002
1022
|
</div>
|
|
1003
|
-
)}
|
|
1023
|
+
)} */}
|
|
1004
1024
|
|
|
1005
1025
|
{/* Enhanced Messages with rich formatting */}
|
|
1006
1026
|
<div className="space-y-1">
|
|
@@ -1024,6 +1044,8 @@ const ModernMessageGroup: React.FC<MessageGroupProps> = ({
|
|
|
1024
1044
|
};
|
|
1025
1045
|
|
|
1026
1046
|
interface ModernMessageBubbleProps {
|
|
1047
|
+
showAuthorName?: boolean;
|
|
1048
|
+
showAvatar?: boolean;
|
|
1027
1049
|
message: IPost;
|
|
1028
1050
|
isOwnMessage: boolean;
|
|
1029
1051
|
isSystemMessage: boolean;
|
|
@@ -1034,6 +1056,8 @@ interface ModernMessageBubbleProps {
|
|
|
1034
1056
|
}
|
|
1035
1057
|
|
|
1036
1058
|
const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
1059
|
+
showAuthorName = false,
|
|
1060
|
+
showAvatar = false,
|
|
1037
1061
|
message,
|
|
1038
1062
|
isOwnMessage,
|
|
1039
1063
|
isSystemMessage,
|
|
@@ -1046,8 +1070,7 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1046
1070
|
onMessageClick?.(message);
|
|
1047
1071
|
};
|
|
1048
1072
|
|
|
1049
|
-
const isAssistantRole = (message as any)?.propsConfiguration?.contents?.role ===
|
|
1050
|
-
|
|
1073
|
+
const isAssistantRole = (message as any)?.propsConfiguration?.contents?.role === AiAgentMessageRole.Assistant;
|
|
1051
1074
|
// For user messages, create a right-aligned layout with avatar and name
|
|
1052
1075
|
if (isOwnMessage) {
|
|
1053
1076
|
const authorName =
|
|
@@ -1065,7 +1088,7 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1065
1088
|
{/* Message content and timestamp on the left */}
|
|
1066
1089
|
{/* <div className="flex flex-col items-end max-w-xs lg:max-w-md"> */}
|
|
1067
1090
|
<div className="flex flex-col items-end ">
|
|
1068
|
-
{
|
|
1091
|
+
{showAuthorName && (
|
|
1069
1092
|
<div className="flex items-end space-x-2 mb-0.5">
|
|
1070
1093
|
<span className="text-sm font-semibold text-gray-900">{authorName}</span>
|
|
1071
1094
|
</div>
|
|
@@ -1123,7 +1146,7 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1123
1146
|
</div>
|
|
1124
1147
|
|
|
1125
1148
|
{/* User avatar on the right */}
|
|
1126
|
-
{
|
|
1149
|
+
{showAvatar && (
|
|
1127
1150
|
<div className="flex-shrink-0 mt-0.5">
|
|
1128
1151
|
<img
|
|
1129
1152
|
className={`w-8 h-8 sm:w-10 sm:h-10 rounded-lg ${
|
|
@@ -1131,7 +1154,8 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1131
1154
|
} transition-opacity object-cover`}
|
|
1132
1155
|
src={message.author?.picture || '/default-avatar.svg'}
|
|
1133
1156
|
alt={authorName}
|
|
1134
|
-
onClick={isAssistantRole ? undefined : handleClick}
|
|
1157
|
+
//onClick={isAssistantRole ? undefined : handleClick}
|
|
1158
|
+
onClick={isAssistantRole ? handleClick : undefined}
|
|
1135
1159
|
onError={(e) => {
|
|
1136
1160
|
e.currentTarget.src = '/default-avatar.svg';
|
|
1137
1161
|
}}
|
|
@@ -1147,9 +1171,10 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1147
1171
|
return (
|
|
1148
1172
|
<div
|
|
1149
1173
|
className={`group/message transition-all duration-200 hover:bg-gray-50 rounded-lg px-3 py-1 -mx-3 ${
|
|
1150
|
-
isSystemMessage || isAssistantRole ? '' : '
|
|
1174
|
+
isSystemMessage || isAssistantRole ? 'cursor-pointer' : ''
|
|
1151
1175
|
}`}
|
|
1152
|
-
onClick={isSystemMessage || isAssistantRole ? undefined : handleClick}
|
|
1176
|
+
// onClick={isSystemMessage || isAssistantRole ? undefined : handleClick}
|
|
1177
|
+
onClick={isSystemMessage || isAssistantRole ? handleClick : undefined}
|
|
1153
1178
|
>
|
|
1154
1179
|
<div className="flex items-start justify-between gap-3">
|
|
1155
1180
|
<div className="flex-1 min-w-0">
|
|
@@ -1200,7 +1225,7 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1200
1225
|
</div>
|
|
1201
1226
|
|
|
1202
1227
|
{/* Action buttons on hover - Only show for non-system messages */}
|
|
1203
|
-
{!isSystemMessage && (
|
|
1228
|
+
{/* {!isSystemMessage && (
|
|
1204
1229
|
<div className="flex-shrink-0 mt-1">
|
|
1205
1230
|
<div className="opacity-0 group-hover/message:opacity-100 transition-opacity duration-200 flex space-x-1">
|
|
1206
1231
|
<button className="p-1 hover:bg-gray-200 rounded transition-colors">
|
|
@@ -1235,7 +1260,7 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1235
1260
|
</button>
|
|
1236
1261
|
</div>
|
|
1237
1262
|
</div>
|
|
1238
|
-
)}
|
|
1263
|
+
)} */}
|
|
1239
1264
|
</div>
|
|
1240
1265
|
</div>
|
|
1241
1266
|
);
|
|
@@ -1244,6 +1269,8 @@ const ModernMessageBubble: React.FC<ModernMessageBubbleProps> = ({
|
|
|
1244
1269
|
export const ModernMessageGroupComponent: React.FC<ModernMessageGroupProps> = ({
|
|
1245
1270
|
messages,
|
|
1246
1271
|
currentUser,
|
|
1272
|
+
showAuthorName = false,
|
|
1273
|
+
showAvatar = false,
|
|
1247
1274
|
onOpen,
|
|
1248
1275
|
onMessageClick,
|
|
1249
1276
|
isDesktopView = false,
|
|
@@ -1251,7 +1278,6 @@ export const ModernMessageGroupComponent: React.FC<ModernMessageGroupProps> = ({
|
|
|
1251
1278
|
sandboxErrors = [],
|
|
1252
1279
|
currentFiles = {},
|
|
1253
1280
|
onFixError,
|
|
1254
|
-
onRecreateSandbox,
|
|
1255
1281
|
}) => {
|
|
1256
1282
|
// Inject CSS styles for HTML content
|
|
1257
1283
|
useInjectStyles();
|
|
@@ -1276,6 +1302,8 @@ export const ModernMessageGroupComponent: React.FC<ModernMessageGroupProps> = ({
|
|
|
1276
1302
|
onMessageClick={onMessageClick}
|
|
1277
1303
|
isDesktopView={isDesktopView}
|
|
1278
1304
|
isSmallScreen={isSmallScreen}
|
|
1305
|
+
showAuthorName={showAuthorName}
|
|
1306
|
+
showAvatar={showAvatar}
|
|
1279
1307
|
/>
|
|
1280
1308
|
);
|
|
1281
1309
|
})}
|