mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-17 04:32:15 +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>
63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import {
|
|
getPendingMultilinePasteConfirm,
|
|
requestMultilinePasteConfirm,
|
|
respondMultilinePasteConfirm,
|
|
subscribeMultilinePasteConfirm,
|
|
} from "./multilinePasteConfirmStore";
|
|
|
|
test("request stores the pending paste and respond resolves it", async () => {
|
|
const pending = requestMultilinePasteConfirm({
|
|
text: "line1\nline2",
|
|
lineCount: 2,
|
|
charCount: 12,
|
|
});
|
|
assert.equal(getPendingMultilinePasteConfirm()?.lineCount, 2);
|
|
|
|
respondMultilinePasteConfirm("line-by-line", "line1\nline2\nline3");
|
|
const response = await pending;
|
|
assert.deepEqual(response, { action: "line-by-line", text: "line1\nline2\nline3" });
|
|
assert.equal(getPendingMultilinePasteConfirm(), null);
|
|
});
|
|
|
|
test("respond without text falls back to the original request text", async () => {
|
|
const pending = requestMultilinePasteConfirm({
|
|
text: "line1\nline2",
|
|
lineCount: 2,
|
|
charCount: 12,
|
|
});
|
|
respondMultilinePasteConfirm("send");
|
|
const response = await pending;
|
|
assert.deepEqual(response, { action: "send", text: "line1\nline2" });
|
|
});
|
|
|
|
test("a newer paste request supersedes the pending one as cancelled", async () => {
|
|
const first = requestMultilinePasteConfirm({ text: "a\nb", lineCount: 2, charCount: 3 });
|
|
const second = requestMultilinePasteConfirm({ text: "c\nd", lineCount: 2, charCount: 3 });
|
|
assert.equal(getPendingMultilinePasteConfirm()?.text, "c\nd");
|
|
|
|
respondMultilinePasteConfirm("send", "c\nd");
|
|
assert.deepEqual(await first, { action: "cancel", text: "a\nb" });
|
|
assert.deepEqual(await second, { action: "send", text: "c\nd" });
|
|
});
|
|
|
|
test("respond without a pending request is a no-op and listeners are notified", async () => {
|
|
respondMultilinePasteConfirm("send");
|
|
assert.equal(getPendingMultilinePasteConfirm(), null);
|
|
|
|
const events: Array<string | null> = [];
|
|
const unsubscribe = subscribeMultilinePasteConfirm(() => {
|
|
events.push(getPendingMultilinePasteConfirm()?.id ?? "cleared");
|
|
});
|
|
const pending = requestMultilinePasteConfirm({ text: "x", lineCount: 1, charCount: 1 });
|
|
const pendingId = getPendingMultilinePasteConfirm()?.id ?? null;
|
|
respondMultilinePasteConfirm("cancel", "x");
|
|
await pending;
|
|
unsubscribe();
|
|
|
|
assert.ok(pendingId);
|
|
assert.deepEqual(events, [pendingId, "cleared"]);
|
|
});
|