mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
cb06857480
* 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>
45 lines
2.0 KiB
JavaScript
45 lines
2.0 KiB
JavaScript
"use strict";
|
|
const test = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
const { EventEmitter } = require("node:events");
|
|
const { createPreloadApi } = require("./api.cjs");
|
|
|
|
test("paste ID is opt-in and receipts use direct IPC with removable subscription", () => {
|
|
const ipcRenderer = new EventEmitter();
|
|
const sent = [];
|
|
ipcRenderer.send = (...args) => sent.push(args);
|
|
const api = createPreloadApi({ ipcRenderer, webUtils: {} });
|
|
api.writeToSession("s", "secret", { automated: true, lineDelayMs: 100, pasteRequestId: "uuid" });
|
|
assert.equal(sent[0][0], "netcatty:write");
|
|
assert.equal(sent[0][1].pasteRequestId, "uuid");
|
|
api.writeToSession("s", "x");
|
|
api.writeToSession("s", "x", { pasteRequestId: 17 });
|
|
assert.equal(sent[1][1].pasteRequestId, undefined);
|
|
assert.equal(sent[2][1].pasteRequestId, undefined);
|
|
const calls = [];
|
|
const unsubscribe = api.onTerminalPasteWrite((...args) => calls.push(args));
|
|
const receipt = { sessionId: "s", requestId: "uuid", index: 0, done: true };
|
|
ipcRenderer.emit("netcatty:paste-write", { sender: "private" }, receipt);
|
|
assert.deepEqual(calls, [[receipt]]);
|
|
unsubscribe();
|
|
ipcRenderer.emit("netcatty:paste-write", {}, receipt);
|
|
assert.equal(calls.length, 1);
|
|
assert.equal(ipcRenderer.listenerCount("netcatty:paste-write"), 0);
|
|
});
|
|
|
|
test("cancel-only bypasses urgent raw-interrupt port while ordinary interrupt preserves it", () => {
|
|
const ipcRenderer = new EventEmitter();
|
|
const sent = [];
|
|
const urgent = [];
|
|
ipcRenderer.send = (...args) => sent.push(args);
|
|
const api = createPreloadApi({ ipcRenderer, webUtils: {}, terminalUrgentInputPorts: {
|
|
postInterrupt(...args) { urgent.push(args); return true; },
|
|
} });
|
|
api.interruptSession("s", undefined, { cancelPendingWritesOnly: true });
|
|
assert.deepEqual(sent, [["netcatty:interrupt", { sessionId: "s", trace: undefined, cancelPendingWritesOnly: true }]]);
|
|
assert.deepEqual(urgent, []);
|
|
api.interruptSession("s");
|
|
assert.equal(urgent.length, 1);
|
|
assert.equal(sent.length, 1);
|
|
});
|