vzcode 2.8.0 → 2.10.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/index.html CHANGED
@@ -20,7 +20,7 @@
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-CCjGlbxJ.js"></script>
23
+ <script type="module" crossorigin src="/assets/index-CsDf6ybm.js"></script>
24
24
  <link rel="stylesheet" crossorigin href="/assets/index-Bjj9VRMn.css">
25
25
  </head>
26
26
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vzcode",
3
- "version": "2.8.0",
3
+ "version": "2.10.0",
4
4
  "description": "Multiplayer code editor system",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -423,18 +423,31 @@ export const useVZCodeState = ({
423
423
  errorMessage ===
424
424
  'You do not have permission to use AI chat on this visualization. Only users with edit access can use this feature. Fork the viz to edit it.'
425
425
  ) {
426
- // Trigger auto-fork instead of showing error
427
- try {
428
- await autoForkAndRetryAI?.(
429
- currentPrompt,
430
- aiChatMode,
431
- );
432
- // If we reach here, the fork was successful and redirect should happen
433
- return;
434
- } catch (forkError) {
435
- console.error('Auto-fork failed:', forkError);
426
+ // For authenticated users, trigger auto-fork
427
+ if (autoForkAndRetryAI) {
428
+ try {
429
+ await autoForkAndRetryAI(
430
+ currentPrompt,
431
+ aiChatMode,
432
+ );
433
+ // If we reach here, the fork was successful and redirect should happen
434
+ return;
435
+ } catch (forkError) {
436
+ console.error(
437
+ 'Auto-fork failed:',
438
+ forkError,
439
+ );
440
+ setAIErrorMessage(
441
+ 'Failed to fork visualization. Please try forking manually.',
442
+ );
443
+ return;
444
+ }
445
+ } else {
446
+ // For unauthenticated users, store the message and trigger login flow
447
+ // This will be handled by the external error handler
436
448
  setAIErrorMessage(
437
- 'Failed to fork visualization. Please try forking manually.',
449
+ errorMessage,
450
+ messageContent.trim(),
438
451
  );
439
452
  return;
440
453
  }
@@ -126,6 +126,8 @@ export const AIChat = () => {
126
126
  ]);
127
127
 
128
128
  // Check for stored AI prompt on component mount (post-fork restoration)
129
+ // This logic is now handled by the AutoSendAIMessage component in VizHub
130
+ // to ensure proper timing and coordination with editor opening
129
131
  useEffect(() => {
130
132
  DEBUG &&
131
133
  console.log('AIChat: Checking for stored AI prompt');
@@ -137,41 +139,29 @@ export const AIChat = () => {
137
139
  storedPrompt,
138
140
  );
139
141
  if (storedPrompt) {
140
- // Restore the prompt and mode
142
+ // Only restore the prompt and mode, but don't auto-send
143
+ // The AutoSendAIMessage component will handle the sending
141
144
  DEBUG &&
142
- console.log('AIChat: Restoring prompt and mode');
145
+ console.log(
146
+ 'AIChat: Restoring prompt and mode only',
147
+ );
143
148
  setAIChatMessage(storedPrompt.prompt);
144
149
  setAIChatMode(
145
150
  storedPrompt.modelName === 'ask' ? 'ask' : 'edit',
146
151
  );
147
152
 
148
- // Clear the stored prompt
153
+ // Don't clear the stored prompt here - let AutoSendAIMessage handle it
154
+ // Don't auto-submit here - let AutoSendAIMessage handle the timing
149
155
  DEBUG &&
150
- console.log('AIChat: Clearing stored prompt');
151
- clearStoredAIPrompt();
152
-
153
- // Auto-submit the restored prompt after a short delay
154
- DEBUG &&
155
- console.log('AIChat: Scheduling auto-submit');
156
- setTimeout(() => {
157
- DEBUG &&
158
- console.log(
159
- 'AIChat: Auto-submitting restored prompt',
160
- );
161
- handleSendMessage(storedPrompt.prompt);
162
- }, 100);
156
+ console.log(
157
+ 'AIChat: Prompt restored, waiting for AutoSendAIMessage to handle sending',
158
+ );
163
159
  } else {
164
160
  DEBUG &&
165
161
  console.log('AIChat: No stored prompt found');
166
162
  }
167
163
  }
168
- }, [
169
- getStoredAIPrompt,
170
- clearStoredAIPrompt,
171
- setAIChatMessage,
172
- setAIChatMode,
173
- handleSendMessage,
174
- ]);
164
+ }, [getStoredAIPrompt, setAIChatMessage, setAIChatMode]);
175
165
 
176
166
  return (
177
167
  <div className="ai-chat-container">
@@ -307,7 +297,6 @@ export const AIChat = () => {
307
297
  ) : (
308
298
  <MessageList
309
299
  messages={messages}
310
- aiStatus={aiStatus}
311
300
  isLoading={isLoading}
312
301
  chatId={selectedChatId || currentChatId}
313
302
  aiScratchpad={aiScratchpad}
@@ -1,7 +1,10 @@
1
1
  export type { ThemeLabel, ThemeOption } from './themes';
2
2
  export type { EditorCache } from './useEditorCache';
3
3
 
4
- export { VZCodeProvider } from './VZCodeContext';
4
+ export {
5
+ VZCodeProvider,
6
+ VZCodeContext,
7
+ } from './VZCodeContext';
5
8
  export { VZSidebar } from './VZSidebar';
6
9
  export { VZSettings } from './VZSettings';
7
10
  export { VZKeyboardShortcutsDoc } from './VZKeyboardShortcutsDoc';