vzcode 2.35.0 → 2.36.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 (44) hide show
  1. package/dist/assets/buildWorker-BZlya278.js +687 -0
  2. package/dist/assets/index-Cj-ERpBu.css +1 -0
  3. package/dist/assets/index-DD7vzp4U.js +364 -0
  4. package/dist/assets/{worker-D8p1JlHW.js → worker-1oQYaz-F.js} +251 -251
  5. package/dist/assets/worker-BfgPD8zR.js +125 -0
  6. package/dist/assets/{worker-k7HZ3t-V.js → worker-CoJaqtpi.js} +12 -12
  7. package/dist/index.html +2 -2
  8. package/dist/ot.js +180 -2
  9. package/dist/server/createServer.js +281 -0
  10. package/dist/server/index.js +6 -269
  11. package/package.json +14 -3
  12. package/src/client/CodeEditor/getOrCreateEditor.tsx +0 -14
  13. package/src/client/VZSidebar/AIChatWrapper.tsx +85 -0
  14. package/src/client/VZSidebar/VisualEditor/VisualEditor.tsx +13 -9
  15. package/src/client/VZSidebar/VisualEditor/colorUtils.ts +14 -0
  16. package/src/client/VZSidebar/index.tsx +2 -2
  17. package/src/client/useOpenDirectories.ts +0 -1
  18. package/src/llm-streaming-server/README.md +5 -3
  19. package/src/llm-streaming-ui/README.md +44 -42
  20. package/src/llm-streaming-ui/components/ChatInput.tsx +6 -19
  21. package/src/llm-streaming-ui/components/DiffView.tsx +6 -24
  22. package/src/llm-streaming-ui/components/FileEditingIndicator.tsx +1 -1
  23. package/src/llm-streaming-ui/components/Message.tsx +11 -27
  24. package/src/llm-streaming-ui/components/MessageList.tsx +15 -29
  25. package/src/llm-streaming-ui/components/Spinner.scss +37 -0
  26. package/src/llm-streaming-ui/components/Spinner.tsx +59 -0
  27. package/src/llm-streaming-ui/components/bootstrap.ts +16 -0
  28. package/src/llm-streaming-ui/components/icons.tsx +68 -0
  29. package/src/llm-streaming-ui/components/index.tsx +34 -30
  30. package/src/llm-streaming-ui/index.ts +13 -0
  31. package/src/llm-streaming-ui/props.ts +137 -0
  32. package/src/ot.ts +221 -4
  33. package/src/server/createServer.ts +413 -0
  34. package/src/server/index.ts +8 -333
  35. package/dist/assets/buildWorker-DylWm2VX.js +0 -687
  36. package/dist/assets/index-Dyt9tpmu.css +0 -1
  37. package/dist/assets/index-rg2Zvfo_.js +0 -364
  38. package/dist/assets/worker-b9bkZkXK.js +0 -116
  39. package/src/client/AIAssist/AIAssistCodeMirrorKeyMap.ts +0 -42
  40. package/src/client/AIAssist/generateFilesContext.ts +0 -25
  41. package/src/client/AIAssist/index.ts +0 -2
  42. package/src/client/CodeEditor/InteractiveWidgets/highlightWidgets.ts +0 -79
  43. /package/src/{client → llm-streaming-ui}/hooks/useAutoScroll.ts +0 -0
  44. /package/src/{client → llm-streaming-ui}/utils/scrollUtils.ts +0 -0
@@ -1,31 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import WebSocketJSONStream from '@teamwork/websocket-json-stream';
3
- import bodyParser from 'body-parser';
4
- import express from 'express';
5
- import fs from 'fs';
6
- import http from 'http';
7
2
  import open from 'open';
