@messenger-box/tailwind-ui-inbox 10.0.3-alpha.144 → 10.0.3-alpha.158
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 +32 -0
- package/lib/components/AIAgent/AIAgent.d.ts.map +1 -1
- package/lib/components/AIAgent/AIAgent.js +1 -55
- package/lib/components/AIAgent/AIAgent.js.map +1 -1
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.d.ts +1 -2
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.d.ts.map +1 -1
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.js.map +1 -1
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts +2 -2
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts.map +1 -1
- package/lib/components/ModelConfigPanel.d.ts +11 -0
- package/lib/components/ModelConfigPanel.d.ts.map +1 -1
- package/lib/components/ModelConfigPanel.js +29 -2
- package/lib/components/ModelConfigPanel.js.map +1 -1
- package/lib/components/filler-components/RightSiderBar.d.ts +1 -28
- package/lib/components/filler-components/RightSiderBar.d.ts.map +1 -1
- package/lib/components/filler-components/RightSiderBar.js +531 -458
- package/lib/components/filler-components/RightSiderBar.js.map +1 -1
- package/lib/container/Inbox.js +1 -1
- package/lib/container/Inbox.js.map +1 -1
- package/lib/container/ServiceInbox.js +1 -1
- package/lib/container/ServiceInbox.js.map +1 -1
- package/lib/container/TestInboxWithAiLoader.d.ts.map +1 -1
- package/lib/container/TestInboxWithAiLoader.js +1 -11
- package/lib/container/TestInboxWithAiLoader.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/hooks/index.d.ts +0 -1
- package/lib/hooks/index.d.ts.map +1 -1
- package/lib/hooks/usePersistentModelConfig.d.ts +1 -0
- package/lib/hooks/usePersistentModelConfig.d.ts.map +1 -1
- package/lib/hooks/usePersistentModelConfig.js +1 -0
- package/lib/hooks/usePersistentModelConfig.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/module.js +1 -1
- package/lib/module.js.map +1 -1
- package/lib/templates/InboxWithAi.d.ts.map +1 -1
- package/lib/templates/InboxWithAi.js +2 -15
- package/lib/templates/InboxWithAi.js.map +1 -1
- package/lib/templates/InboxWithAi.tsx +2 -24
- package/package.json +4 -4
- package/src/components/AIAgent/AIAgent.tsx +3 -54
- package/src/components/InboxMessage/message-widgets/ErrorFixCard.tsx +1 -2
- package/src/components/InboxMessage/message-widgets/ModernMessageGroup.tsx +2 -2
- package/src/components/ModelConfigPanel.tsx +59 -0
- package/src/components/filler-components/RightSiderBar.tsx +570 -566
- package/src/container/TestInboxWithAiLoader.tsx +0 -8
- package/src/hooks/index.ts +0 -1
- package/src/hooks/usePersistentModelConfig.ts +2 -0
- package/src/templates/InboxWithAi.tsx +2 -24
- package/lib/components/live-code-editor/hybrid-live-editor.js +0 -68
- package/lib/components/live-code-editor/hybrid-live-editor.js.map +0 -1
- package/lib/components/live-code-editor/live-code-editor.js +0 -207
- package/lib/components/live-code-editor/live-code-editor.js.map +0 -1
- package/lib/hooks/use-file-sync.d.ts +0 -16
- package/lib/hooks/use-file-sync.d.ts.map +0 -1
- package/lib/hooks/use-file-sync.js +0 -63
- package/lib/hooks/use-file-sync.js.map +0 -1
- package/lib/utils/utils.js +0 -3
- package/lib/utils/utils.js.map +0 -1
- package/lib/xstate/rightSidebar.machine.js +0 -325
- package/lib/xstate/rightSidebar.machine.js.map +0 -1
- package/src/hooks/use-file-sync.ts +0 -91
|
@@ -1,459 +1,532 @@
|
|
|
1
|
-
import*as React from'react'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
1
|
+
import*as React from'react';// import { HybridLiveEditor, HybridLiveEditorRef } from '../live-code-editor/hybrid-live-editor';
|
|
2
|
+
// import { useOnChatMessageAddedSubscription } from 'common/graphql';
|
|
3
|
+
// import { AiAgentMessageRole, ICreateChannelInput, PostTypeEnum, RoomType } from 'common';
|
|
4
|
+
// import { Sandbox } from '@e2b/code-interpreter';
|
|
5
|
+
// import { useMachine } from '@xstate/react';
|
|
6
|
+
// import { fromPromise } from 'xstate';
|
|
7
|
+
// import { rightSidebarMachine } from '../../xstate';
|
|
8
|
+
// type RightSidebarProps = {
|
|
9
|
+
// channelId: string;
|
|
10
|
+
// detailSidebarOptions: {
|
|
11
|
+
// isMobileView: boolean;
|
|
12
|
+
// isSmallTabletView: boolean;
|
|
13
|
+
// isTabletView: boolean;
|
|
14
|
+
// isDesktopView: boolean;
|
|
15
|
+
// isLargeDesktopView: boolean;
|
|
16
|
+
// isSmallScreen: boolean;
|
|
17
|
+
// [key: string]: any;
|
|
18
|
+
// };
|
|
19
|
+
// windowWidth: number;
|
|
20
|
+
// windowHeight: number;
|
|
21
|
+
// activeTab?: string;
|
|
22
|
+
// selectedPost?: any;
|
|
23
|
+
// messages?: any[];
|
|
24
|
+
// setIsLoading?: (isLoading: boolean) => void;
|
|
25
|
+
// handleSendMessage?: (createChannelInput: ICreateChannelInput) => void;
|
|
26
|
+
// handleRecreateSandbox?: (messageId: string) => void | Promise<any>;
|
|
27
|
+
// isMinimized?: boolean;
|
|
28
|
+
// isLoading?: boolean;
|
|
29
|
+
// isCreatingSandbox?: boolean;
|
|
30
|
+
// setIsCreatingSandbox?: (isCreatingSandbox: boolean) => void;
|
|
31
|
+
// [key: string]: any;
|
|
32
|
+
// };
|
|
33
|
+
// export const RightSidebarFillComponent = (props: RightSidebarProps) => {
|
|
34
|
+
// const {
|
|
35
|
+
// channelId,
|
|
36
|
+
// detailSidebarOptions,
|
|
37
|
+
// windowWidth,
|
|
38
|
+
// windowHeight,
|
|
39
|
+
// activeTab,
|
|
40
|
+
// messages,
|
|
41
|
+
// selectedPost,
|
|
42
|
+
// setIsLoading,
|
|
43
|
+
// isLoading,
|
|
44
|
+
// handleSendMessage,
|
|
45
|
+
// handleRecreateSandbox,
|
|
46
|
+
// isMinimized,
|
|
47
|
+
// isCreatingSandbox,
|
|
48
|
+
// setIsCreatingSandbox,
|
|
49
|
+
// } = props;
|
|
50
|
+
// const hybridLiveEditorRef = React.useRef<HybridLiveEditorRef>(null);
|
|
51
|
+
// const previewIframeRef = React.useRef<HTMLIFrameElement>(null);
|
|
52
|
+
// const previewIframeContainerRef = React.useRef<HTMLIFrameElement>(null);
|
|
53
|
+
// // State for subscription data
|
|
54
|
+
// const [subscriptionData, setSubscriptionData] = React.useState<any>(null);
|
|
55
|
+
// // XState machine for sidebar state
|
|
56
|
+
// const [state, send] = useMachine(
|
|
57
|
+
// rightSidebarMachine.provide({
|
|
58
|
+
// actors: {
|
|
59
|
+
// recreateSandbox: fromPromise(async ({ input }) => {
|
|
60
|
+
// const { id } = input as { id: string };
|
|
61
|
+
// if (handleRecreateSandbox) {
|
|
62
|
+
// await handleRecreateSandbox(id);
|
|
63
|
+
// }
|
|
64
|
+
// return { success: true } as const;
|
|
65
|
+
// }),
|
|
66
|
+
// },
|
|
67
|
+
// }),
|
|
68
|
+
// {
|
|
69
|
+
// input: {
|
|
70
|
+
// channelId: channelId || '',
|
|
71
|
+
// isMinimized: !!isMinimized,
|
|
72
|
+
// windowWidth,
|
|
73
|
+
// windowHeight,
|
|
74
|
+
// isLoading: !!isLoading,
|
|
75
|
+
// activeFragment: null,
|
|
76
|
+
// currentFiles: {},
|
|
77
|
+
// canvasLayers: [],
|
|
78
|
+
// previewStatus: null,
|
|
79
|
+
// },
|
|
80
|
+
// },
|
|
81
|
+
// );
|
|
82
|
+
// const activeFragment = state.context.activeFragment;
|
|
83
|
+
// const currentFiles = state.context.currentFiles;
|
|
84
|
+
// const canvasLayers = state.context.canvasLayers as any[];
|
|
85
|
+
// const previewStatus = state.context.previewStatus as { code?: number; message?: string; status?: string } | null;
|
|
86
|
+
// // const [isLoading, setIsLoading] = React.useState(false);
|
|
87
|
+
// const { data: chatMessageAddedData } = useOnChatMessageAddedSubscription({
|
|
88
|
+
// variables: { channelId: channelId?.toString() || '' },
|
|
89
|
+
// skip: !channelId,
|
|
90
|
+
// });
|
|
91
|
+
// // Component mount tracking
|
|
92
|
+
// const componentId = React.useMemo(
|
|
93
|
+
// () => `right-sidebar-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
94
|
+
// [],
|
|
95
|
+
// );
|
|
96
|
+
// const handleCopyToClipboard = React.useCallback((text: string) => {
|
|
97
|
+
// navigator.clipboard.writeText(text);
|
|
98
|
+
// }, []);
|
|
99
|
+
// const handleFileUpdate = React.useCallback(async (filePath: string, content: string) => {
|
|
100
|
+
// // TODO: Implement file update logic for the channel
|
|
101
|
+
// console.log('File update:', { filePath, content });
|
|
102
|
+
// }, []);
|
|
103
|
+
// // Create complete file context by merging currentFiles with activeFragment files
|
|
104
|
+
// const completeFileContext = React.useMemo(() => {
|
|
105
|
+
// if (!activeFragment?.files) {
|
|
106
|
+
// console.log('📂 Using currentFiles as complete context (no activeFragment.files)');
|
|
107
|
+
// return currentFiles;
|
|
108
|
+
// }
|
|
109
|
+
// // Merge currentFiles with activeFragment files, giving priority to activeFragment files
|
|
110
|
+
// const merged = { ...currentFiles };
|
|
111
|
+
// // Override with activeFragment files (these are the most recent changes)
|
|
112
|
+
// Object.entries(activeFragment.files).forEach(([path, content]) => {
|
|
113
|
+
// merged[path] = content as string;
|
|
114
|
+
// });
|
|
115
|
+
// // Validate file context integrity
|
|
116
|
+
// const hasPackageJson = 'package.json' in merged;
|
|
117
|
+
// const hasMainFiles = Object.keys(merged).some(
|
|
118
|
+
// (path) =>
|
|
119
|
+
// path.includes('index.') || path.includes('main.') || path.includes('App.') || path.includes('src/'),
|
|
120
|
+
// );
|
|
121
|
+
// console.log('📂 Complete file context created:', {
|
|
122
|
+
// currentFilesCount: Object.keys(currentFiles).length,
|
|
123
|
+
// activeFragmentFilesCount: Object.keys(activeFragment.files).length,
|
|
124
|
+
// mergedFilesCount: Object.keys(merged).length,
|
|
125
|
+
// hasPackageJson,
|
|
126
|
+
// hasMainFiles,
|
|
127
|
+
// activeFragmentFiles: Object.keys(activeFragment.files),
|
|
128
|
+
// allFiles: Object.keys(merged),
|
|
129
|
+
// validation: {
|
|
130
|
+
// isComplete: hasPackageJson && hasMainFiles,
|
|
131
|
+
// missingPackageJson: !hasPackageJson,
|
|
132
|
+
// missingMainFiles: !hasMainFiles,
|
|
133
|
+
// },
|
|
134
|
+
// });
|
|
135
|
+
// if (!hasPackageJson) {
|
|
136
|
+
// console.warn('⚠️ File context missing package.json - this may cause issues in sandbox');
|
|
137
|
+
// }
|
|
138
|
+
// if (!hasMainFiles) {
|
|
139
|
+
// console.warn('⚠️ File context missing main application files - this may cause issues in sandbox');
|
|
140
|
+
// }
|
|
141
|
+
// return merged;
|
|
142
|
+
// }, [currentFiles, activeFragment?.files]);
|
|
143
|
+
// // Determine if we should show preview or editor based on activeTab
|
|
144
|
+
// const isPreviewMode = activeTab === 'preview';
|
|
145
|
+
// // Turn on loader when new data is about to be processed
|
|
146
|
+
// React.useEffect(() => {
|
|
147
|
+
// if (chatMessageAddedData?.chatMessageAdded || selectedPost) {
|
|
148
|
+
// // sync external loader
|
|
149
|
+
// // setIsLoading?.(false);
|
|
150
|
+
// // send({ type: 'SET_LOADING', isLoading: false });
|
|
151
|
+
// }
|
|
152
|
+
// }, [chatMessageAddedData, selectedPost, send, setIsLoading]);
|
|
153
|
+
// // Handle subscription data updates - prefer response update structure like use-ai-messages.ts
|
|
154
|
+
// React.useEffect(() => {
|
|
155
|
+
// if (chatMessageAddedData?.chatMessageAdded || selectedPost) {
|
|
156
|
+
// // Prefer explicitly selected post to ensure UI updates when it changes
|
|
157
|
+
// const message = selectedPost || chatMessageAddedData?.chatMessageAdded;
|
|
158
|
+
// // Extract strictly from message.propsConfiguration (fragment only)
|
|
159
|
+
// let extracted: any = null;
|
|
160
|
+
// let fragmentSource:
|
|
161
|
+
// | 'propsConfiguration.contents.props.fragment'
|
|
162
|
+
// | 'propsConfiguration.contents.fragment'
|
|
163
|
+
// | 'propsConfiguration.fragment'
|
|
164
|
+
// | null = null;
|
|
165
|
+
// try {
|
|
166
|
+
// // 1) Preferred: contents.props.fragment
|
|
167
|
+
// const cfg: any = message.propsConfiguration || {};
|
|
168
|
+
// const contents: any = cfg.contents || cfg.content || {};
|
|
169
|
+
// if (contents?.props?.fragment) {
|
|
170
|
+
// const frag = contents.props.fragment;
|
|
171
|
+
// extracted = {
|
|
172
|
+
// sandboxUrl: frag.sandboxUrl || frag.url,
|
|
173
|
+
// sandboxId: frag.sandboxId,
|
|
174
|
+
// projectId: cfg.projectId || contents.projectId || frag.projectId,
|
|
175
|
+
// modelConfig: cfg.modelConfig || contents.modelConfig || frag.modelConfig,
|
|
176
|
+
// files: frag.files || {},
|
|
177
|
+
// canvasLayers: contents.canvasLayers || cfg.canvasLayers || frag.canvasLayers,
|
|
178
|
+
// summary: contents.summary || cfg.summary || frag.summary,
|
|
179
|
+
// title: frag.title || contents.title || cfg.title,
|
|
180
|
+
// isError: frag.isError,
|
|
181
|
+
// };
|
|
182
|
+
// fragmentSource = 'propsConfiguration.contents.props.fragment';
|
|
183
|
+
// }
|
|
184
|
+
// // 2) Fallback: contents.fragment
|
|
185
|
+
// if (!extracted && contents?.fragment) {
|
|
186
|
+
// const frag = contents.fragment;
|
|
187
|
+
// extracted = {
|
|
188
|
+
// sandboxUrl: frag.sandboxUrl || frag.url,
|
|
189
|
+
// sandboxId: frag.sandboxId,
|
|
190
|
+
// projectId: cfg.projectId || contents.projectId || frag.projectId,
|
|
191
|
+
// modelConfig: cfg.modelConfig || contents.modelConfig || frag.modelConfig,
|
|
192
|
+
// files: frag.files || {},
|
|
193
|
+
// canvasLayers: contents.canvasLayers || cfg.canvasLayers || frag.canvasLayers,
|
|
194
|
+
// summary: contents.summary || cfg.summary || frag.summary,
|
|
195
|
+
// title: frag.title || contents.title || cfg.title,
|
|
196
|
+
// isError: frag.isError,
|
|
197
|
+
// };
|
|
198
|
+
// fragmentSource = 'propsConfiguration.contents.fragment';
|
|
199
|
+
// }
|
|
200
|
+
// // 3) Fallback: propsConfiguration.fragment (top-level)
|
|
201
|
+
// if (!extracted && cfg?.fragment) {
|
|
202
|
+
// const frag = cfg.fragment;
|
|
203
|
+
// extracted = {
|
|
204
|
+
// sandboxUrl: frag.sandboxUrl || frag.url,
|
|
205
|
+
// sandboxId: frag.sandboxId,
|
|
206
|
+
// projectId: cfg.projectId || frag.projectId,
|
|
207
|
+
// modelConfig: cfg.modelConfig || frag.modelConfig,
|
|
208
|
+
// files: frag.files || {},
|
|
209
|
+
// canvasLayers: cfg.canvasLayers || frag.canvasLayers,
|
|
210
|
+
// summary: cfg.summary || frag.summary,
|
|
211
|
+
// title: frag.title || cfg.title,
|
|
212
|
+
// isError: frag.isError,
|
|
213
|
+
// };
|
|
214
|
+
// fragmentSource = 'propsConfiguration.fragment';
|
|
215
|
+
// }
|
|
216
|
+
// } catch (error) {
|
|
217
|
+
// console.error('Error extracting response from message:', error);
|
|
218
|
+
// }
|
|
219
|
+
// // console.log('Extracted response fragment source:', fragmentSource);
|
|
220
|
+
// // console.log('Extracted response:', extracted);
|
|
221
|
+
// if (extracted && (extracted.sandboxUrl || extracted.url)) {
|
|
222
|
+
// console.log('✅ Processing response update:', extracted);
|
|
223
|
+
// // Update subscription data snapshot
|
|
224
|
+
// setSubscriptionData(extracted);
|
|
225
|
+
// // Build active fragment
|
|
226
|
+
// const fragment = {
|
|
227
|
+
// id: message.id,
|
|
228
|
+
// sandboxUrl: extracted.sandboxUrl || extracted.url,
|
|
229
|
+
// sandboxId: extracted.sandboxId,
|
|
230
|
+
// title: extracted.title || 'Generated Code',
|
|
231
|
+
// files: extracted.files || {},
|
|
232
|
+
// projectId: extracted.projectId,
|
|
233
|
+
// modelConfig: extracted.modelConfig,
|
|
234
|
+
// canvasLayers: extracted.canvasLayers,
|
|
235
|
+
// summary: extracted.summary,
|
|
236
|
+
// isError: extracted.isError,
|
|
237
|
+
// };
|
|
238
|
+
// // If canvasLayers missing but present in summary, attempt to extract like use-ai-messages
|
|
239
|
+
// if ((!fragment.canvasLayers || !Array.isArray(fragment.canvasLayers)) && fragment.summary) {
|
|
240
|
+
// try {
|
|
241
|
+
// const match = (fragment.summary as string).match(/<canvas_layers>([\s\S]*?)<\/canvas_layers>/);
|
|
242
|
+
// if (match) {
|
|
243
|
+
// const parsed = JSON.parse(match[1]);
|
|
244
|
+
// if (Array.isArray(parsed)) {
|
|
245
|
+
// fragment.canvasLayers = parsed;
|
|
246
|
+
// }
|
|
247
|
+
// }
|
|
248
|
+
// } catch (e) {
|
|
249
|
+
// console.warn('Failed to parse canvas layers from summary:', e);
|
|
250
|
+
// }
|
|
251
|
+
// }
|
|
252
|
+
// console.log('✅ Setting active fragment via XState:', fragment);
|
|
253
|
+
// send({ type: 'SET_FRAGMENT', fragment });
|
|
254
|
+
// // setIsLoading?.(false);
|
|
255
|
+
// //send({ type: 'SET_LOADING', isLoading: false });
|
|
256
|
+
// } else {
|
|
257
|
+
// console.log('❌ No valid response found in message');
|
|
258
|
+
// // setIsLoading?.(false);
|
|
259
|
+
// // send({ type: 'SET_LOADING', isLoading: false });
|
|
260
|
+
// }
|
|
261
|
+
// }
|
|
262
|
+
// }, [chatMessageAddedData, selectedPost, send, setIsLoading]);
|
|
263
|
+
// // When switching tabs or when sandbox changes, show loader until ready
|
|
264
|
+
// // React.useEffect(() => {
|
|
265
|
+
// // if (isPreviewMode) {
|
|
266
|
+
// // if (activeFragment?.sandboxUrl) {
|
|
267
|
+
// // // setIsLoading(true);
|
|
268
|
+
// // }
|
|
269
|
+
// // } else {
|
|
270
|
+
// // // In code view, briefly show loader while editor reacts to new files
|
|
271
|
+
// // // setIsLoading(true);
|
|
272
|
+
// // const timeoutId = setTimeout(() => setIsLoading(false), 400);
|
|
273
|
+
// // return () => clearTimeout(timeoutId);
|
|
274
|
+
// // }
|
|
275
|
+
// // }, [isPreviewMode, activeFragment?.sandboxUrl, completeFileContext]);
|
|
276
|
+
// // Cleanup iframe resources on unmount to prevent renderer leaks in Chrome
|
|
277
|
+
// React.useEffect(() => {
|
|
278
|
+
// return () => {
|
|
279
|
+
// try {
|
|
280
|
+
// if (previewIframeRef.current) {
|
|
281
|
+
// previewIframeRef.current.src = 'about:blank';
|
|
282
|
+
// }
|
|
283
|
+
// } catch (e) {
|
|
284
|
+
// // no-op
|
|
285
|
+
// }
|
|
286
|
+
// };
|
|
287
|
+
// }, []);
|
|
288
|
+
// React.useEffect(() => {
|
|
289
|
+
// const handleVisualEditorMessage = (event: MessageEvent) => {
|
|
290
|
+
// // Handle AI changes
|
|
291
|
+
// if (event.data.type === 'VISUAL_EDITOR_CHANGES') {
|
|
292
|
+
// console.log('visual_editor_changes....', event.data.message);
|
|
293
|
+
// if (handleSendMessage && event.data.message) {
|
|
294
|
+
// // Call aiHandleSend directly - this is the handleSend function from AIAgent
|
|
295
|
+
// handleSendMessage({
|
|
296
|
+
// channelId,
|
|
297
|
+
// type: RoomType.Aiassistant,
|
|
298
|
+
// postData: {
|
|
299
|
+
// // postId: postId,
|
|
300
|
+
// type: PostTypeEnum.Aiassistant,
|
|
301
|
+
// content: event.data.message,
|
|
302
|
+
// },
|
|
303
|
+
// });
|
|
304
|
+
// } else {
|
|
305
|
+
// console.warn('⚠️ handleSendMessage not available or no message provided');
|
|
306
|
+
// }
|
|
307
|
+
// }
|
|
308
|
+
// };
|
|
309
|
+
// window.addEventListener('message', handleVisualEditorMessage);
|
|
310
|
+
// return () => window.removeEventListener('message', handleVisualEditorMessage);
|
|
311
|
+
// }, [handleSendMessage, channelId]);
|
|
312
|
+
// const recreateSandboxHandler = React.useCallback(
|
|
313
|
+
// async (id: string) => {
|
|
314
|
+
// if (id) {
|
|
315
|
+
// console.log('recreate sandbox id....', id);
|
|
316
|
+
// setIsLoading?.(true);
|
|
317
|
+
// send({ type: 'SET_LOADING', isLoading: true });
|
|
318
|
+
// try {
|
|
319
|
+
// send({ type: 'RECREATE_SANDBOX', id });
|
|
320
|
+
// } catch (e: any) {
|
|
321
|
+
// console.error('Error recreating sandbox:', e);
|
|
322
|
+
// setIsLoading?.(false);
|
|
323
|
+
// send({ type: 'SET_LOADING', isLoading: false });
|
|
324
|
+
// }
|
|
325
|
+
// }
|
|
326
|
+
// },
|
|
327
|
+
// [send, setIsLoading],
|
|
328
|
+
// );
|
|
329
|
+
// // Track if we've already attempted recreate for a given sandbox URL
|
|
330
|
+
// const recreateAttemptedByUrlRef = React.useRef<Record<string, boolean>>({});
|
|
331
|
+
// // Probe sandbox URL via XState actor
|
|
332
|
+
// React.useEffect(() => {
|
|
333
|
+
// const url = activeFragment?.sandboxUrl;
|
|
334
|
+
// if (url) {
|
|
335
|
+
// send({ type: 'PROBE', url, fragmentId: activeFragment?.id });
|
|
336
|
+
// }
|
|
337
|
+
// }, [activeFragment?.sandboxUrl, activeFragment?.id, send]);
|
|
338
|
+
// // Prefer using external loading when provided; otherwise fall back to machine state
|
|
339
|
+
// const derivedIsLoading = (typeof isLoading === 'boolean' ? isLoading : state.context.isLoading) as boolean;
|
|
340
|
+
// // Sync external loading prop with machine's loading state (no-op if setter not provided)
|
|
341
|
+
// // React.useEffect(() => {
|
|
342
|
+
// // console.log(
|
|
343
|
+
// // 'isLoading....',
|
|
344
|
+
// // isLoading,
|
|
345
|
+
// // ' state.context.isLoading',
|
|
346
|
+
// // state.context.isLoading,
|
|
347
|
+
// // ' previewStatus',
|
|
348
|
+
// // previewStatus,
|
|
349
|
+
// // );
|
|
350
|
+
// // if (!state.context.isLoading) {
|
|
351
|
+
// // setIsLoading?.(!!state.context.isLoading);
|
|
352
|
+
// // }
|
|
353
|
+
// // }, [state.context.isLoading, setIsLoading, isLoading]);
|
|
354
|
+
// return (
|
|
355
|
+
// <div ref={previewIframeContainerRef} className="right-sidebar-content h-full flex flex-col">
|
|
356
|
+
// <div className="flex-1 overflow-hidden" style={{ minHeight: windowHeight - 140 }}>
|
|
357
|
+
// {isPreviewMode ? (
|
|
358
|
+
// // Preview Mode - Show sandbox iframe or fallback
|
|
359
|
+
// (() => {
|
|
360
|
+
// if (activeFragment?.sandboxUrl) {
|
|
361
|
+
// return (
|
|
362
|
+
// <div
|
|
363
|
+
// className="w-full h-full relative"
|
|
364
|
+
// style={{
|
|
365
|
+
// width: isMinimized ? windowWidth * 0.8 + 'px' : '100%',
|
|
366
|
+
// height: windowHeight - 140,
|
|
367
|
+
// backgroundColor: '#f0f0f0',
|
|
368
|
+
// }}
|
|
369
|
+
// >
|
|
370
|
+
// {!previewStatus ? (
|
|
371
|
+
// <iframe
|
|
372
|
+
// key={activeFragment.sandboxUrl}
|
|
373
|
+
// ref={previewIframeRef}
|
|
374
|
+
// src={activeFragment.sandboxUrl}
|
|
375
|
+
// className="w-full w-fit h-full h-fit border border-gray-200 rounded-md bg-white shadow-sm"
|
|
376
|
+
// title="Live Preview"
|
|
377
|
+
// sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-orientation-lock allow-pointer-lock allow-presentation allow-storage-access-by-user-activation allow-top-navigation-by-user-activation"
|
|
378
|
+
// loading="lazy"
|
|
379
|
+
// onLoad={() => {
|
|
380
|
+
// console.log('🎯 Iframe loaded successfully');
|
|
381
|
+
// setIsLoading?.(false);
|
|
382
|
+
// setIsCreatingSandbox?.(false);
|
|
383
|
+
// send({ type: 'SET_LOADING', isLoading: false });
|
|
384
|
+
// }}
|
|
385
|
+
// onError={(e) => {
|
|
386
|
+
// console.error('❌ Iframe error:', e);
|
|
387
|
+
// setIsLoading?.(false);
|
|
388
|
+
// send({ type: 'SET_LOADING', isLoading: false });
|
|
389
|
+
// }}
|
|
390
|
+
// style={
|
|
391
|
+
// {
|
|
392
|
+
// // maxHeight: windowHeight - 140,
|
|
393
|
+
// // width: isMinimized ? windowWidth * 0.82 + 'px' : '100%',
|
|
394
|
+
// //padding: isMinimized ? '10px' : '0px',
|
|
395
|
+
// }
|
|
396
|
+
// }
|
|
397
|
+
// />
|
|
398
|
+
// ) : (
|
|
399
|
+
// <div className="absolute inset-0 bg-white/60 flex items-center justify-center z-20">
|
|
400
|
+
// {handleRecreateSandbox && (
|
|
401
|
+
// <>
|
|
402
|
+
// {derivedIsLoading || isCreatingSandbox ? (
|
|
403
|
+
// <div className="flex flex-col items-center justify-center gap-2">
|
|
404
|
+
// <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"></div>
|
|
405
|
+
// <p className="text-xs text-blue-700">Recreating...</p>
|
|
406
|
+
// </div>
|
|
407
|
+
// ) : (
|
|
408
|
+
// <div className="flex flex-col items-center justify-center gap-2">
|
|
409
|
+
// <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"></div>
|
|
410
|
+
// <p className="text-sm text-muted-foreground">
|
|
411
|
+
// {isLoading ? 'Recreating...' : 'Refresh'}{' '}
|
|
412
|
+
// {/* Sandbox is not available. */}
|
|
413
|
+
// </p>
|
|
414
|
+
// {/* <button
|
|
415
|
+
// type="button"
|
|
416
|
+
// className="themed-button focus-themed px-3 py-1.5 text-xs"
|
|
417
|
+
// onClick={() =>
|
|
418
|
+
// recreateSandboxHandler(activeFragment?.id)
|
|
419
|
+
// }
|
|
420
|
+
// >
|
|
421
|
+
// Recreate
|
|
422
|
+
// </button> */}
|
|
423
|
+
// </div>
|
|
424
|
+
// )}
|
|
425
|
+
// </>
|
|
426
|
+
// )}
|
|
427
|
+
// </div>
|
|
428
|
+
// )}
|
|
429
|
+
// <div className="absolute top-2 right-2 bg-green-100 text-green-800 px-2 py-1 rounded text-xs z-10">
|
|
430
|
+
// Live Preview
|
|
431
|
+
// </div>
|
|
432
|
+
// {derivedIsLoading ||
|
|
433
|
+
// (isCreatingSandbox && (
|
|
434
|
+
// <>
|
|
435
|
+
// <div className="absolute inset-0 bg-white/60 flex items-center justify-center z-20">
|
|
436
|
+
// <div className="animate-spin rounded-full h-12 w-12 border-4 border-blue-500 border-t-transparent"></div>
|
|
437
|
+
// </div>
|
|
438
|
+
// <div className="absolute top-2 left-2 bg-blue-100 text-blue-800 px-2 py-1 rounded text-xs z-30">
|
|
439
|
+
// Loading...
|
|
440
|
+
// </div>
|
|
441
|
+
// </>
|
|
442
|
+
// ))}
|
|
443
|
+
// </div>
|
|
444
|
+
// );
|
|
445
|
+
// } else {
|
|
446
|
+
// return (
|
|
447
|
+
// <div
|
|
448
|
+
// className="h-full flex items-center justify-center text-gray-500 border border-gray-200 rounded-md bg-gray-50 "
|
|
449
|
+
// style={{ width: '100%', height: '80vh' }}
|
|
450
|
+
// >
|
|
451
|
+
// <div className="text-center space-y-3">
|
|
452
|
+
// <p className="font-medium">No preview available</p>
|
|
453
|
+
// <div className="flex flex-col items-center justify-center space-y-3">
|
|
454
|
+
// {derivedIsLoading || isCreatingSandbox ? (
|
|
455
|
+
// <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"></div>
|
|
456
|
+
// ) : (
|
|
457
|
+
// <div className="w-8 h-8 bg-gray-300 rounded-full"></div>
|
|
458
|
+
// )}
|
|
459
|
+
// <p className="text-sm text-gray-400">
|
|
460
|
+
// {derivedIsLoading || isCreatingSandbox
|
|
461
|
+
// ? 'Generating code...'
|
|
462
|
+
// : 'Waiting for code generation...'}
|
|
463
|
+
// </p>
|
|
464
|
+
// </div>
|
|
465
|
+
// </div>
|
|
466
|
+
// </div>
|
|
467
|
+
// );
|
|
468
|
+
// }
|
|
469
|
+
// })()
|
|
470
|
+
// ) : (
|
|
471
|
+
// // Code Editor Mode - Show files from subscription or fallback
|
|
472
|
+
// <div
|
|
473
|
+
// className="h-full w-full relative"
|
|
474
|
+
// style={{
|
|
475
|
+
// minHeight: windowHeight - 140,
|
|
476
|
+
// height: windowHeight - 140,
|
|
477
|
+
// width: isMinimized ? windowWidth * 0.9 + 'px' : '100%',
|
|
478
|
+
// }}
|
|
479
|
+
// >
|
|
480
|
+
// <HybridLiveEditor
|
|
481
|
+
// ref={hybridLiveEditorRef}
|
|
482
|
+
// projectId={activeFragment?.projectId || channelId}
|
|
483
|
+
// fragmentId={activeFragment?.id || activeTab || 'default'}
|
|
484
|
+
// files={Object.keys(completeFileContext).length > 0 ? completeFileContext : {}}
|
|
485
|
+
// sandboxUrl={activeFragment?.sandboxUrl}
|
|
486
|
+
// onCopyToClipboard={handleCopyToClipboard}
|
|
487
|
+
// onFileUpdate={handleFileUpdate}
|
|
488
|
+
// readOnly={!activeFragment?.id}
|
|
489
|
+
// autoSave={false}
|
|
490
|
+
// debounceMs={500}
|
|
491
|
+
// //className={`h-full w-[100%] h-[75vh] border-b border-gray-200 rounded-md bg-white shadow-sm overflow-hidden`}
|
|
492
|
+
// className="h-full w-full"
|
|
493
|
+
// />
|
|
494
|
+
// {derivedIsLoading && (
|
|
495
|
+
// <>
|
|
496
|
+
// <div className="absolute inset-0 bg-white/60 flex items-center justify-center z-20">
|
|
497
|
+
// <div className="animate-spin rounded-full h-12 w-12 border-4 border-blue-500 border-t-transparent"></div>
|
|
498
|
+
// </div>
|
|
499
|
+
// <div className="absolute top-4 right-4 bg-blue-100 border border-blue-400 text-blue-700 px-3 py-2 rounded text-sm z-30">
|
|
500
|
+
// <div className="flex items-center gap-2">
|
|
501
|
+
// <div className="animate-spin rounded-full h-4 w-4 border-b-2 border-blue-500"></div>
|
|
502
|
+
// Processing...
|
|
503
|
+
// </div>
|
|
504
|
+
// </div>
|
|
505
|
+
// </>
|
|
506
|
+
// )}
|
|
507
|
+
// </div>
|
|
508
|
+
// )}
|
|
509
|
+
// </div>
|
|
510
|
+
// {/* <div className="p-2 border-t bg-gray-50 text-xs text-gray-500">
|
|
511
|
+
// <div className="flex justify-between">
|
|
512
|
+
// <span>Mobile: {detailSidebarOptions.isMobileView ? 'Yes' : 'No'}</span>
|
|
513
|
+
// <span>Desktop: {detailSidebarOptions.isDesktopView ? 'Yes' : 'No'}</span>
|
|
514
|
+
// {activeFragment && (
|
|
515
|
+
// <span className="text-green-600">{activeFragment.isError ? 'Error' : 'Ready'}</span>
|
|
516
|
+
// )}
|
|
517
|
+
// </div>
|
|
518
|
+
// {activeFragment && (
|
|
519
|
+
// <div className="mt-1 text-xs">
|
|
520
|
+
// <span className="text-gray-400">Files: {Object.keys(completeFileContext).length}</span>
|
|
521
|
+
// {canvasLayers.length > 0 && (
|
|
522
|
+
// <span className="ml-2 text-gray-400">Layers: {canvasLayers.length}</span>
|
|
523
|
+
// )}
|
|
524
|
+
// </div>
|
|
525
|
+
// )}
|
|
526
|
+
// </div> */}
|
|
527
|
+
// </div>
|
|
528
|
+
// );
|
|
529
|
+
// };
|
|
530
|
+
const RightSidebarFillComponent = props => {
|
|
531
|
+
return React.createElement(React.Fragment, null);
|
|
459
532
|
};export{RightSidebarFillComponent};//# sourceMappingURL=RightSiderBar.js.map
|