Let Ctrl+V reach the agent on macOS, and leave Cmd+V to the webview's own paste

AI Assisted
This commit is contained in:
Seth committed 2026-12-05 00:10:45 -08:00
1 parent b629f5ef04
commit 91479b21a1
3 files changed
+36 -3

No files matched your search

+30
View File
@@ -1383,6 +1383,36 @@ test("clipboardAction: Ctrl+C copies only with a selection (else it is the inter
assert.equal(clipboardAction(null, true), null);
});
test("clipboardAction on a Mac: Ctrl+V goes to the agent, Cmd+V is left to the webview's own paste", () => {
const ev = (key, mods = {}) => ({ key, ctrlKey: false, metaKey: false, shiftKey: false, altKey: false, ...mods });
assert.equal(clipboardAction(ev("v", { ctrlKey: true }), false, { mac: true }), null, "xterm sends \\x16 to the agent (Claude Code's image paste)");
assert.equal(clipboardAction(ev("V", { ctrlKey: true, shiftKey: true }), false, { mac: true }), null);
assert.equal(clipboardAction(ev("v", { metaKey: true }), false, { mac: true }), null, "a script clipboard read makes WebKit ask with a Paste menu first");
});
test("clipboardAction off a Mac: every key decides exactly as before the Mac rule", () => {
// The rule as it was before Ctrl+V was left to the agent on a Mac.
const before = (event, hasSelection) => {
if (event.altKey) return null;
const key = event.key.toLowerCase();
if (key === "c") {
if (event.metaKey && !event.ctrlKey) return "copy";
if (event.ctrlKey && !event.metaKey) return event.shiftKey || hasSelection ? "copy" : null;
return null;
}
if (key === "v" && (event.ctrlKey || event.metaKey)) return "paste";
return null;
};
for (const key of ["c", "C", "v", "V", "x"]) {
for (let bits = 0; bits < 16; bits++) {
const event = { key, ctrlKey: Boolean(bits & 1), metaKey: Boolean(bits & 2), shiftKey: Boolean(bits & 4), altKey: Boolean(bits & 8) };
for (const sel of [true, false]) {
assert.equal(clipboardAction(event, sel), before(event, sel), `${key} ${JSON.stringify(event)} selection ${sel}`);
}
}
}
});
test("the terminal pastes once and in brackets, copies on select only by preference, and has a Copy / Paste / Clear menu", () => {
const term = fs.readFileSync(path.join(HERE, "../plan2code-app/ui/terminal.js"), "utf8");
assert.match(term, /term\.paste\(text\)/, "bracketed paste, not onInput(text)");