8
- import path from 'path';
9
- import ShareDB from 'sharedb';
10
- import { fileURLToPath } from 'url';
11
- import { WebSocketServer } from 'ws';
12
- import { json1Presence } from '../ot.js';
13
- import { computeInitialDocument } from './computeInitialDocument.js';
14
- import { handleAIAssist } from './handleAIAssist.js';
15
- import { handleAICopilot } from './handleAICopilot.js';
16
- import { handleAIChatMessage } from './handleAIChatMessage.js';
17
- import { isDirectory } from './isDirectory.js';
18
- import { createToken } from './livekit.js';
19
- import './setupEnv.js';
20
- // Import the image file utility
21
- const isImageFile = (fileName) => {
22
- return (fileName.match(/\.(png|jpg|jpeg|gif|bmp|svg|webp)$/i) !== null);
23
- };
24
- // The time in milliseconds by which auto-saving is debounced.
25
- const autoSaveDebounceTimeMS = 800;
26
- // The time in milliseconds by which auto-saving is throttled
27
- // when the user is interacting with the widgets in the editor.
28
- const throttleTimeMS = 100;
3
+ import { createVZCodeServer } from './createServer.js';
29
4
  // Helper function to get the port from command line arguments or use default.
30
5
  function getPortFromArgs(defaultPort = 3030) {
31
6
  const portArg = process.argv.find((arg) => arg.startsWith('--port='));
@@ -36,252 +11,14 @@ function getPortFromArgs(defaultPort = 3030) {
36
11
  }
37
12
  // Server port.
38
13
  const port = getPortFromArgs();
39
- const initialDocument = computeInitialDocument({
40
- // Use the current working directory to look for files.
41
- fullPath: process.cwd(),
14
+ const { ready, listen } = createVZCodeServer();
15
+ ready.catch((error) => {
16
+ console.error('Failed to initialize ShareDB document:', error);
42
17
  });
43
- // Register our custom OT type,
44
- // because it does not ship with ShareDB.
45
- ShareDB.types.register(json1Presence.type);
46
- const app = express();
47
- // Use ShareDB over WebSocket
48
- const shareDBBackend = new ShareDB({
49
- // Enable presence
50
- // See https://github.com/share/sharedb/blob/master/examples/rich-text-presence/server.js#L9
51
- presence: true,
52
- doNotForwardSendPresenceErrorsToClient: true,
53
- });
54
- const server = http.createServer(app);
55
- const wss = new WebSocketServer({ server });
56
- wss.on('connection', (ws) => {
57
- const clientStream = new WebSocketJSONStream(ws);
58
- shareDBBackend.listen(clientStream);
59
- // Prevent server crashes on errors.
60
- clientStream.on('error', (error) => {
61
- console.log('clientStream error: ' + error.message);
62
- });
63
- // Handle errors
64
- ws.on('error', (error) => {
65
- console.log('ws error: ' + error.message);
66
- });
67
- // Handle disconnections
68
- ws.on('close', () => {
69
- clientStream.end();
70
- });
71
- });
72
- // Serve static files
73
- const filename = fileURLToPath(import.meta.url);
74
- const dirname = path.dirname(filename);
75
- const dir = path.join(dirname, '..', '..', 'dist');
76
- app.use(express.static(dir));
77
- // Create the initial "document",
78
- // which is a representation of files on disk.
79
- const shareDBConnection = shareDBBackend.connect();
80
- const shareDBDoc = shareDBConnection.get('documents', '1');
81
- shareDBDoc.create(initialDocument, json1Presence.type.uri);
82
- // Handle AI Assist requests.
83
- app.post('/ai-assist', bodyParser.json(), handleAIAssist(shareDBDoc));
84
- // Handle AI Copilot requests.
85
- app.post('/ai-copilot', bodyParser.json(), handleAICopilot());
86
- // Handle AI Chat Message requests.
87
- app.post('/ai-chat-message', bodyParser.json(), handleAIChatMessage({
88
- shareDBDoc,
89
- onCreditDeduction: undefined,
90
- }));
91
- // Livekit Token Generator
92
- app.get('/livekit-token', async (req, res) => {
93
- const { room, username } = req.query;
94
- res.send(await createToken(room, username));
95
- });
96
- // The state of the document when files were last auto-saved.
97
- let previousDocument = initialDocument;
98
- // Saves the files that changed.
99
- const save = () => {
100
- const currentDocument = shareDBDoc.data;
101
- // Take a look at each file (key) previously and currently.
102
- const allKeys = Object.keys({
103
- ...currentDocument.files,
104
- ...previousDocument.files,
105
- });
106
- const directoriesToDelete = [];
107
- for (const key of allKeys) {
108
- const previous = previousDocument.files[key];
109
- const current = currentDocument.files[key];
110
- // If this file was neither created nor deleted...
111
- if (previous && current) {
112
- // Handle changing of text content.
113
- if (previous.text !== current.text) {
114
- if (isImageFile(current.name)) {
115
- // Write image files as binary from base64
116
- const buffer = Buffer.from(current.text, 'base64');
117
- fs.writeFileSync(current.name, buffer);
118
- }
119
- else {
120
- // Write non-image files as text
121
- fs.writeFileSync(current.name, current.text);
122
- }
123
- }
124
- // // Handle renaming files.
125
- // if (previous.name !== current.name) {
126
- // const previousPath = previous.name.split('/');
127
- // const currentPath = current.name.split('/');
128
- // // - If the path is length 1 for previous and current,
129
- // // then this should be true.
130
- // // - If the path length is the sane for previous and current,
131
- // // AND all the entries leading up to the last one are the same
132
- // // between previous and current, AND the last entry in the arrays
133
- // // (the file name itself) is different between previous and current
134
- // const onlyFileNameChanged =
135
- // (previousPath.length === 1 &&
136
- // currentPath.length === 1) ||
137
- // (previousPath.length === currentPath.length &&
138
- // previousPath
139
- // .slice(0, -1)
140
- // .every(
141
- // (val, index) => val === currentPath[index],
142
- // ) &&
143
- // previousPath.at(-1) !== currentPath.at(-1));
144
- // // This logic works if only the file name itself changes.
145
- // if (onlyFileNameChanged) {
146
- // fs.renameSync(previous.name, current.name);
147
- // }
148
- // {
149
- // // If we get here, then the directory may have been renamed,
150
- // // or the file has been moved between directories.
151
- // // If we get here, then the directory may have been renamed,
152
- // // or the file has been moved between directories.
153
- // const newDir = path.dirname(current.name);
154
- // // Check if the new directory exists, if not, create it
155
- // if (!fs.existsSync(newDir)) {
156
- // fs.mkdirSync(newDir, { recursive: true });
157
- // }
158
- // // Move the file to the new directory
159
- // fs.renameSync(previous.name, current.name);
160
- // }
161
- // }
162
- // Handle renaming files.
163
- if (previous.name !== current.name) {
164
- if (isDirectory(previous.name)) {
165
- // If the directory itself is being renamed,
166
- // Phase I: Ignore it, and get the files moved
167
- // Phase II: Keep track of these, and delete them after
168
- // all the files moved.
169
- // directoriesToDelete.push(previous.name)
170
- directoriesToDelete.push(previous.name);
171
- }
172
- else {
173
- const newDir = path.dirname(current.name);
174
- // Check if the new directory exists, if not, create it
175
- if (!fs.existsSync(newDir)) {
176
- fs.mkdirSync(newDir, { recursive: true });
177
- }
178
- // Move the file to the new directory
179
- fs.renameSync(previous.name, current.name);
180
- }
181
- }
182
- }
183
- // handle deleting files and directories.
184
- if (previous && !current) {
185
- const stats = fs.statSync(previous.name);
186
- //Check if the file path we are trying to delete is a directory
187
- if (!stats.isDirectory()) {
188
- fs.unlinkSync(previous.name);
189
- }
190
- else {
191
- //Performs directory deletion.
192
- fs.rm(previous.name, {
193
- recursive: true, //Makes sure that all files in directory are deleted.
194
- }, (error) => {
195
- if (error) {
196
- console.log(error);
197
- }
198
- });
199
- }
200
- }
201
- // Handle creating files and Directories.
202
- if (!previous && current) {
203
- //File Creation
204
- if (!isDirectory(current.name)) {
205
- if (isImageFile(current.name)) {
206
- // Write image files as binary from base64
207
- const buffer = Buffer.from(current.text, 'base64');
208
- fs.writeFileSync(current.name, buffer);
209
- }
210
- else {
211
- // Write non-image files as text
212
- fs.writeFileSync(current.name, current.text);
213
- }
214
- }
215
- else {
216
- fs.mkdirSync(current.name, { recursive: true });
217
- }
218
- }
219
- }
220
- // TODO deleted all directories under directoriesToDelete
221
- for (const dir of directoriesToDelete) {
222
- //Performs directory deletion.
223
- fs.rm(dir, {
224
- recursive: true, //Makes sure that all files in directory are deleted.
225
- }, (error) => {
226
- if (error) {
227
- console.log(error);
228
- }
229
- });
230
- }
231
- previousDocument = currentDocument;
232
- };
233
- // // Listen for when users modify files.
234
- // // Files get written to disk after `autoSaveDebounceTimeMS`
235
- // // milliseconds of inactivity.
236
- // let timeout;
237
- // shareDBDoc.subscribe(() => {
238
- // shareDBDoc.on('op', () => {
239
- // // console.log(shareDBDoc.data.isInteracting);
240
- // clearTimeout(timeout);
241
- // timeout = setTimeout(save, autoSaveDebounceTimeMS);
242
- // });
243
- // });
244
- let lastExecutedTime = Date.now();
245
- let lastChangeTimeout; // This timeout ensures the last change is saved
246
- // Function to throttle the saving
247
- function throttleSave() {
248
- const now = Date.now();
249
- const timeSinceLastExecution = now - lastExecutedTime;
250
- if (timeSinceLastExecution > throttleTimeMS) {
251
- save();
252
- lastExecutedTime = now;
253
- }
254
- else {
255
- // Clear the previous timeout and set a new one to save the last change
256
- clearTimeout(lastChangeTimeout);
257
- lastChangeTimeout = setTimeout(() => {
258
- save();
259
- lastExecutedTime = now;
260
- }, throttleTimeMS - timeSinceLastExecution);
261
- }
262
- }
263
- // Function to debounce the saving
264
- let debounceTimeout;
265
- function debounceSave() {
266
- clearTimeout(debounceTimeout);
267
- debounceTimeout = setTimeout(save, autoSaveDebounceTimeMS);
268
- }
269
- // Subscribe to listen for modifications
270
- shareDBDoc.subscribe(() => {
271
- shareDBDoc.on('op', () => {
272
- if (shareDBDoc.data.isInteracting) {
273
- throttleSave();
274
- }
275
- else {
276
- debounceSave();
277
- }
278
- });
279
- });
280
- server.listen(port, async () => {
281
- // Note: ngrok support can be added when the package is properly installed
18
+ listen(port).then((actualPort) => {
282
19
  // Sets the port to the one specified in the environment
283
20
  // variable (for development) or the default port.
284
- const livePort = process.env.EDITOR_PORT || port;
21
+ const livePort = process.env.EDITOR_PORT || actualPort;
285
22
  console.log(`EDITOR_PORT: ${process.env.EDITOR_PORT}`);
286
23
  console.log(`Editor is live at http://localhost:${livePort}`);
287
24
  open(`http://localhost:${livePort}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vzcode",
3
- "version": "2.35.0",
3
+ "version": "2.36.0",
4
4
  "description": "Multiplayer code editor system",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -13,6 +13,9 @@
13
13
  ],
14
14
  "scripts": {
15
15
  "test": "vitest run",
16
+ "test:e2e": "vitest run test/serverE2E.test.ts",
17
+ "e2e": "playwright test",
18
+ "e2e:headed": "playwright test --headed",
16
19
  "test-interactive": "cd test/sampleDirectories/playground && tsx ../../../src/server/index.ts",
17
20
  "prettier": "prettier {*.*,**/*.*} --write",
18
21
  "typecheck": "tsc --noEmit",
@@ -113,17 +116,22 @@
113
116
  "homepage": "https://github.com/vizhub-core/vzcode#readme",
114
117
  "dependencies": {
115
118
  "@codemirror/autocomplete": "^6.20.0",
119
+ "@codemirror/commands": "^6.11.1",
116
120
  "@codemirror/lang-css": "^6.3.1",
117
121
  "@codemirror/lang-html": "^6.4.11",
118
122
  "@codemirror/lang-javascript": "^6.2.4",
119
123
  "@codemirror/lang-json": "^6.0.2",
120
124
  "@codemirror/lang-markdown": "^6.5.0",
125
+ "@codemirror/language": "^6.13.1",
121
126
  "@codemirror/lint": "^6.9.2",
127
+ "@codemirror/search": "^6.7.2",
122
128
  "@codemirror/state": "^6.5.3",
123
129
  "@codemirror/theme-one-dark": "^6.1.3",
124
130
  "@codemirror/view": "^6.39.8",
131
+ "@dmsnell/diff-match-patch": "^1.1.0",
125
132
  "@langchain/core": "^1.1.8",
126
133
  "@langchain/openai": "^1.2.0",
134
+ "@lezer/common": "^1.5.4",
127
135
  "@lezer/highlight": "^1.2.3",
128
136
  "@livekit/components-react": "^2.9.17",
129
137
  "@replit/codemirror-indentation-markers": "^6.5.3",
@@ -155,7 +163,6 @@
155
163
  "d3-array": "^3.2.4",
156
164
  "d3-color": "^3.1.0",
157
165
  "diff": "^8.0.2",
158
- "@dmsnell/diff-match-patch": "^1.1.0",
159
166
  "diff2html": "3.4.52",
160
167
  "dotenv": "^17.2.3",
161
168
  "editcodewithai": "^2.4.0",
@@ -167,8 +174,8 @@
167
174
  "livekit-server-sdk": "^2.15.0",
168
175
  "llm-code-format": "^3.1.0",
169
176
  "lucide-react": "^0.562.0",
170
- "npm": "^11.7.0",
171
177
  "open": "^11.0.0",
178
+ "openai": "^6.9.1",
172
179
  "prettier-plugin-svelte": "^3.4.1",
173
180
  "react": "^18",
174
181
  "react-bootstrap": "^2.10.10",
@@ -184,8 +191,10 @@
184
191
  },
185
192
  "devDependencies": {
186
193
  "@eslint/js": "^9.39.2",
194
+ "@playwright/test": "^1.57.0",
187
195
  "@tauri-apps/cli": "^2.9.6",
188
196
  "@types/d3-color": "^3.1.3",
197
+ "@types/node": "^22.20.5",
189
198
  "@types/react": "^18",
190
199
  "@types/react-dom": "^18",
191
200
  "@typescript-eslint/eslint-plugin": "^8.51.0",
@@ -198,9 +207,11 @@
198
207
  "eslint-plugin-react": "^7.37.5",
199
208
  "eslint-plugin-react-hooks": "^7.0.1",
200
209
  "globals": "^17.0.0",
210
+ "livekit-client": "^2.16.0",
201
211
  "npm-check-updates": "^19.2.0",
202
212
  "prettier": "^3.7.4",
203
213
  "sass": "^1.97.1",
214
+ "svelte": "^5.20.1",
204
215
  "ts-node": "^10.9.2",
205
216
  "tsx": "^4.21.0",
206
217
  "typescript": "^5.9.3",
@@ -384,22 +384,8 @@ export const getOrCreateEditor = async ({
384
384
  widgets({ onInteract, customInteractRules }),
385
385
  );
386
386
 
387
- // TODO fix the bugginess in this one where
388
- // the highlight persists after the mouse leaves.
389
- // extensions.push(highlightWidgets);
390
-
391
387
  extensions.push(rotationIndicator);
392
388
 
393
- // extensions.push(
394
- // AIAssistCodeMirrorKeyMap({
395
- // shareDBDoc,
396
- // fileId,
397
- // tabList,
398
- // aiAssistEndpoint,
399
- // aiAssistOptions,
400
- // }),
401
- // );
402
-
403
389
  // Add the extension that provides indentation markers.
404
390
  extensions.push(
405
391
  indentationMarkers({
@@ -0,0 +1,85 @@
1
+ import { useCallback, useContext } from 'react';
2
+ import { getFileId } from '@vizhub/viz-utils';
3
+ import { AIChat } from '../../llm-streaming-ui';
4
+ import { VZCodeContext } from '../VZCodeContext';
5
+ import {
6
+ enableAskMode,
7
+ enableDiffView,
8
+ enableVoiceInput,
9
+ } from '../featureFlags';
10
+
11
+ /**
12
+ * Bridges VZCode's context into the standalone `AIChat` component.
13
+ *
14
+ * `AIChat` (from `llm-streaming-ui`) is fully controlled and reads no
15
+ * application state. This wrapper supplies the chat state, callbacks,
16
+ * feature flags, and file-link handling from `VZCodeContext`.
17
+ */
18
+ export const AIChatWrapper = () => {
19
+ const {
20
+ content,
21
+ aiChatFocused,
22
+ aiChatMode,
23
+ aiChatMessage,
24
+ currentChatId,
25
+ selectedChatId,
26
+ setSelectedChatId,
27
+ aiErrorMessage,
28
+ setAIChatMode,
29
+ getStoredAIPrompt,
30
+ setAIChatMessage,
31
+ handleSendMessage,
32
+ setAIErrorMessage,
33
+ navigateMessageHistoryUp,
34
+ navigateMessageHistoryDown,
35
+ resetMessageHistoryNavigation,
36
+ enableMinimalEditFlow,
37
+ additionalWidgets,
38
+ openTab,
39
+ setIsAIChatOpen,
40
+ } = useContext(VZCodeContext);
41
+
42
+ // Open a file referenced by a link inside a diff.
43
+ const handleOpenFile = useCallback(
44
+ (fileName: string) => {
45
+ if (!content) return;
46
+ const fileId = getFileId(content, fileName);
47
+ if (fileId) {
48
+ openTab({ fileId, isTransient: false });
49
+ setIsAIChatOpen(false);
50
+ }
51
+ },
52
+ [content, openTab, setIsAIChatOpen],
53
+ );
54
+
55
+ return (
56
+ <AIChat
57
+ content={content}
58
+ aiChatFocused={aiChatFocused}
59
+ aiChatMode={aiChatMode}
60
+ setAIChatMode={setAIChatMode}
61
+ aiChatMessage={aiChatMessage}
62
+ setAIChatMessage={setAIChatMessage}
63
+ aiErrorMessage={aiErrorMessage}
64
+ setAIErrorMessage={setAIErrorMessage}
65
+ currentChatId={currentChatId}
66
+ selectedChatId={selectedChatId}
67
+ setSelectedChatId={setSelectedChatId}
68
+ handleSendMessage={handleSendMessage}
69
+ navigateMessageHistoryUp={navigateMessageHistoryUp}
70
+ navigateMessageHistoryDown={
71
+ navigateMessageHistoryDown
72
+ }
73
+ resetMessageHistoryNavigation={
74
+ resetMessageHistoryNavigation
75
+ }
76
+ getStoredAIPrompt={getStoredAIPrompt}
77
+ onOpenFile={handleOpenFile}
78
+ additionalWidgets={additionalWidgets}
79
+ enableDiffView={enableDiffView}
80
+ enableAskMode={enableAskMode}
81
+ enableVoiceInput={enableVoiceInput}
82
+ enableMinimalEditFlow={enableMinimalEditFlow}
83
+ />
84
+ );
85
+ };
@@ -11,6 +11,7 @@ import { VisualEditorConfigEntry } from '../../../types';
11
11
  import { EmptyState } from '../EmptyState';
12
12
  import {
13
13
  toHclChannels,
14
+ coerceChannelNumber,
14
15
  hclChannelsToHex,
15
16
  } from './colorUtils';
16
17
  import { CONFIG_FILE_NAME } from './constants';
@@ -377,15 +378,18 @@ export const VisualEditor = () => {
377
378
  '#000000';
378
379
 
379
380
  const channels = toHclChannels(currentHex);
380
- const currentH =
381
- localValues[`${widgetConfig.property}_h`] ??
382
- channels.h;
383
- const currentC =
384
- localValues[`${widgetConfig.property}_c`] ??
385
- channels.c;
386
- const currentL =
387
- localValues[`${widgetConfig.property}_l`] ??
388
- channels.l;
381
+ const currentH = coerceChannelNumber(
382
+ localValues[`${widgetConfig.property}_h`],
383
+ channels.h,
384
+ );
385
+ const currentC = coerceChannelNumber(
386
+ localValues[`${widgetConfig.property}_c`],
387
+ channels.c,
388
+ );
389
+ const currentL = coerceChannelNumber(
390
+ localValues[`${widgetConfig.property}_l`],
391
+ channels.l,
392
+ );
389
393
 
390
394
  return (
391
395
  <ColorWidget
@@ -16,6 +16,20 @@ export function toHclChannels(value: string): HclChannels {
16
16
  };
17
17
  }
18
18
 
19
+ /**
20
+ * Coerces a widget value to a finite number, falling back when
21
+ * the stored value is not numeric (widget values may be strings or
22
+ * booleans for other widget types).
23
+ */
24
+ export function coerceChannelNumber(
25
+ value: unknown,
26
+ fallback: number,
27
+ ): number {
28
+ return typeof value === 'number' && Number.isFinite(value)
29
+ ? value
30
+ : fallback;
31
+ }
32
+
19
33
  export function hclChannelsToHex(
20
34
  channels: HclChannels,
21
35
  fallback: string,
@@ -32,7 +32,7 @@ import { MicSVG } from '../Icons/MicSVG';
32
32
  import { sortFileTree } from '../sortFileTree';
33
33
  import { SplitPaneResizeContext } from '../SplitPaneResizeContext';
34
34
  import { VZCodeContext } from '../VZCodeContext';
35
- import { AIChat } from '../../llm-streaming-ui/components/index.js';
35
+ import { AIChatWrapper } from './AIChatWrapper';
36
36
  import { Listing } from './Listing';
37
37
  import { Search } from './Search';
38
38
  import { DeleteConfirmationModal } from './DeleteConfirmationModal';
@@ -581,7 +581,7 @@ export const VZSidebar = ({
581
581
  >
582
582
  {isAIChatOpen ? (
583
583
  <div className="sidebar-ai-chat">
584
- <AIChat />
584
+ <AIChatWrapper />
585
585
  </div>
586
586
  ) : isSearchOpen ? (
587
587
  <div className="sidebar-search">
@@ -2,7 +2,6 @@ import { useState, useCallback, useEffect } from 'react';
2
2
  import type { Pane } from '../types';
3
3
  import { VizContent } from '@vizhub/viz-types';
4
4
 
5
- // TODO bring this feature back
6
5
  // When a page is opened with an active file,
7
6
  // make sure all the directories leading to that file
8
7
  // are opened automatically.
@@ -27,9 +27,9 @@ This module is being extracted from VZCode's AI chat functionality to become a s
27
27
 
28
28
  ## Dependencies
29
29
 
30
- Currently depends on:
30
+ Declared in `package.json`:
31
31
 
32
- - `openai` - OpenAI SDK for LLM interactions
32
+ - `openai` - OpenAI SDK for LLM interactions (declared directly; also used transitively by `@langchain/openai`)
33
33
  - `sharedb` - Real-time collaborative editing framework
34
34
  - `llm-code-format` - Markdown parsing for code blocks
35
35
  - `editcodewithai` - Code editing utilities
@@ -44,7 +44,9 @@ This module will eventually be:
44
44
  3. Made framework-agnostic (can work with Express, Fastify, etc.)
45
45
  4. Fully documented with usage examples
46
46
 
47
- See the [main issue](https://github.com/vizhub-core/vzcode/issues/XXX) for the full extraction plan.
47
+ This module is being extracted into a standalone package
48
+ (`@vizhub/llm-streaming-server`). Follow the conventions in
49
+ `../llm-streaming-ui/README.md` when contributing.
48
50
 
49
51
  ## Usage (Current)
50
52