muuuuse 2.2.1 → 2.2.2
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/package.json +1 -1
- package/src/runtime.js +34 -2
package/package.json
CHANGED
package/src/runtime.js
CHANGED
|
@@ -35,8 +35,9 @@ const {
|
|
|
35
35
|
writeJson,
|
|
36
36
|
} = require("./util");
|
|
37
37
|
|
|
38
|
-
const TYPE_CHUNK_DELAY_MS =
|
|
39
|
-
const TYPE_CHUNK_SIZE =
|
|
38
|
+
const TYPE_CHUNK_DELAY_MS = 12;
|
|
39
|
+
const TYPE_CHUNK_SIZE = 6;
|
|
40
|
+
const ESCAPE_RELAY_GUARD_MS = 180;
|
|
40
41
|
const MIRROR_SUPPRESSION_WINDOW_MS = 30 * 1000;
|
|
41
42
|
const PENDING_RELAY_CONTEXT_TTL_MS = 2 * 60 * 1000;
|
|
42
43
|
const EMITTED_ANSWER_TTL_MS = 5 * 60 * 1000;
|
|
@@ -467,10 +468,30 @@ function stripPassiveTerminalInput(input) {
|
|
|
467
468
|
.replace(/\u0000/g, "");
|
|
468
469
|
}
|
|
469
470
|
|
|
471
|
+
function isBareEscapeInput(input) {
|
|
472
|
+
return String(input || "") === "\u001b";
|
|
473
|
+
}
|
|
474
|
+
|
|
470
475
|
function isMeaningfulTerminalInput(input) {
|
|
476
|
+
if (isBareEscapeInput(input)) {
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
471
479
|
return stripPassiveTerminalInput(input).length > 0;
|
|
472
480
|
}
|
|
473
481
|
|
|
482
|
+
function getEscapeRelayDelayMs(lastEscapeAtMs, now = Date.now()) {
|
|
483
|
+
if (!Number.isFinite(lastEscapeAtMs) || lastEscapeAtMs <= 0) {
|
|
484
|
+
return 0;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
const elapsedMs = now - lastEscapeAtMs;
|
|
488
|
+
if (elapsedMs >= ESCAPE_RELAY_GUARD_MS) {
|
|
489
|
+
return 0;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
return ESCAPE_RELAY_GUARD_MS - elapsedMs;
|
|
493
|
+
}
|
|
494
|
+
|
|
474
495
|
async function sendTextAndEnter(child, text, shouldAbort = () => false) {
|
|
475
496
|
const payload = normalizeRelayPayloadForTyping(text);
|
|
476
497
|
|
|
@@ -530,6 +551,7 @@ class ArmedSeat {
|
|
|
530
551
|
this.forceKillTimer = null;
|
|
531
552
|
this.identity = null;
|
|
532
553
|
this.lastUserInputAtMs = 0;
|
|
554
|
+
this.lastEscapeAtMs = 0;
|
|
533
555
|
this.pendingInboundContext = null;
|
|
534
556
|
this.recentInboundRelays = [];
|
|
535
557
|
this.recentEmittedAnswers = [];
|
|
@@ -807,6 +829,9 @@ class ArmedSeat {
|
|
|
807
829
|
installStdinProxy() {
|
|
808
830
|
const handleData = (chunk) => {
|
|
809
831
|
const chunkText = chunk.toString("utf8");
|
|
832
|
+
if (isBareEscapeInput(chunkText)) {
|
|
833
|
+
this.lastEscapeAtMs = Date.now();
|
|
834
|
+
}
|
|
810
835
|
if (isMeaningfulTerminalInput(chunkText)) {
|
|
811
836
|
this.lastUserInputAtMs = Date.now();
|
|
812
837
|
this.pendingInboundContext = null;
|
|
@@ -969,6 +994,11 @@ class ArmedSeat {
|
|
|
969
994
|
continue;
|
|
970
995
|
}
|
|
971
996
|
|
|
997
|
+
const escapeRelayDelayMs = getEscapeRelayDelayMs(this.lastEscapeAtMs);
|
|
998
|
+
if (escapeRelayDelayMs > 0) {
|
|
999
|
+
await sleep(escapeRelayDelayMs);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
972
1002
|
const delivered = await sendTextAndEnter(
|
|
973
1003
|
this.child,
|
|
974
1004
|
payload,
|
|
@@ -1513,7 +1543,9 @@ module.exports = {
|
|
|
1513
1543
|
ArmedSeat,
|
|
1514
1544
|
buildChildEnv,
|
|
1515
1545
|
chunkRelayPayloadForTyping,
|
|
1546
|
+
getEscapeRelayDelayMs,
|
|
1516
1547
|
getStatusReport,
|
|
1548
|
+
isBareEscapeInput,
|
|
1517
1549
|
isMeaningfulTerminalInput,
|
|
1518
1550
|
normalizeRelayPayloadForTyping,
|
|
1519
1551
|
resolveSessionName,
|