The best way to control Claude Code, Codex and more from any computer or phone
fix(server): a decoded U+009C no longer ends an OSC string in terminal history (#36022)
Julius Marminge committed
Nov 12, 2026 at 22:52 UTC
2dd207aabc29d7852554a4b2939f646cd3a83e1c
2 files changed
+19
-11
apps/server/src/terminal/Manager.test.ts
+15
@@ -1492,6 +1492,21 @@ it.layer(
1492
}),
1493
);
1494
1495
+ it.effect("keeps a decoded U+009C inside a stripped OSC query out of history", () =>
1496
+ Effect.gen(function* () {
1497
+ const { manager, ptyAdapter } = yield* createManager();
1498
+ yield* manager.open(openInput());
1499
+ const process = ptyAdapter.processes[0]!;
1500
+ // libghostty receives UTF-8 (c2 9c), which is OSC payload; only ESC \ ends this string.
1501
+ process.emitData("A\u001b]11;?\u009cHIDDEN\u001b\\B\n");
1502
+ // A DCS string does end at U+009C there, so the text after it stays visible.
1503
+ process.emitData("C\u001bP$qm\u009cSHOWN\u001b\\D\n");
1504
+ yield* manager.close({ threadId: "thread-1" });
1505
+
1506
+ expect((yield* manager.open(openInput())).history).toMatch(/^AB\nCSHOWN\u001b\\D\n/);
1507
+ }),
1508
+ );
1509
+
1510
it.effect("preserves large chunked OSC 52 and DCS strings across reopen", () =>
1511
Effect.gen(function* () {
1512
const { manager, ptyAdapter, logsDir } = yield* createManager();
apps/server/src/terminal/Manager.ts
+4
-11
@@ -1194,19 +1194,12 @@ function stripStringTerminator(value: string): string {
1194
return value;
1195
}
1196
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 {
1197
+// BEL ends only OSC; inside DCS, PM and APC it is payload. A decoded U+009C is the
1198
+// reverse: libghostty keeps it inside OSC but ends the other strings there.
1199
+function findStringTerminatorIndex(input: string, start: number, isOsc: boolean): number | null {
1200
for (let index = start; index < input.length; index += 1) {
1201
const codePoint = input.charCodeAt(index);
1205
- if (
1206
- (belTerminates && codePoint === 0x07) ||
1207
- codePoint === 0x9c ||
1208
- isControlSequenceCancel(codePoint)
1209
- ) {
1202
+ if ((isOsc ? codePoint === 0x07 : codePoint === 0x9c) || isControlSequenceCancel(codePoint)) {
1203
return index + 1;
1204
}
1205
// Like xterm.js, an ESC that does not start ST ends the string and begins the next sequence.