The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 17:15 UTC
fix(server): BEL inside a DCS no longer ends it in terminal history (#36020)
Julius Marminge committed
Nov 12, 2026 at 22:01 UTC
c29c26afeb5789ac1260b8b75eeb39a876bbf6b1
2 files changed
+14
-2
apps/server/src/terminal/Manager.test.ts
+2
@@ -1402,6 +1402,8 @@ it.layer(
1402
process.emitData("\u001b[=c\u001b[=0c");
1403
process.emitData("\u001bP$q m\u001b\\\u001bP1$r0m\u001b\\");
1404
process.emitData("\u001bP+q544e\u001b\\\u001bP1+r544e=1b\u001b\\");
1405
+ // BEL is DCS payload, not a terminator: only ST ends the string.
1406
+ process.emitData("\u001bP$qm\u0007hidden\u001b\\\u001bP+q544e\u0007hidden\u001b\\");
1407
process.emitData('\u001b[!p\u001b["p\u001b[4 q\u001b[u');
1408
process.emitData("\u001b]0;x\u001b\u001b[?2026$p");
1409
process.emitData("done\n");
apps/server/src/terminal/Manager.ts
+12
-2
@@ -1194,10 +1194,19 @@ function stripStringTerminator(value: string): string {
1194
return value;
1195
}
1196
1197
-function findStringTerminatorIndex(input: string, start: number): number | null {
1197
+// BEL ends only OSC; inside DCS, PM and APC it is payload.
1198
+function findStringTerminatorIndex(
1199
+ input: string,
1200
+ start: number,
1201
+ belTerminates: boolean,
1202
+): number | null {
1203
for (let index = start; index < input.length; index += 1) {
1204
const codePoint = input.charCodeAt(index);
1200
- if (codePoint === 0x07 || codePoint === 0x9c || isControlSequenceCancel(codePoint)) {
1205
+ if (
1206
+ (belTerminates && codePoint === 0x07) ||
1207
+ codePoint === 0x9c ||
1208
+ isControlSequenceCancel(codePoint)
1209
+ ) {
1210
return index + 1;
1211
}
1212
// Like xterm.js, an ESC that does not start ST ends the string and begins the next sequence.
@@ -1293,6 +1302,7 @@ function sanitizeTerminalHistoryChunk(
1302
const terminatorIndex = findStringTerminatorIndex(
1303
input,
1304
Math.max(index + 2, pendingScanStart),
1305
+ nextCodePoint === 0x5d,
1306
);
1307
if (terminatorIndex === null) {
1308
return { visibleText, pendingControlSequence: input.slice(index) };