claude-remote-cli 1.9.5 → 1.9.6

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 (2) hide show
  1. package/package.json +1 -1
  2. package/public/app.js +29 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-remote-cli",
3
- "version": "1.9.5",
3
+ "version": "1.9.6",
4
4
  "description": "Remote web interface for Claude Code CLI sessions",
5
5
  "type": "module",
6
6
  "main": "dist/server/index.js",
package/public/app.js CHANGED
@@ -1359,6 +1359,28 @@
1359
1359
  return count;
1360
1360
  }
1361
1361
 
1362
+ // Batched send: accumulates payload across rapid input events (e.g. autocorrect
1363
+ // fires deleteContentBackward + insertText ~2ms apart) and flushes in one
1364
+ // ws.send() so the PTY receives backspaces + replacement text atomically.
1365
+ var sendBuffer = '';
1366
+ var sendTimer = null;
1367
+ var SEND_DELAY = 10; // ms – enough to batch autocorrect pairs, imperceptible for typing
1368
+
1369
+ function scheduleSend(data) {
1370
+ sendBuffer += data;
1371
+ if (sendTimer !== null) clearTimeout(sendTimer);
1372
+ sendTimer = setTimeout(flushSendBuffer, SEND_DELAY);
1373
+ }
1374
+
1375
+ function flushSendBuffer() {
1376
+ sendTimer = null;
1377
+ if (sendBuffer && ws && ws.readyState === WebSocket.OPEN) {
1378
+ dbg('FLUSH: "' + sendBuffer.replace(/\x7f/g, '\u232b') + '" (' + sendBuffer.length + ' bytes)');
1379
+ ws.send(sendBuffer);
1380
+ }
1381
+ sendBuffer = '';
1382
+ }
1383
+
1362
1384
  // Send the diff between lastInputValue and currentValue to the terminal.
1363
1385
  // Handles autocorrect expansions, deletions, and same-length replacements.
1364
1386
  function sendInputDiff(currentValue) {
@@ -1374,11 +1396,13 @@
1374
1396
 
1375
1397
  dbg('sendInputDiff: del=' + charsToDelete + ' "' + deletedSlice + '" add="' + newChars + '"');
1376
1398
 
1399
+ var payload = '';
1377
1400
  for (var i = 0; i < charsToDelete; i++) {
1378
- ws.send('\x7f'); // backspace
1401
+ payload += '\x7f';
1379
1402
  }
1380
- if (newChars) {
1381
- ws.send(newChars);
1403
+ payload += newChars;
1404
+ if (payload) {
1405
+ scheduleSend(payload);
1382
1406
  }
1383
1407
  }
1384
1408
 
@@ -1413,9 +1437,7 @@
1413
1437
  lastInputValue = '';
1414
1438
  });
1415
1439
 
1416
- // Flush any pending composed text to the terminal.
1417
- // Safe to call even if compositionend already ran: sendInputDiff
1418
- // is a no-op when lastInputValue === mobileInput.value.
1440
+ // Flush any pending composed text and buffered sends to the terminal.
1419
1441
  function flushComposedText() {
1420
1442
  isComposing = false;
1421
1443
  if (ws && ws.readyState === WebSocket.OPEN) {
@@ -1423,6 +1445,7 @@
1423
1445
  sendInputDiff(currentValue);
1424
1446
  lastInputValue = currentValue;
1425
1447
  }
1448
+ flushSendBuffer();
1426
1449
  }
1427
1450
  function clearInput() {
1428
1451
  mobileInput.value = '';