vzcode 3.2.0 → 3.4.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 (67) hide show
  1. package/README.md +185 -40
  2. package/dist/assets/App-BSFvLn9Z.js +387 -0
  3. package/dist/assets/App-DbKY-mb6.css +1 -0
  4. package/dist/assets/bindings_wasm_bg-IWNG_AjZ.wasm +0 -0
  5. package/dist/assets/buildWorker-N5tFTOqM.js +794 -0
  6. package/dist/assets/index-Acvr-XWK.js +43 -0
  7. package/dist/assets/index-CZT-v4sH.css +1 -0
  8. package/dist/assets/rolldown-runtime-COiEfhsA.js +1 -0
  9. package/dist/assets/worker-BpV7Ustv.js +223 -0
  10. package/dist/assets/worker-CLeezw6h.js +458 -0
  11. package/dist/assets/worker-DaSIYBQX.js +327 -0
  12. package/dist/cli.js +170 -99
  13. package/dist/index.html +3 -2
  14. package/dist/server/accessControl.js +104 -0
  15. package/dist/server/computeInitialDocument.js +4 -1
  16. package/dist/server/createServer.js +356 -104
  17. package/dist/server/index.js +4 -3
  18. package/dist/server/workspaceSecurity.js +115 -0
  19. package/dist/server/workspaceSync.js +141 -0
  20. package/package.json +74 -72
  21. package/src/cli.ts +203 -182
  22. package/src/client/App/index.tsx +2 -0
  23. package/src/client/App/usePending.ts +3 -1
  24. package/src/client/RunCodeWidget/index.tsx +1 -0
  25. package/src/client/SplitPaneResizeContext.tsx +94 -11
  26. package/src/client/VZCodeContext/types.ts +6 -0
  27. package/src/client/VZCodeContext/useVZCodeState.ts +2 -0
  28. package/src/client/VZResizer/index.tsx +25 -0
  29. package/src/client/VZSidebar/AIChatWrapper.tsx +2 -0
  30. package/src/client/VZSidebar/VisualEditor/CheckboxWidget.tsx +22 -30
  31. package/src/client/VZSidebar/VisualEditor/ColorWidget.tsx +198 -126
  32. package/src/client/VZSidebar/VisualEditor/DropdownWidget.tsx +25 -67
  33. package/src/client/VZSidebar/VisualEditor/PropertySection.tsx +41 -0
  34. package/src/client/VZSidebar/VisualEditor/SegmentedWidget.tsx +34 -0
  35. package/src/client/VZSidebar/VisualEditor/SliderWidget.tsx +60 -12
  36. package/src/client/VZSidebar/VisualEditor/VisualEditor.tsx +31 -393
  37. package/src/client/VZSidebar/VisualEditor/VisualEditorControls.tsx +478 -0
  38. package/src/client/VZSidebar/VisualEditor/colorUtils.ts +12 -0
  39. package/src/client/VZSidebar/VisualEditor/status.ts +47 -0
  40. package/src/client/VZSidebar/VisualEditor/updateConfig.ts +51 -24
  41. package/src/client/VZSidebar/VisualEditor/utils.ts +1 -1
  42. package/src/client/VZSidebar/styles.scss +424 -0
  43. package/src/client/WorkspaceConflictBanner.tsx +120 -0
  44. package/src/client/index.ts +2 -0
  45. package/src/client/main.jsx +54 -12
  46. package/src/llm-streaming-server/README.md +4 -16
  47. package/src/llm-streaming-ui/README.md +41 -2
  48. package/src/llm-streaming-ui/components/ChatInput.tsx +65 -13
  49. package/src/llm-streaming-ui/components/index.tsx +2 -0
  50. package/src/llm-streaming-ui/components/styles.scss +14 -0
  51. package/src/llm-streaming-ui/hooks/useAutoScroll.ts +1 -1
  52. package/src/llm-streaming-ui/index.ts +1 -0
  53. package/src/llm-streaming-ui/props.ts +26 -2
  54. package/src/server/accessControl.ts +151 -0
  55. package/src/server/computeInitialDocument.ts +6 -2
  56. package/src/server/createServer.ts +487 -138
  57. package/src/server/index.ts +4 -5
  58. package/src/server/workspaceSecurity.ts +160 -0
  59. package/src/server/workspaceSync.ts +203 -0
  60. package/src/types.ts +29 -27
  61. package/dist/assets/bindings_wasm_bg-9w8E-TmY.wasm +0 -0
  62. package/dist/assets/buildWorker-BZlya278.js +0 -687
  63. package/dist/assets/index-B7NRhsN6.js +0 -356
  64. package/dist/assets/index-D1V1AKed.css +0 -1
  65. package/dist/assets/worker-1oQYaz-F.js +0 -342
  66. package/dist/assets/worker-BfgPD8zR.js +0 -125
  67. package/dist/assets/worker-CoJaqtpi.js +0 -436
