@pixelbyte-software/pixcode 1.53.8 → 1.53.9

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
@@ -35,7 +35,7 @@
35
35
 
36
36
  <!-- Prevent zoom on iOS -->
37
37
  <meta name="format-detection" content="telephone=no" />
38
- <script type="module" crossorigin src="/assets/index-BTj30VBN.js"></script>
38
+ <script type="module" crossorigin src="/assets/index-nl5YZ8Wr.js"></script>
39
39
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-DB6V5Fl1.js">
40
40
  <link rel="modulepreload" crossorigin href="/assets/vendor-codemirror-CIYNS698.js">
41
41
  <link rel="modulepreload" crossorigin href="/assets/vendor-xterm-C7tpxJl7.js">
@@ -37,12 +37,18 @@ const DAEMON_COMMAND_CONTEXT = {
37
37
  nodeExecPath: process.execPath,
38
38
  };
39
39
  function resolveMonacoAssetsPath() {
40
+ const appParent = path.dirname(APP_ROOT);
41
+ const appGrandparent = path.dirname(appParent);
40
42
  const candidates = [
41
43
  path.join(APP_ROOT, 'node_modules', 'monaco-editor', 'min', 'vs'),
44
+ path.join(appParent, 'node_modules', 'monaco-editor', 'min', 'vs'),
45
+ path.join(appParent, 'monaco-editor', 'min', 'vs'),
46
+ path.join(appGrandparent, 'node_modules', 'monaco-editor', 'min', 'vs'),
47
+ path.join(appGrandparent, 'monaco-editor', 'min', 'vs'),
42
48
  ];
43
49
  try {
44
50
  const monacoPackagePath = require.resolve('monaco-editor/package.json', {
45
- paths: [APP_ROOT, __dirname],
51
+ paths: [APP_ROOT, appParent, appGrandparent, __dirname, process.cwd()],
46
52
  });
47
53
  candidates.push(path.join(path.dirname(monacoPackagePath), 'min', 'vs'));
48
54
  }
@@ -912,6 +918,8 @@ const SHELL_URL_PARSE_BUFFER_LIMIT = 32768;
912
918
  const SHELL_OUTPUT_FLUSH_MAX_CHARS = 128 * 1024;
913
919
  const SHELL_WS_BACKPRESSURE_LIMIT = 8 * 1024 * 1024;
914
920
  const PTY_SESSION_BUFFER_MAX_BYTES = Number.parseInt(process.env.PIXCODE_PTY_BUFFER_MAX_BYTES || '', 10) || (2 * 1024 * 1024);
921
+ const SHELL_INPUT_CHUNK_CHARS = 4096;
922
+ const SHELL_PENDING_INPUT_MAX_BYTES = 2 * 1024 * 1024;
915
923
  const SHELL_CLI_PROVIDERS = new Set(['claude', 'codex', 'cursor', 'gemini', 'qwen', 'opencode']);
916
924
  import { stripAnsiSequences, normalizeDetectedUrl, extractUrlsFromText, shouldAutoOpenUrlFromOutput } from './utils/url-detection.js';
917
925
  function terminatePtySession(sessionKey, session, reason) {
@@ -1132,6 +1140,27 @@ function queueTerminalStartupInput(session, startupInput, reason, delayMs = 500)
1132
1140
  function writeTerminalStartupInput(session, startupInput, reason, delayMs = 500) {
1133
1141
  queueTerminalStartupInput(session, startupInput, reason, delayMs);
1134
1142
  }
1143
+ function splitTerminalInput(data) {
1144
+ const value = String(data || '');
1145
+ if (!value)
1146
+ return [];
1147
+ const chunks = [];
1148
+ for (let index = 0; index < value.length; index += SHELL_INPUT_CHUNK_CHARS) {
1149
+ chunks.push(value.slice(index, index + SHELL_INPUT_CHUNK_CHARS));
1150
+ }
1151
+ return chunks;
1152
+ }
1153
+ function writeTerminalInputChunks(ptyProcess, data) {
1154
+ if (!ptyProcess?.write)
1155
+ return false;
1156
+ const chunks = splitTerminalInput(data);
1157
+ if (chunks.length === 0)
1158
+ return false;
1159
+ for (const chunk of chunks) {
1160
+ ptyProcess.write(chunk);
1161
+ }
1162
+ return true;
1163
+ }
1135
1164
  function normalizeShellPermissionMode(value) {
1136
1165
  return typeof value === 'string' ? value.trim() : '';
1137
1166
  }
@@ -1368,7 +1397,7 @@ app.post('/api/shell/sessions/provider-input', authenticateToken, requireProject
1368
1397
  }
1369
1398
  const data = submit ? normalizeTerminalStartupInput(input) : input;
1370
1399
  try {
1371
- matchedSession.pty.write(data);
1400
+ writeTerminalInputChunks(matchedSession.pty, data);
1372
1401
  matchedSession.updatedAt = Date.now();
1373
1402
  res.json({
1374
1403
  ok: true,
@@ -3147,7 +3176,58 @@ function handleShellConnection(ws, request) {
3147
3176
  let urlDetectionBuffer = '';
3148
3177
  let outputBuffer = '';
3149
3178
  let outputFlushTimer = null;
3179
+ let inputFlushTimer = null;
3180
+ let pendingInputBytes = 0;
3181
+ const pendingInputQueue = [];
3150
3182
  const announcedAuthUrls = new Set();
3183
+ function getActiveShellPty() {
3184
+ const session = ptySessionKey ? ptySessionsMap.get(ptySessionKey) : null;
3185
+ return session?.pty || shellProcess;
3186
+ }
3187
+ function scheduleInputFlush(delayMs = 0) {
3188
+ if (inputFlushTimer)
3189
+ return;
3190
+ inputFlushTimer = setTimeout(flushPendingInput, delayMs);
3191
+ }
3192
+ function flushPendingInput() {
3193
+ inputFlushTimer = null;
3194
+ if (pendingInputQueue.length === 0)
3195
+ return;
3196
+ const activePty = getActiveShellPty();
3197
+ if (!activePty?.write) {
3198
+ scheduleInputFlush(100);
3199
+ return;
3200
+ }
3201
+ const chunk = pendingInputQueue.shift();
3202
+ pendingInputBytes = Math.max(0, pendingInputBytes - Buffer.byteLength(chunk, 'utf8'));
3203
+ try {
3204
+ activePty.write(chunk);
3205
+ }
3206
+ catch (error) {
3207
+ console.error('Error writing to shell:', error);
3208
+ pendingInputQueue.length = 0;
3209
+ pendingInputBytes = 0;
3210
+ return;
3211
+ }
3212
+ if (pendingInputQueue.length > 0)
3213
+ scheduleInputFlush(1);
3214
+ }
3215
+ function enqueueShellInput(data) {
3216
+ const chunks = splitTerminalInput(data);
3217
+ if (chunks.length === 0)
3218
+ return;
3219
+ for (const chunk of chunks) {
3220
+ pendingInputQueue.push(chunk);
3221
+ pendingInputBytes += Buffer.byteLength(chunk, 'utf8');
3222
+ }
3223
+ while (pendingInputQueue.length > 0 && pendingInputBytes > SHELL_PENDING_INPUT_MAX_BYTES) {
3224
+ const dropped = pendingInputQueue.shift();
3225
+ pendingInputBytes -= Buffer.byteLength(String(dropped || ''), 'utf8');
3226
+ }
3227
+ if (pendingInputBytes < 0)
3228
+ pendingInputBytes = 0;
3229
+ scheduleInputFlush();
3230
+ }
3151
3231
  function flushOutputBuffer() {
3152
3232
  if (!outputBuffer || !ptySessionKey) {
3153
3233
  outputFlushTimer = null;
@@ -3534,6 +3614,7 @@ function handleShellConnection(ws, request) {
3534
3614
  if (terminalStartupInput && !isPlainShell) {
3535
3615
  writeTerminalStartupInput(createdSession, terminalStartupInput, 'new provider session', 4500);
3536
3616
  }
3617
+ scheduleInputFlush();
3537
3618
  // Handle data output — batch rapid chunks so high-volume CLI
3538
3619
  // output does not flood the WebSocket with one JSON frame per
3539
3620
  // keystroke-sized chunk.
@@ -3612,18 +3693,7 @@ function handleShellConnection(ws, request) {
3612
3693
  }
3613
3694
  }
3614
3695
  else if (data.type === 'input') {
3615
- // Send input to shell process
3616
- if (shellProcess && shellProcess.write) {
3617
- try {
3618
- shellProcess.write(data.data);
3619
- }
3620
- catch (error) {
3621
- console.error('Error writing to shell:', error);
3622
- }
3623
- }
3624
- else {
3625
- console.warn('No active shell process to send input to');
3626
- }
3696
+ enqueueShellInput(data.data);
3627
3697
  }
3628
3698
  else if (data.type === 'resize') {
3629
3699
  // Handle terminal resize
@@ -3658,6 +3728,12 @@ function handleShellConnection(ws, request) {
3658
3728
  clearTimeout(outputFlushTimer);
3659
3729
  outputFlushTimer = null;
3660
3730
  }
3731
+ if (inputFlushTimer) {
3732
+ clearTimeout(inputFlushTimer);
3733
+ inputFlushTimer = null;
3734
+ }
3735
+ pendingInputQueue.length = 0;
3736
+ pendingInputBytes = 0;
3661
3737
  if (ptySessionKey) {
3662
3738
  const session = ptySessionsMap.get(ptySessionKey);
3663
3739
  if (session) {