mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
* feat(terminal): click archive names to fill extraction command Paste an absolute tar or unzip command when a Linux session Ctrl/Cmd-clicks a printed archive name. Cwd comes from OSC 7 markers only, so a later directory change cannot retarget an old relative name. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(terminal): anchor wrapped archive links on the continuation row A token that starts on the next physical row was mapped to the previous row's exclusive end cell. Inclusive offsets now move to the next segment, while an end-exclusive offset stays on the row where the match stops. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(terminal): separate archive fill from text after the cursor Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(terminal): separate archive fill across a wrapped draft Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
78 lines
2.1 KiB
TypeScript
78 lines
2.1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
isIdleShellReadyForCommandInjection,
|
|
isShellPromptReadyForInsertion,
|
|
} from "./terminalCommandInjectionReady.ts";
|
|
|
|
test("idle shell is ready only at a clean primary-screen prompt", () => {
|
|
assert.equal(
|
|
isIdleShellReadyForCommandInjection({
|
|
hasLiveTerminal: true,
|
|
alternateScreenActive: false,
|
|
isAtPrompt: true,
|
|
userInputLength: 0,
|
|
}),
|
|
true,
|
|
);
|
|
});
|
|
|
|
test("rejects sensitive prompts, alt-screen TUIs, partial input, and missing terminals", () => {
|
|
const ready = {
|
|
hasLiveTerminal: true,
|
|
alternateScreenActive: false,
|
|
isAtPrompt: true,
|
|
userInputLength: 0,
|
|
};
|
|
assert.equal(
|
|
isIdleShellReadyForCommandInjection({ ...ready, sensitiveInputActive: true }),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
isIdleShellReadyForCommandInjection({ ...ready, alternateScreenActive: true }),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
isIdleShellReadyForCommandInjection({ ...ready, isAtPrompt: false }),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
isIdleShellReadyForCommandInjection({ ...ready, userInputLength: 3 }),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
isIdleShellReadyForCommandInjection({ ...ready, pendingTypedInputLength: 2 }),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
isIdleShellReadyForCommandInjection({ ...ready, hasLiveTerminal: false }),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("draft insertion still blocks sensitive prompts, alt-screen, and a missing prompt", () => {
|
|
const draft = {
|
|
hasLiveTerminal: true,
|
|
alternateScreenActive: false,
|
|
isAtPrompt: true,
|
|
userInputLength: 4,
|
|
pendingTypedInputLength: 2,
|
|
};
|
|
assert.equal(isShellPromptReadyForInsertion(draft), true);
|
|
assert.equal(isIdleShellReadyForCommandInjection(draft), false);
|
|
assert.equal(
|
|
isShellPromptReadyForInsertion({ ...draft, sensitiveInputActive: true }),
|
|
false,
|
|
);
|
|
assert.equal(
|
|
isShellPromptReadyForInsertion({ ...draft, alternateScreenActive: true }),
|
|
false,
|
|
);
|
|
assert.equal(isShellPromptReadyForInsertion({ ...draft, isAtPrompt: false }), false);
|
|
assert.equal(
|
|
isShellPromptReadyForInsertion({ ...draft, hasLiveTerminal: false }),
|
|
false,
|
|
);
|
|
});
|