package/src/cli.ts CHANGED
@@ -1,205 +1,226 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { spawn } from 'child_process';
4
- import path from 'path';
5
- import { fileURLToPath } from 'url';
6
- import fs from 'fs';
7
-
8
- // Get the directory of the current module
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = path.dirname(__filename);
11
-
12
- // Function to find the Tauri binary
13
- function findTauriApp(): string | null {
14
- // Look for the Tauri binary in common locations
15
- const possiblePaths = [
16
- // Development location (when running from source)
17
- path.join(
18
- __dirname,
19
- '..',
20
- 'src-tauri',
21
- 'target',
22
- 'debug',
23
- 'vzcode',
24
- ),
25
- path.join(
26
- __dirname,
27
- '..',
28
- 'src-tauri',
29
- 'target',
30
- 'debug',
31
- 'vzcode.exe',
32
- ),
33
- // Release location (when running from built package)
34
- path.join(
35
- __dirname,
36
- '..',
37
- 'src-tauri',
38
- 'target',
39
- 'release',
40
- 'vzcode',
41
- ),
42
- path.join(
43
- __dirname,
44
- '..',
45
- 'src-tauri',
46
- 'target',
47
- 'release',
48
- 'vzcode.exe',
49
- ),
50
- // MacOS app bundle
51
- path.join(
52
- __dirname,
53
- '..',
54
- 'src-tauri',
55
- 'target',
56
- 'debug',
57
- 'vzcode.app',
58
- 'Contents',
59
- 'MacOS',
60
- 'vzcode',
61
- ),
62
- path.join(
63
- __dirname,
64
- '..',
65
- 'src-tauri',
66
- 'target',
67
- 'release',
68
- 'vzcode.app',
69
- 'Contents',
70
- 'MacOS',
71
- 'vzcode',
72
- ),
73
- ];
3
+ import { spawn } from 'node:child_process';
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+ import open from 'open';
8
+ import { createVZCodeServer } from './server/createServer.js';
9
+
10
+ const DEFAULT_PORT = 3030;
11
+ const HOST = '127.0.0.1';
12
+ const __dirname = path.dirname(
13
+ fileURLToPath(import.meta.url),
14
+ );
15
+
16
+ type CLIOptions = {
17
+ directory: string;
18
+ port: number;
19
+ openBrowser: boolean;
20
+ desktop: boolean;
21
+ help: boolean;
22
+ };
23
+
24
+ const usage = [
25
+ 'VZCode - Multiplayer Code Editor',
26
+ '',
27
+ 'Usage: vzcode [directory] [options]',
28
+ '',
29
+ 'Starts the browser editor for a local workspace (defaults to ".").',
30
+ '',
31
+ 'Options:',
32
+ ' --help, -h Show this help message',
33
+ ' --browser Use the browser editor (the default)',
34
+ ' --desktop Launch a locally built Tauri application (experimental)',
35
+ ' --no-open Start the server without opening a browser',
36
+ ' --port=<port> HTTP/WebSocket port (default: 3030)',
37
+ ' --port <port> Equivalent to --port=<port>',
38
+ '',
39
+ 'Examples:',
40
+ ' vzcode .',
41
+ ' vzcode ./my-project --port=4000',
42
+ ' vzcode --no-open',
43
+ '',
44
+ 'VZCode listens on 127.0.0.1 only. Do not expose its unauthenticated',
45
+ 'workspace editing server to untrusted networks.',
46
+ ].join('\n');
47
+
48
+ function parsePort(value: string): number {
49
+ if (!/^\d+$/.test(value)) {
50
+ throw new Error('Invalid port: ' + value);
51
+ }
52
+ const port = Number(value);
53
+ if (!Number.isSafeInteger(port) || port > 65535) {
54
+ throw new Error(
55
+ 'Port must be between 0 and 65535: ' + value,
56
+ );
57
+ }
58
+ return port;
59
+ }
74
60
 
75
- for (const binaryPath of possiblePaths) {
76
- if (fs.existsSync(binaryPath)) {
77
- return binaryPath;
61
+ function parseOptions(args: string[]): CLIOptions {
62
+ const options: CLIOptions = {
63
+ directory: '.',
64
+ port: DEFAULT_PORT,
65
+ openBrowser: true,
66
+ desktop: false,
67
+ help: false,
68
+ };
69
+
70
+ let hasDirectory = false;
71
+ for (let i = 0; i < args.length; i++) {
72
+ const arg = args[i];
73
+
74
+ if (arg === '--help' || arg === '-h') {
75
+ options.help = true;
76
+ continue;
77
+ }
78
+ if (arg === '--browser') {
79
+ continue;
78
80
  }
81
+ if (arg === '--desktop') {
82
+ options.desktop = true;
83
+ continue;
84
+ }
85
+ if (arg === '--no-open') {
86
+ options.openBrowser = false;
87
+ continue;
88
+ }
89
+ if (arg === '--port' || arg.startsWith('--port=')) {
90
+ const value =
91
+ arg === '--port'
92
+ ? args[++i]
93
+ : arg.slice('--port='.length);
94
+ if (value === undefined) {
95
+ throw new Error('Missing value for --port');
96
+ }
97
+ options.port = parsePort(value);
98
+ continue;
99
+ }
100
+ if (arg.startsWith('-')) {
101
+ throw new Error('Unknown option: ' + arg);
102
+ }
103
+ if (hasDirectory) {
104
+ throw new Error(
105
+ 'Provide at most one workspace directory',
106
+ );
107
+ }
108
+ options.directory = arg;
109
+ hasDirectory = true;
79
110
  }
80
111
 
81
- return null;
112
+ return options;
82
113
  }
83
114
 
84
- // Function to launch the Tauri app
85
- function launchTauriApp(workingDirectory: string): void {
86
- const tauriBinary = findTauriApp();
115
+ // The npm package intentionally does not include a desktop executable.
116
+ // This path is available only after building Tauri in a source checkout.
117
+ function findDesktopApp(): string | null {
118
+ const root = path.resolve(__dirname, '..');
119
+ const candidates = [
120
+ 'src-tauri/target/debug/vzcode',
121
+ 'src-tauri/target/debug/vzcode.exe',
122
+ 'src-tauri/target/release/vzcode',
123
+ 'src-tauri/target/release/vzcode.exe',
124
+ 'src-tauri/target/debug/vzcode.app/Contents/MacOS/vzcode',
125
+ 'src-tauri/target/release/vzcode.app/Contents/MacOS/vzcode',
126
+ ];
127
+ return (
128
+ candidates
129
+ .map((candidate) => path.join(root, candidate))
130
+ .find((candidate) => fs.existsSync(candidate)) ?? null
131
+ );
132
+ }
87
133
 
88
- if (!tauriBinary) {
89
- console.error(
90
- 'VZCode desktop app not found. Please build it first with: npm run tauri:build',
91
- );
92
- console.error(
93
- 'Falling back to launching browser version...',
94
- );
95
- launchBrowserVersion(workingDirectory);
134
+ async function main(): Promise<void> {
135
+ const options = parseOptions(process.argv.slice(2));
136
+ if (options.help) {
137
+ console.log(usage);
96
138
  return;
97
139
  }
98
140
 
99
- console.log(
100
- `Launching VZCode desktop app from: ${workingDirectory}`,
101
- );
102
-
103
- // First start the server in the background
104
- startServerInBackground(workingDirectory);
105
-
106
- // Give the server a moment to start, then launch Tauri
107
- setTimeout(() => {
108
- const child = spawn(tauriBinary, [], {
109
- cwd: workingDirectory,
110
- stdio: 'inherit',
111
- detached: true,
112
- });
113
-
114
- // Allow the parent process to exit while keeping the child running
115
- child.unref();
116
- }, 2000);
117
- }
141
+ const directory = path.resolve(options.directory);
142
+ if (
143
+ !fs.existsSync(directory) ||
144
+ !fs.statSync(directory).isDirectory()
145
+ ) {
146
+ throw new Error(
147
+ 'Workspace is not a directory: ' + directory,
148
+ );
149
+ }
118
150
 
119
- // Function to start the server in the background
120
- function startServerInBackground(
121
- workingDirectory: string,
122
- ): void {
123
- // Start the server process in the background
124
- const serverPath = path.join(
125
- __dirname,
126
- 'server',
127
- 'index.js',
128
- );
129
- const serverChild = spawn('node', [serverPath], {
130
- cwd: workingDirectory,
131
- stdio: ['ignore', 'pipe', 'pipe'],
132
- detached: true,
133
- });
134
-
135
- // Don't block on the server process
136
- serverChild.unref();
137
-
138
- // Log server output for debugging
139
- if (serverChild.stdout) {
140
- serverChild.stdout.on('data', (data) => {
141
- console.log('Server:', data.toString());
142
- });
151
+ const desktopBinary = options.desktop
152
+ ? findDesktopApp()
153
+ : null;
154
+ if (options.desktop && !desktopBinary) {
155
+ throw new Error(
156
+ 'Tauri application not found. Build it with npm run tauri:build, ' +
157
+ 'or omit --desktop to use the browser editor.',
158
+ );
143
159
  }
144
160
 
145
- if (serverChild.stderr) {
146
- serverChild.stderr.on('data', (data) => {
147
- console.error('Server error:', data.toString());
148
- });
161
+ const server = createVZCodeServer({ cwd: directory });
162
+ await server.ready;
163
+ let actualPort: number;
164
+ try {
165
+ // Local-only until authenticated remote collaboration exists.
166
+ actualPort = await server.listen(options.port, HOST);
167
+ } catch (error) {
168
+ await server.close();
169
+ throw error;
149
170
  }
150
- }
151
171
 
152
- // Fallback function to launch the browser version
153
- async function launchBrowserVersion(
154
- workingDirectory: string,
155
- ): Promise<void> {
156
- // Note: The server/index.js will use process.cwd() automatically
157
- // and we're already in the correct working directory
172
+ const url = 'http://' + HOST + ':' + actualPort;
173
+ console.log('Workspace: ' + directory);
174
+ const accessUrl =
175
+ url + '/#vzcode-token=' + server.accessToken;
176
+ console.log('Editor is live at ' + accessUrl);
158
177
  console.log(
159
- `Starting VZCode server from: ${workingDirectory}`,
178
+ 'Keep this private link secret; it grants workspace editing access.',
160
179
  );
161
- }
162
-
163
- // Main CLI function
164
- function main(): void {
165
- const workingDirectory = process.cwd();
166
-
167
- // Parse command line arguments
168
- const args = process.argv.slice(2);
169
-
170
- if (args.includes('--help') || args.includes('-h')) {
171
- console.log('VZCode - Multiplayer Code Editor');
172
- console.log('');
173
- console.log('Usage: vzcode [options]');
174
- console.log('');
175
- console.log('Options:');
176
- console.log(' --help, -h Show this help message');
177
- console.log(
178
- ' --browser Force browser version instead of desktop app',
179
- );
180
- console.log(
181
- ' --port=<port> Specify port for server (default: 3030)',
182
- );
183
- console.log('');
184
- console.log('Examples:');
185
- console.log(
186
- ' vzcode # Launch desktop app in current directory',
187
- );
188
- console.log(
189
- ' vzcode --browser # Launch browser version',
190
- );
191
- console.log(
192
- ' vzcode --port=4000 # Start server on port 4000',
193
- );
194
- return;
195
- }
180
+ console.log('Press Ctrl+C to stop VZCode.');
181
+
182
+ let closing = false;
183
+ const shutdown = async () => {
184
+ if (closing) return;
185
+ closing = true;
186
+ try {
187
+ await server.close();
188
+ } catch (error) {
189
+ console.error('Failed to stop VZCode:', error);
190
+ process.exitCode = 1;
191
+ }
192
+ };
193
+ process.once('SIGINT', () => void shutdown());
194
+ process.once('SIGTERM', () => void shutdown());
196
195
 
197
- if (args.includes('--browser')) {
198
- launchBrowserVersion(workingDirectory);
199
- } else {
200
- launchTauriApp(workingDirectory);
196
+ if (desktopBinary) {
197
+ const child = spawn(desktopBinary, [], {
198
+ cwd: directory,
199
+ stdio: 'inherit',
200
+ });
201
+ child.once('error', (error) => {
202
+ console.error(
203
+ 'Unable to launch the desktop app:',
204
+ error,
205
+ );
206
+ process.exitCode = 1;
207
+ void shutdown();
208
+ });
209
+ child.once('exit', () => void shutdown());
210
+ } else if (options.openBrowser) {
211
+ try {
212
+ await open(accessUrl);
213
+ } catch (error) {
214
+ console.warn(
215
+ 'Could not open a browser automatically. Visit ' +
216
+ url,
217
+ error,
218
+ );
219
+ }
201
220
  }
202
221
  }
203
222
 
204
- // Run the CLI
205
- main();
223
+ main().catch((error) => {
224
+ console.error('VZCode: ' + (error.message ?? error));
225
+ process.exitCode = 1;
226
+ });
@@ -19,6 +19,7 @@ import { VZLeft } from '../VZLeft';
19
19
  import { VZMiddle } from '../VZMiddle';
20
20
  import { VZResizer } from '../VZResizer';
21
21
  import { VZRight } from '../VZRight';
22
+ import { WorkspaceConflictBanner } from '../WorkspaceConflictBanner';
22
23
  import {
23
24
  useInitialUsername,
24
25
  usePersistUsername,
@@ -111,6 +112,7 @@ function App() {
111
112
  // only mounted when explicitly enabled.
112
113
  const appContent = (
113
114
  <>
115
+ <WorkspaceConflictBanner />
114
116
  <div className="app">
115
117
  <VZLeft />
116
118
  <VZMiddle
@@ -14,7 +14,9 @@ const runDelay = 1000;
14
14
  export const usePending = (
15
15
  shareDBDoc: ShareDBDoc<VizContent>,
16
16
  ) => {
17
- const lastOpTimerRef = useRef<NodeJS.Timeout>();
17
+ const lastOpTimerRef = useRef<NodeJS.Timeout | undefined>(
18
+ undefined,
19
+ );
18
20
 
19
21
  // TODO rename this to isPending,
20
22
  // and also rename connected to isConnected.
@@ -3,6 +3,7 @@ import {
3
3
  useContext,
4
4
  useEffect,
5
5
  useState,
6
+ type JSX,
6
7
  } from 'react';
7
8
  import { PlaySVG } from '../Icons';
8
9
  import { SplitEditorSVG } from '../Icons/SplitEditorSVG';
@@ -15,6 +15,7 @@ export type SplitPaneResizeContextValue = {
15
15
  isDraggingLeft: boolean;
16
16
  setIsDragging: (a: boolean, side: Side) => void;
17
17
  setSidebarView: (isAIChatOpen: boolean) => void;
18
+ setContainerWidth: (width: number) => void;
18
19
  };
19
20
 
20
21
  // Default widths for different sidebar views
@@ -22,6 +23,13 @@ const filesViewWidth = 300;
22
23
  const aiChatViewWidth = 800;
23
24
  const initialCodeEditorWidthDefault = 800;
24
25
 
26
+ // Preserve a usable preview and code pane as the host workspace narrows.
27
+ const minFilesWidth = 220;
28
+ const minAIChatWidth = 300;
29
+ const minCodeEditorWidth = 200;
30
+ const minPreviewWidth = 320;
31
+ const previewShare = 0.32;
32
+
25
33
  const initialValue: SplitPaneResizeContextValue = {
26
34
  codeEditorWidth: initialCodeEditorWidthDefault,
27
35
  sidebarWidth: filesViewWidth, // Default to files view
@@ -30,15 +38,18 @@ const initialValue: SplitPaneResizeContextValue = {
30
38
  isDraggingLeft: false,
31
39
  setIsDragging: () => {},
32
40
  setSidebarView: () => {},
41
+ setContainerWidth: () => {},
33
42
  };
34
43
 
35
44
  export const SplitPaneResizeContext =
36
45
  createContext<SplitPaneResizeContextValue>(initialValue);
37
46
 
38
47
  type SplitPaneState = {
39
- // The width of the sidebar, in pixels.
48
+ // Preferred widths; actual widths are bounded by the workspace size.
40
49
  sidebarWidth: number;
41
50
  codeEditorWidth: number;
51
+ containerWidth: number | null;
52
+ isAIChatOpen: boolean;
42
53
  isDraggingLeft: boolean;
43
54
  isDraggingRight: boolean;
44
55
  };
@@ -46,10 +57,69 @@ type SplitPaneState = {
46
57
  const initialState: SplitPaneState = {
47
58
  sidebarWidth: filesViewWidth,
48
59
  codeEditorWidth: initialCodeEditorWidthDefault,
60
+ containerWidth: null,
61
+ isAIChatOpen: false,
49
62
  isDraggingLeft: false,
50
63
  isDraggingRight: false,
51
64
  };
52
65
 
66
+ // Keep preferred widths intact when the workspace temporarily shrinks, so
67
+ // the user's drag choices return when there is room again.
68
+ export const getConstrainedPaneWidths = (
69
+ state: SplitPaneState,
70
+ ) => {
71
+ const {
72
+ sidebarWidth,
73
+ codeEditorWidth,
74
+ containerWidth,
75
+ isAIChatOpen,
76
+ } = state;
77
+ if (containerWidth === null) {
78
+ return { sidebarWidth, codeEditorWidth };
79
+ }
80
+
81
+ const availableWidth = Math.max(0, containerWidth);
82
+ const previewWidth = Math.min(
83
+ Math.max(
84
+ minPreviewWidth,
85
+ availableWidth * previewShare,
86
+ ),
87
+ availableWidth * 0.45,
88
+ );
89
+ const sidebarMinimum = Math.min(
90
+ isAIChatOpen ? minAIChatWidth : minFilesWidth,
91
+ Math.max(0, availableWidth - previewWidth),
92
+ );
93
+ const codeMinimum = Math.min(
94
+ minCodeEditorWidth,
95
+ Math.max(
96
+ 0,
97
+ availableWidth - previewWidth - sidebarMinimum,
98
+ ),
99
+ );
100
+ const sidebarMaximum = Math.max(
101
+ sidebarMinimum,
102
+ availableWidth - previewWidth - codeMinimum,
103
+ );
104
+ const constrainedSidebarWidth = Math.min(
105
+ Math.max(sidebarWidth, sidebarMinimum),
106
+ sidebarMaximum,
107
+ );
108
+ const constrainedCodeEditorWidth = Math.min(
109
+ Math.max(0, codeEditorWidth),
110
+ Math.max(
111
+ 0,
112
+ availableWidth -
113
+ constrainedSidebarWidth -
114
+ previewWidth,
115
+ ),
116
+ );
117
+ return {
118
+ sidebarWidth: constrainedSidebarWidth,
119
+ codeEditorWidth: constrainedCodeEditorWidth,
120
+ };
121
+ };
122
+
53
123
  type SplitPaneAction =
54
124
  | {
55
125
  type: 'move';
@@ -64,6 +134,10 @@ type SplitPaneAction =
64
134
  | {
65
135
  type: 'setSidebarView';
66
136
  isAIChatOpen: boolean;
137
+ }
138
+ | {
139
+ type: 'setContainerWidth';
140
+ width: number;
67
141
  };
68
142
 
69
143
  const splitPaneReducer = (
@@ -71,18 +145,20 @@ const splitPaneReducer = (
71
145
  action: SplitPaneAction,
72
146
  ) => {
73
147
  switch (action.type) {
74
- case 'move':
148
+ case 'move': {
149
+ const { sidebarWidth, codeEditorWidth } =
150
+ getConstrainedPaneWidths(state);
75
151
  return action.side === 'left'
76
152
  ? {
77
153
  ...state,
78
- sidebarWidth:
79
- state.sidebarWidth + action.movementX,
154
+ sidebarWidth: sidebarWidth + action.movementX,
80
155
  }
81
156
  : {
82
157
  ...state,
83
158
  codeEditorWidth:
84
- state.codeEditorWidth + action.movementX,
159
+ codeEditorWidth + action.movementX,
85
160
  };
161
+ }
86
162
  // Handle setIsDragging
87
163
  case 'setIsDragging':
88
164
  return action.side === 'left'
@@ -97,10 +173,15 @@ const splitPaneReducer = (
97
173
  case 'setSidebarView':
98
174
  return {
99
175
  ...state,
176
+ isAIChatOpen: action.isAIChatOpen,
100
177
  sidebarWidth: action.isAIChatOpen
101
178
  ? aiChatViewWidth
102
179
  : filesViewWidth,
103
180
  };
181
+ case 'setContainerWidth':
182
+ return state.containerWidth === action.width
183
+ ? state
184
+ : { ...state, containerWidth: action.width };
104
185
  default:
105
186
  return state;
106
187
  }
@@ -133,12 +214,13 @@ export const SplitPaneResizeProvider = ({ children }) => {
133
214
  [dispatch],
134
215
  );
135
216
 
136
- const {
137
- sidebarWidth,
138
- codeEditorWidth,
139
- isDraggingLeft,
140
- isDraggingRight,
141
- } = state;
217
+ const setContainerWidth = useCallback((width: number) => {
218
+ dispatch({ type: 'setContainerWidth', width });
219
+ }, []);
220
+
221
+ const { sidebarWidth, codeEditorWidth } =
222
+ getConstrainedPaneWidths(state);
223
+ const { isDraggingLeft, isDraggingRight } = state;
142
224
 
143
225
  const value: SplitPaneResizeContextValue = {
144
226
  codeEditorWidth,
@@ -148,6 +230,7 @@ export const SplitPaneResizeProvider = ({ children }) => {
148
230
  isDraggingRight,
149
231
  setIsDragging,
150
232
  setSidebarView,
233
+ setContainerWidth,
151
234
  };
152
235
 
153
236
  return (
@@ -15,6 +15,7 @@ import {
15
15
  } from '../../types';
16
16
  import { VizFiles, VizContent } from '@vizhub/viz-types';
17
17
  import { ThemeLabel } from '../themes';
18
+ import type { ChatVoiceInputRenderer } from '../../llm-streaming-ui/props';
18
19
  import { EditorCache } from '../useEditorCache';
19
20
 
20
21
  // The type of the object provided by this context.
@@ -213,6 +214,9 @@ export type VZCodeContextValue = {
213
214
  ) => Promise<any>;
214
215
  }) => React.ReactNode;
215
216
 
217
+ /** Optional host-owned microphone beside the AI Chat Send button. */
218
+ renderChatVoiceInput?: ChatVoiceInputRenderer;
219
+
216
220
  // Feature flags
217
221
  enableMinimalEditFlow: boolean;
218
222
 
@@ -268,6 +272,8 @@ export interface VZCodeProviderProps {
268
272
  options?: Record<string, string>,
269
273
  ) => Promise<any>;
270
274
  }) => React.ReactNode;
275
+ /** Host-owned chat voice input, independent of the legacy VZCode voice flag. */
276
+ renderChatVoiceInput?: ChatVoiceInputRenderer;
271
277
  iframeRef?: React.MutableRefObject<HTMLIFrameElement>;
272
278
  handleChatError?: (
273
279
  error: string,
@@ -53,6 +53,7 @@ export const useVZCodeState = ({
53
53
  clearStoredAIPrompt,
54
54
  getStoredAIPrompt,
55
55
  additionalWidgets,
56
+ renderChatVoiceInput,
56
57
  iframeRef: externalIframeRef,
57
58
  handleChatError,
58
59
  onAIChatMessageSubmitted,
@@ -510,6 +511,7 @@ export const useVZCodeState = ({
510
511
 
511
512
  // Additional widgets that can be rendered in AI chat messages
512
513
  additionalWidgets,
514
+ renderChatVoiceInput,
513
515
 
514
516
  // Feature flags
515
517
  enableMinimalEditFlow,