vzcode 1.45.0 → 1.46.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 (33) hide show
  1. package/dist/assets/{index-C1lTrzOZ.js → index-CC0CUUDi.js} +113 -113
  2. package/dist/assets/{index-DeeOcIzw.css → index-CQyHWTWE.css} +1 -1
  3. package/dist/index.html +2 -2
  4. package/package.json +7 -3
  5. package/src/client/CodeEditor/index.tsx +7 -4
  6. package/src/client/RunCodeWidget/index.tsx +18 -15
  7. package/src/client/SplitPaneResizeContext.tsx +26 -108
  8. package/src/client/VZCodeContext.tsx +8 -1
  9. package/src/client/VZRight.tsx +32 -4
  10. package/src/client/VZSidebar/AIChat/ChatInput.tsx +72 -2
  11. package/src/client/VZSidebar/AIChat/DiffView.scss +29 -0
  12. package/src/client/VZSidebar/AIChat/DiffView.tsx +62 -1
  13. package/src/client/VZSidebar/AIChat/Message.tsx +14 -1
  14. package/src/client/VZSidebar/AIChat/MessageList.tsx +134 -13
  15. package/src/client/VZSidebar/AIChat/ThinkingScratchpad.tsx +37 -0
  16. package/src/client/VZSidebar/AIChat/index.tsx +148 -12
  17. package/src/client/VZSidebar/AIChat/styles.scss +223 -1
  18. package/src/client/VZSidebar/aiCopyPaste.ts +6 -1
  19. package/src/client/VZSidebar/index.tsx +10 -2
  20. package/src/client/bootstrap.ts +11 -1
  21. package/src/client/useActions.ts +12 -0
  22. package/src/client/usePrettier/index.ts +1 -3
  23. package/src/client/vzReducer/aiChatReducer.ts +13 -0
  24. package/src/client/vzReducer/createInitialState.ts +1 -0
  25. package/src/client/vzReducer/index.ts +9 -0
  26. package/src/client/vzReducer/searchReducer.test.ts +44 -2
  27. package/src/runCode.ts +5 -17
  28. package/src/server/aiChatHandler/aiEditing.ts +37 -0
  29. package/src/server/aiChatHandler/chatOperations.ts +38 -1
  30. package/src/server/aiChatHandler/index.ts +20 -9
  31. package/src/server/aiChatHandler/llmStreaming.ts +101 -19
  32. package/src/server/generateAIResponse.ts +4 -0
  33. package/src/server/index.ts +52 -0
@@ -14,6 +14,7 @@ import { computeInitialDocument } from './computeInitialDocument.js';
14
14
  import { handleAIAssist } from './handleAIAssist.js';
15
15
  import { handleAICopilot } from './handleAICopilot.js';
16
16
  import { handleAIChatMessage } from './handleAIChatMessage.js';
17
+ import { undoAIEdit } from './aiChatHandler/chatOperations.js';
17
18
  import { isDirectory } from './isDirectory.js';
18
19
  import { createToken } from './livekit.js';
19
20
  import './setupEnv.js';
@@ -141,6 +142,57 @@ app.post(
141
142
  }),
142
143
  );
143
144
 
145
+ // Handle AI Chat Undo requests.
146
+ app.post(
147
+ '/ai-chat-undo',
148
+ bodyParser.json(),
149
+ async (req, res) => {
150
+ const { chatId, messageId } = req.body;
151
+
152
+ if (!chatId || !messageId) {
153
+ return res
154
+ .status(400)
155
+ .json({ error: 'Missing chatId or messageId' });
156
+ }
157
+
158
+ try {
159
+ const chat = shareDBDoc.data.chats?.[chatId];
160
+ if (!chat) {
161
+ return res
162
+ .status(404)
163
+ .json({ error: 'Chat not found' });
164
+ }
165
+
166
+ const message = chat.messages.find(
167
+ (msg) => msg.id === messageId,
168
+ );
169
+ if (
170
+ !message ||
171
+ message.role !== 'assistant' ||
172
+ !message.beforeFiles
173
+ ) {
174
+ return res
175
+ .status(400)
176
+ .json({ error: 'Invalid message for undo' });
177
+ }
178
+
179
+ undoAIEdit(
180
+ shareDBDoc,
181
+ chatId,
182
+ messageId,
183
+ message.beforeFiles,
184
+ );
185
+
186
+ res.status(200).json({ success: true });
187
+ } catch (error) {
188
+ console.error('Error undoing AI edit:', error);
189
+ res
190
+ .status(500)
191
+ .json({ error: 'Failed to undo edit' });
192
+ }
193
+ },
194
+ );
195
+
144
196
  // Livekit Token Generator
145
197
  app.get('/livekit-token', async (req, res) => {
146
198
  const { room, username } = req.query;