mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-17 21:10:48 +00:00
* fix(terminal): narrow snippet terminal restore to RHEL-family hosts Limit auto-run snippet stty protection to distros affected by #1498 and suppress wrapper echo so Ubuntu, Rocky, and macOS users see their raw commands again. Fixes #1594 Co-authored-by: Cursor <cursoragent@cursor.com> * revert(terminal): remove auto-run snippet stty protection (#1594) The wrapper added in #1498 caused visible preamble noise for all snippet executions. Revert to inserting the original command directly; the underlying CentOS 7 terminal issue reproduces when running the script manually too. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
139 lines
3.9 KiB
TypeScript
139 lines
3.9 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import type { Host } from "../domain/models";
|
|
import {
|
|
AUTO_RUN_SNIPPET_LINE_DELAY_MS,
|
|
shouldHideConnectingDialogForConnectionReuse,
|
|
shouldDelayAutoRunSnippetInput,
|
|
shouldShowTerminalConnectionDialog,
|
|
} from "./terminal/terminalHelpers";
|
|
|
|
const host = (overrides: Partial<Host> = {}): Host => ({
|
|
id: "host-1",
|
|
label: "Host",
|
|
hostname: "example.com",
|
|
username: "alice",
|
|
authMethod: "password",
|
|
...overrides,
|
|
});
|
|
|
|
test("connection dialog is hidden while a reused SSH channel is opening", () => {
|
|
assert.equal(
|
|
shouldShowTerminalConnectionDialog({
|
|
status: "connecting",
|
|
isLocalConnection: false,
|
|
isSerialConnection: false,
|
|
isDisconnectedDialogDismissed: false,
|
|
hideConnectingDialogForConnectionReuse: true,
|
|
}),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("connection dialog remains visible when reuse is not actually supported", () => {
|
|
assert.equal(
|
|
shouldShowTerminalConnectionDialog({
|
|
status: "connecting",
|
|
isLocalConnection: false,
|
|
isSerialConnection: false,
|
|
isDisconnectedDialogDismissed: false,
|
|
hideConnectingDialogForConnectionReuse: false,
|
|
}),
|
|
true,
|
|
);
|
|
});
|
|
|
|
test("connection dialog still appears for fresh remote connections", () => {
|
|
assert.equal(
|
|
shouldShowTerminalConnectionDialog({
|
|
status: "connecting",
|
|
isLocalConnection: false,
|
|
isSerialConnection: false,
|
|
isDisconnectedDialogDismissed: false,
|
|
}),
|
|
true,
|
|
);
|
|
});
|
|
|
|
test("connection dialog keeps existing local and disconnected behavior", () => {
|
|
assert.equal(
|
|
shouldShowTerminalConnectionDialog({
|
|
status: "connecting",
|
|
isLocalConnection: true,
|
|
isSerialConnection: false,
|
|
isDisconnectedDialogDismissed: false,
|
|
}),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
shouldShowTerminalConnectionDialog({
|
|
status: "connected",
|
|
isLocalConnection: false,
|
|
isSerialConnection: false,
|
|
isDisconnectedDialogDismissed: false,
|
|
}),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
shouldShowTerminalConnectionDialog({
|
|
status: "disconnected",
|
|
isLocalConnection: false,
|
|
isSerialConnection: false,
|
|
isDisconnectedDialogDismissed: true,
|
|
}),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("connection reuse hides connecting dialog only while reuse is still possible", () => {
|
|
assert.equal(
|
|
shouldHideConnectingDialogForConnectionReuse({
|
|
reuseConnectionFromSessionId: "source-session",
|
|
host: host(),
|
|
connectionReuseFellBack: false,
|
|
}),
|
|
true,
|
|
);
|
|
assert.equal(
|
|
shouldHideConnectingDialogForConnectionReuse({
|
|
reuseConnectionFromSessionId: "source-session",
|
|
host: host({ x11Forwarding: true }),
|
|
connectionReuseFellBack: false,
|
|
}),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
shouldHideConnectingDialogForConnectionReuse({
|
|
reuseConnectionFromSessionId: "source-session",
|
|
host: host({ moshEnabled: true }),
|
|
connectionReuseFellBack: false,
|
|
}),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
shouldHideConnectingDialogForConnectionReuse({
|
|
reuseConnectionFromSessionId: "source-session",
|
|
host: host({ etEnabled: true }),
|
|
connectionReuseFellBack: false,
|
|
}),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
shouldHideConnectingDialogForConnectionReuse({
|
|
reuseConnectionFromSessionId: "source-session",
|
|
host: host(),
|
|
connectionReuseFellBack: true,
|
|
}),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("auto-run snippets delay multi-line input but paste-only snippets do not", () => {
|
|
assert.equal(AUTO_RUN_SNIPPET_LINE_DELAY_MS > 0, true);
|
|
assert.equal(shouldDelayAutoRunSnippetInput("tthdf 0 2323\nadmin\ntest123", { noAutoRun: false }), true);
|
|
assert.equal(shouldDelayAutoRunSnippetInput("tthdf 0 2323\nadmin\ntest123", { noAutoRun: true }), false);
|
|
assert.equal(shouldDelayAutoRunSnippetInput("show version", { noAutoRun: false }), false);
|
|
assert.equal(shouldDelayAutoRunSnippetInput("show version\r", { noAutoRun: false }), false);
|
|
});
|