Compare commits

...
Author SHA1 Message Date
bincxz 6a138ba0b1 fix(ai): preserve terminal replies between OSC contexts 2026-10-15 14:51:04 +08:00
2 changed files with 15 additions and 1 deletions

No files matched your search

+1 -1
View File
@@ -13,7 +13,7 @@ const path = require("node:path");
// ── ANSI / URL regexes ──
const ANSI_ESCAPE_REGEX = /\u001B\[[0-?]*[ -/]*[@-~]/g;
const ANSI_OSC_REGEX = /\u001B\][^\u0007]*(?:\u0007|\u001B\\)/g;
const ANSI_OSC_REGEX = /\u001B\][^\u0007]*?(?:\u0007|\u001B\\)/g;
const URL_CANDIDATE_REGEX = /https?:\/\/[^\s]+/g;
const WINDOWS_RUNNABLE_EXTENSIONS = [".exe", ".cmd", ".bat", ".com"];
const MAX_PROMPT_TRACK_TAIL = 4096;
+14
View File
@@ -2,6 +2,7 @@ const test = require("node:test");
const assert = require("node:assert/strict");
const {
stripAnsi,
addCodexExecutableEnvForSdk,
buildWindowsShellCommandLine,
extractTrailingIdlePrompt,
@@ -28,6 +29,19 @@ const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");
test("OSC stripping preserves text between independently terminated sequences", () => {
for (const firstEnd of ["\x07", "\x1b\\"]) {
for (const secondEnd of ["\x07", "\x1b\\"]) {
const text = `\x1b]3008;start${firstEnd}\nprobe-reply\n\x1b]3008;end${secondEnd}prompt`;
assert.equal(stripAnsi(text), "\nprobe-reply\nprompt");
}
}
assert.equal(
stripAnsi("before\x1b[31mcolored\x1b[0m\x1b]0;title\x07after"),
"beforecoloredafter",
);
});
test("formatSyntheticEcho normalizes multi-line commands to CRLF so xterm doesn't staircase", () => {
assert.equal(
formatSyntheticEcho("set -e\ncd /tmp\necho done"),