feat(cli): add experimental.useOSC52Copy setting (#19488)

This commit is contained in:
Tommaso Sciortino
2026-02-19 10:22:11 -08:00
committed by GitHub
parent ba3e327ba1
commit 09b623fbd7
8 changed files with 98 additions and 19 deletions

View File

@@ -14,6 +14,7 @@ import {
copyToClipboard,
getUrlOpenCommand,
} from './commandUtils.js';
import type { Settings } from '../../config/settingsSchema.js';
// Constants used by OSC-52 tests
const ESC = '\u001B';
@@ -257,6 +258,29 @@ describe('commandUtils', () => {
expect(mockClipboardyWrite).not.toHaveBeenCalled();
});
it('uses OSC-52 when useOSC52Copy setting is enabled', async () => {
const testText = 'forced-osc52';
const tty = makeWritable({ isTTY: true });
mockFs.createWriteStream.mockImplementation(() => {
setTimeout(() => tty.emit('open'), 0);
return tty;
});
// NO environment signals for SSH/WSL/etc.
const settings = {
experimental: { useOSC52Copy: true },
} as unknown as Settings;
await copyToClipboard(testText, settings);
const b64 = Buffer.from(testText, 'utf8').toString('base64');
const expected = `${ESC}]52;c;${b64}${BEL}`;
expect(tty.write).toHaveBeenCalledTimes(1);
expect(tty.write.mock.calls[0][0]).toBe(expected);
expect(mockClipboardyWrite).not.toHaveBeenCalled();
});
it('wraps OSC-52 for tmux when in SSH', async () => {
const testText = 'tmux-copy';
const tty = makeWritable({ isTTY: true });