Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
108 lines
3.3 KiB
TypeScript
108 lines
3.3 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
computeLivePreviewWrite,
|
|
isWindowsShellLineInput,
|
|
shouldWriteAutocompleteLivePreview,
|
|
} from "./autocomplete/livePreviewSequence.ts";
|
|
|
|
test("network-device sessions skip live-preview PTY writes (#1193)", () => {
|
|
assert.equal(shouldWriteAutocompleteLivePreview(true, false), true);
|
|
assert.equal(shouldWriteAutocompleteLivePreview(true, true), false);
|
|
assert.equal(shouldWriteAutocompleteLivePreview(false, false), false);
|
|
assert.equal(shouldWriteAutocompleteLivePreview(false, true), false);
|
|
});
|
|
|
|
test("appends only the tail when the candidate continues the current line", () => {
|
|
assert.equal(
|
|
computeLivePreviewWrite({ currentLine: "do", candidate: "docker", os: "linux" }),
|
|
"cker",
|
|
);
|
|
});
|
|
|
|
test("returns empty when the line already equals the candidate", () => {
|
|
assert.equal(
|
|
computeLivePreviewWrite({ currentLine: "docker", candidate: "docker", os: "linux" }),
|
|
"",
|
|
);
|
|
});
|
|
|
|
test("clears with Ctrl-U then writes the full candidate on a non-prefix change", () => {
|
|
assert.equal(
|
|
computeLivePreviewWrite({ currentLine: "docker", candidate: "df", os: "linux" }),
|
|
"\x15df",
|
|
);
|
|
});
|
|
|
|
test("clears when switching to a shorter prefix candidate", () => {
|
|
assert.equal(
|
|
computeLivePreviewWrite({ currentLine: "docker-compose", candidate: "docker", os: "linux" }),
|
|
"\x15docker",
|
|
);
|
|
});
|
|
|
|
test("reverting to the typed baseline clears then rewrites the baseline", () => {
|
|
assert.equal(
|
|
computeLivePreviewWrite({ currentLine: "docker", candidate: "do", os: "linux" }),
|
|
"\x15do",
|
|
);
|
|
});
|
|
|
|
test("Windows uses backspaces sized to the current line, not Ctrl-U", () => {
|
|
assert.equal(
|
|
computeLivePreviewWrite({ currentLine: "abc", candidate: "xy", os: "windows" }),
|
|
"\b\b\bxy",
|
|
);
|
|
});
|
|
|
|
test("a Windows prompt clears with backspaces even when the host OS flag is mislabeled (#3184)", () => {
|
|
// PowerShell on Windows SSH with the saved host left at the os:"linux"
|
|
// default: Ctrl-U renders literally and visited suggestions accumulate.
|
|
assert.equal(
|
|
computeLivePreviewWrite({
|
|
currentLine: "uv run tkauto video sync-fs",
|
|
candidate: "uv run tkauto video daily",
|
|
os: "linux",
|
|
promptText: "(base) PS C:\\Users\\Administrator>",
|
|
}),
|
|
"\b".repeat("uv run tkauto video sync-fs".length) + "uv run tkauto video daily",
|
|
);
|
|
// cmd.exe prompt form.
|
|
assert.equal(
|
|
computeLivePreviewWrite({
|
|
currentLine: "echo",
|
|
candidate: "cls",
|
|
os: "linux",
|
|
promptText: "C:\\Users\\Administrator>",
|
|
}),
|
|
"\b\b\b\bcls",
|
|
);
|
|
});
|
|
|
|
test("a POSIX prompt keeps the Ctrl-U clear when the host OS flag is linux", () => {
|
|
assert.equal(
|
|
computeLivePreviewWrite({
|
|
currentLine: "docker",
|
|
candidate: "df",
|
|
os: "linux",
|
|
promptText: "root@web:~#",
|
|
}),
|
|
"\x15df",
|
|
);
|
|
assert.equal(
|
|
computeLivePreviewWrite({
|
|
currentLine: "docker",
|
|
candidate: "df",
|
|
os: "linux",
|
|
promptText: "user@host:/mnt/c/Users",
|
|
}),
|
|
"\x15df",
|
|
);
|
|
});
|
|
|
|
test("isWindowsShellLineInput treats an explicit windows flag as authoritative", () => {
|
|
assert.equal(isWindowsShellLineInput("windows", "root@web:~#"), true);
|
|
assert.equal(isWindowsShellLineInput("linux"), false);
|
|
assert.equal(isWindowsShellLineInput("linux", null), false);
|
|
});
|