vzcode 2.4.0 → 2.6.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.
- package/dist/assets/{index-DuUjtrt6.js → index-Bfp1zhR4.js} +64 -64
- package/dist/assets/{index-BoFeK4GL.css → index-Bjj9VRMn.css} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/client/VZCodeContext/types.ts +4 -1
- package/src/client/VZCodeContext/useVZCodeState.ts +91 -3
- package/src/client/VZSidebar/AIChat/index.tsx +3 -1
- package/src/client/VZSidebar/VisualEditor.tsx +367 -118
- package/src/client/VZSidebar/styles.scss +348 -0
- package/src/types.ts +14 -3
package/dist/index.html
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
|
|
21
21
|
rel="stylesheet"
|
|
22
22
|
/>
|
|
23
|
-
<script type="module" crossorigin src="/assets/index-
|
|
24
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
23
|
+
<script type="module" crossorigin src="/assets/index-Bfp1zhR4.js"></script>
|
|
24
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Bjj9VRMn.css">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
|
27
27
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -244,5 +244,8 @@ export interface VZCodeProviderProps {
|
|
|
244
244
|
chatId: string;
|
|
245
245
|
}>;
|
|
246
246
|
iframeRef?: React.MutableRefObject<HTMLIFrameElement>;
|
|
247
|
-
handleChatError?: (
|
|
247
|
+
handleChatError?: (
|
|
248
|
+
error: string,
|
|
249
|
+
message?: string,
|
|
250
|
+
) => void;
|
|
248
251
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCallback,
|
|
3
|
+
useEffect,
|
|
3
4
|
useMemo,
|
|
4
5
|
useReducer,
|
|
5
6
|
useRef,
|
|
@@ -299,10 +300,10 @@ export const useVZCodeState = ({
|
|
|
299
300
|
|
|
300
301
|
// Create the combined setAIErrorMessage function that calls both state setter and external callback
|
|
301
302
|
const setAIErrorMessage = useCallback(
|
|
302
|
-
(error: string | null) => {
|
|
303
|
+
(error: string | null, message?: string) => {
|
|
303
304
|
setAIErrorMessageState(error);
|
|
304
305
|
if (error && handleChatError) {
|
|
305
|
-
handleChatError(error);
|
|
306
|
+
handleChatError(error, message);
|
|
306
307
|
}
|
|
307
308
|
},
|
|
308
309
|
[handleChatError],
|
|
@@ -440,7 +441,10 @@ export const useVZCodeState = ({
|
|
|
440
441
|
}
|
|
441
442
|
|
|
442
443
|
// For other errors, show the error message
|
|
443
|
-
setAIErrorMessage(
|
|
444
|
+
setAIErrorMessage(
|
|
445
|
+
errorMessage,
|
|
446
|
+
messageContent.trim(),
|
|
447
|
+
);
|
|
444
448
|
return;
|
|
445
449
|
}
|
|
446
450
|
|
|
@@ -450,6 +454,7 @@ export const useVZCodeState = ({
|
|
|
450
454
|
console.error('Error getting AI response:', error);
|
|
451
455
|
setAIErrorMessage(
|
|
452
456
|
'Failed to send message. Please try again.',
|
|
457
|
+
messageContent.trim(),
|
|
453
458
|
);
|
|
454
459
|
}
|
|
455
460
|
},
|
|
@@ -464,6 +469,89 @@ export const useVZCodeState = ({
|
|
|
464
469
|
],
|
|
465
470
|
);
|
|
466
471
|
|
|
472
|
+
// Config.json change detection and iframe notification
|
|
473
|
+
// This logic was moved from VisualEditor.tsx to ensure it runs
|
|
474
|
+
// even when the visual editor is not open, fixing cross-client propagation
|
|
475
|
+
const previousConfigRef = useRef<any>(null);
|
|
476
|
+
const CONFIG_FILE_NAME = 'config.json';
|
|
477
|
+
|
|
478
|
+
useEffect(() => {
|
|
479
|
+
// Find config.json file
|
|
480
|
+
let configFileId = null;
|
|
481
|
+
for (const fileId in files) {
|
|
482
|
+
if (files[fileId].name === CONFIG_FILE_NAME) {
|
|
483
|
+
configFileId = fileId;
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if (!configFileId || !files || !files[configFileId]) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
let newConfigData;
|
|
493
|
+
try {
|
|
494
|
+
newConfigData = JSON.parse(files[configFileId].text);
|
|
495
|
+
} catch (error) {
|
|
496
|
+
// If config is invalid JSON, we can't process changes
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
const previousConfig = previousConfigRef.current;
|
|
501
|
+
|
|
502
|
+
// Update the ref with the new config
|
|
503
|
+
previousConfigRef.current = newConfigData;
|
|
504
|
+
|
|
505
|
+
// Skip processing if this is the first time or if there's no previous config
|
|
506
|
+
if (!previousConfig) {
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// Find changed top-level properties
|
|
511
|
+
const changedProperties: { [key: string]: any } = {};
|
|
512
|
+
|
|
513
|
+
// Check all properties in the new config
|
|
514
|
+
for (const key in newConfigData) {
|
|
515
|
+
if (newConfigData[key] !== previousConfig[key]) {
|
|
516
|
+
// Deep comparison for objects to detect actual changes
|
|
517
|
+
if (
|
|
518
|
+
typeof newConfigData[key] === 'object' &&
|
|
519
|
+
typeof previousConfig[key] === 'object'
|
|
520
|
+
) {
|
|
521
|
+
if (
|
|
522
|
+
JSON.stringify(newConfigData[key]) !==
|
|
523
|
+
JSON.stringify(previousConfig[key])
|
|
524
|
+
) {
|
|
525
|
+
changedProperties[key] = newConfigData[key];
|
|
526
|
+
}
|
|
527
|
+
} else {
|
|
528
|
+
changedProperties[key] = newConfigData[key];
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// Check for deleted properties (properties that existed before but don't exist now)
|
|
534
|
+
for (const key in previousConfig) {
|
|
535
|
+
if (!(key in newConfigData)) {
|
|
536
|
+
changedProperties[key] = undefined;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// Send changed properties to iframe if any changes were detected
|
|
541
|
+
if (Object.keys(changedProperties).length > 0) {
|
|
542
|
+
try {
|
|
543
|
+
iframeRef.current?.contentWindow?.postMessage(
|
|
544
|
+
changedProperties,
|
|
545
|
+
);
|
|
546
|
+
} catch (error) {
|
|
547
|
+
console.error(
|
|
548
|
+
'Failed to send config changes to iframe:',
|
|
549
|
+
error,
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}, [files, iframeRef]);
|
|
554
|
+
|
|
467
555
|
// Return the context value
|
|
468
556
|
return {
|
|
469
557
|
content,
|
|
@@ -13,6 +13,8 @@ const DEBUG = false;
|
|
|
13
13
|
|
|
14
14
|
const showSuggestedRequests = false;
|
|
15
15
|
|
|
16
|
+
const showPreviousChats = false;
|
|
17
|
+
|
|
16
18
|
// Component for displaying the list of existing chats
|
|
17
19
|
const ChatList = ({
|
|
18
20
|
chats,
|
|
@@ -184,7 +186,7 @@ export const AIChat = () => {
|
|
|
184
186
|
<div className="ai-chat-empty-text">
|
|
185
187
|
How can I help you?
|
|
186
188
|
</div>
|
|
187
|
-
{hasExistingChats && (
|
|
189
|
+
{hasExistingChats && showPreviousChats && (
|
|
188
190
|
<ChatList
|
|
189
191
|
chats={existingChats}
|
|
190
192
|
selectedChatId={selectedChatId}
|