Skip to content

Commit f855cf9

Browse files
saphidclaude
andcommitted
fix(server): a doubled escape after a cancelled string starts the next sequence
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e863548 commit f855cf9

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎apps/server/src/terminal/Manager.test.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,14 +1137,17 @@ it.layer(
11371137
process.emitData("\u0090$q m\u009c\u00901$r0m\u009c");
11381138
process.emitData("\u0090+q544e\u009c\u00901+r544e=1b\u009c");
11391139
process.emitData('\u001b[!p\u001b["p\u001b[4 q\u001b[u');
1140+
process.emitData("\u001b]0;x\u001b\u001b[?2026$p");
11401141
process.emitData("done\n");
11411142

11421143
yield* manager.close({ threadId: "thread-1" });
11431144

11441145
const reopened = yield* manager.open(openInput());
1145-
expect(reopened.history.startsWith('prompt \u001b[!p\u001b["p\u001b[4 q\u001b[udone\n')).toBe(
1146-
true,
1147-
);
1146+
expect(
1147+
reopened.history.startsWith(
1148+
'prompt \u001b[!p\u001b["p\u001b[4 q\u001b[u\u001b]0;x\u001bdone\n',
1149+
),
1150+
).toBe(true);
11481151
}),
11491152
);
11501153

‎apps/server/src/terminal/Manager.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,10 @@ function findEscapeSequenceEndIndex(input: string, start: number): number | null
11671167
if (cursor >= input.length) {
11681168
return null;
11691169
}
1170+
// A second ESC restarts the sequence, so leave it for the next pass.
1171+
if (input.charCodeAt(cursor) === 0x1b) {
1172+
return cursor;
1173+
}
11701174
return isEscapeFinalByte(input.charCodeAt(cursor)) ? cursor + 1 : start + 1;
11711175
}
11721176

0 commit comments

Comments
 (0)