mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-21 07:32:54 +00:00
* fix(#3398): automated AI fix * fix: address Codex review on PR #3400 * fix: address Codex review on PR #3400 * fix: address Codex review on PR #3400 * fix: address Codex review on PR #3400 * fix: address Codex review on PR #3400 * fix: address Codex review on PR #3400 * fix: address Codex review on PR #3400 * fix: address Codex review on PR #3400 * fix: address Codex review on PR #3400 * fix: address Codex review on PR #3400 * fix(terminal): protect popup and sanitized multiline pastes * fix(terminal): preserve input state across paste confirmation * fix(terminal): retain serial character-mode paste echo * test(terminal): cover paced input write options * fix(terminal): retain telnet echo for paced pastes * test(terminal): scope serial buffer assertion to serial sessions * fix(terminal): align runtime write options with bridge contract * fix(terminal): preserve bookkeeping for all paced pastes * fix(terminal): record confirmed paste lines in order * fix: record paced paste commands after transport writes * fix: omit paste receipts for filtered input * fix: cancel superseded paste batches across input paths * fix: classify each acknowledged paste line before recording * fix: stop paced paste when editing buffered serial input * fix: preserve recording pause boundaries and serial edit cancellation * fix: treat paced terminal pastes as user input * fix: preserve paste drafts until write and snippet broadcast origin * fix: retain filtered paste drafts and invalidate urgent input ownership * fix: broadcast paced user paste only on guarded line receipts --------- Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com> Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
49 lines
2.7 KiB
TypeScript
49 lines
2.7 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { createRequire } from "node:module";
|
|
const require = createRequire(import.meta.url);
|
|
const backend = require("../../../electron/bridges/terminalReportSequence.cjs");
|
|
|
|
import { isTerminalReportSequence } from "./terminalReportSequence";
|
|
|
|
test("classifies automatic terminal-report replies as reports", () => {
|
|
assert.equal(isTerminalReportSequence("\x1b[?1;2c"), true); // DA1 reply
|
|
assert.equal(isTerminalReportSequence("\x1b[>0;95;0c"), true); // DA2 reply
|
|
assert.equal(isTerminalReportSequence("\x1b[12;34R"), true); // CPR reply
|
|
assert.equal(isTerminalReportSequence("\x1b[?12;34R"), true); // DECXCPR reply
|
|
assert.equal(isTerminalReportSequence("\x1b[0n"), true); // DSR reply
|
|
assert.equal(isTerminalReportSequence("\x1b[?62;1;2;6;9;15;22c"), true);
|
|
assert.equal(isTerminalReportSequence("\x1b[I"), true);
|
|
assert.equal(isTerminalReportSequence("\x1b[O"), true);
|
|
assert.equal(isTerminalReportSequence("\x1b[?1u"), true); // Kitty query reply
|
|
assert.equal(isTerminalReportSequence("\x1b[2;1$y"), true); // DECRPM reply
|
|
assert.equal(isTerminalReportSequence("\x1b[8;24;80t"), true);
|
|
assert.equal(isTerminalReportSequence("\x1b]11;rgb:0c/0c/0c\x07"), true);
|
|
assert.equal(isTerminalReportSequence("\x1bP0!r\x1b\\"), true); // DCS reply
|
|
});
|
|
|
|
test("does not classify typed text or submit keys as reports", () => {
|
|
assert.equal(isTerminalReportSequence("enable"), false);
|
|
assert.equal(isTerminalReportSequence("\r"), false);
|
|
assert.equal(isTerminalReportSequence("\n"), false);
|
|
assert.equal(isTerminalReportSequence("\x03"), false);
|
|
assert.equal(isTerminalReportSequence("\x7f"), false);
|
|
assert.equal(isTerminalReportSequence("\x1b[A"), false); // Arrow key
|
|
assert.equal(isTerminalReportSequence("\x1b[200~pasted\x1b[201~"), false);
|
|
assert.equal(isTerminalReportSequence(""), false);
|
|
});
|
|
|
|
test('renderer and backend agree on protocol replies and distinguish keyboard escape sequences', () => {
|
|
const replies = ['\x1b[I', '\x1b[O', '\x1b[1;2R', '\x1b[?1;2c', '\x1b[>1;2c', '\x1b[?997;1n',
|
|
'\x1b[?3u', '\x1b[?2004;1$y', '\x1b[8;24;80t', '\x1b[6;12;8t', '\x1b[4;1080;1920t',
|
|
'\x1b]10;rgb:ffff/ffff/ffff\x1b\\', '\x1b]4;255;rgb:ffff/0000/ffff\x1b\\',
|
|
'\x1b]11;rgb:0000/0000/0000\x07', '\x1bP1$r0m\x1b\\'];
|
|
const keys = ['hello', '\r', '\x7f', '\x15', '\x1b[A', '\x1b[D', '\x1b[3~', '\x1bOD', '\x1bx', '\x1b[200~paste\x1b[201~'];
|
|
for (const [values, expected] of [[replies, true], [keys, false]] as const) {
|
|
for (const value of values) {
|
|
assert.equal(isTerminalReportSequence(value), expected, JSON.stringify(value));
|
|
assert.equal(isTerminalReportSequence(value), backend.isTerminalReportSequence(value), JSON.stringify(value));
|
|
}
|
|
}
|
|
});
|