mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-22 16:10:50 +00:00
* fix(ssh): 去掉单通道 SSH 的手动开关 单通道只在握手后匹配 BHostSSH、TERM-SSHD、CLOUDBILITY 时生效。 主机和分组不再保存这个选项,读到旧字段时直接丢掉。 * test(sftp): 对齐单通道登录后的重连扫描 专用 SFTP 登录改为 reuseTerminalTransport 之后,旧的 sourceSessionId 三元表达式扫描不再匹配,lint-and-test 因此失败。扫描改为锁定当前门槛:已连接,或已经钉住严格来源,才复用终端传输。
49 lines
2.0 KiB
TypeScript
49 lines
2.0 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import test from "node:test";
|
|
|
|
const sidePanelSource = readFileSync(new URL("../SftpSidePanel.tsx", import.meta.url), "utf8");
|
|
const tabBridgeSource = readFileSync(
|
|
new URL("../terminalLayer/TerminalLayerTabBridge.tsx", import.meta.url),
|
|
"utf8",
|
|
);
|
|
|
|
test("SFTP side panel rebinds after same-tab SSH start-over", () => {
|
|
assert.match(sidePanelSource, /shouldRebindSftpSidePanelSourceSession\(/);
|
|
assert.match(sidePanelSource, /shouldDeferSftpSidePanelAutoConnectForSession\(/);
|
|
assert.match(sidePanelSource, /lastSourceSessionStatusRef/);
|
|
assert.match(
|
|
sidePanelSource,
|
|
/previousStatus:\s*lastSourceSessionStatusRef\.current/,
|
|
);
|
|
// Reuse the terminal transport only when SSH is connected, or when a strict
|
|
// pending source id is already pinned. A dedicated single-channel login never
|
|
// reuses that transport. A linked id may arrive while reconnecting.
|
|
assert.match(
|
|
sidePanelSource,
|
|
/const reuseTerminalTransport = !dedicatedSftpLogin && \(\s*Boolean\(pendingStrictSourceSessionId\) \|\| activeSessionStatus === "connected"\s*\);/,
|
|
);
|
|
assert.match(
|
|
sidePanelSource,
|
|
/sourceSessionId: reuseTerminalTransport\s*\?\s*\(pendingStrictSourceSessionId \?\? \(activeSessionId \?\? undefined\)\)\s*: undefined/,
|
|
);
|
|
assert.match(
|
|
sidePanelSource,
|
|
/requireSourceSessionReuse: reuseTerminalTransport && Boolean\(pendingStrictSourceSessionId\)/,
|
|
);
|
|
assert.match(sidePanelSource, /resolveSftpSidePanelTrackedSourceStatusUpdate\(/);
|
|
assert.match(
|
|
sidePanelSource,
|
|
/trackedSessionId = lastSourceSessionIdRef\.current/,
|
|
);
|
|
assert.match(sidePanelSource, /if \(activeSessionId\) return;/);
|
|
});
|
|
|
|
test("terminal layer keeps the linked SFTP session id while SSH reconnects", () => {
|
|
assert.match(tabBridgeSource, /isTerminalSessionEligibleForSftpReuse\(session\)/);
|
|
assert.doesNotMatch(
|
|
tabBridgeSource,
|
|
/activeTerminalSessionIdForSftp[\s\S]*canReuseTerminalConnection\(session\)/,
|
|
);
|
|
});
|