Merge pull request #1612 from QwenLM/feat/image-attachment

feat: Add clipboard image support and attachment UI to CLI
This commit is contained in:
pomelo 2026-02-25 15:16:29 +08:00 committed by GitHub
commit 33a5116eca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 638 additions and 235 deletions

View file

@ -36,6 +36,7 @@ import {
MODIFIER_ALT_BIT,
MODIFIER_CTRL_BIT,
} from '../utils/platformConstants.js';
import { clipboardHasImage } from '../utils/clipboardUtils.js';
import { FOCUS_IN, FOCUS_OUT } from '../hooks/useFocus.js';
@ -54,6 +55,7 @@ export interface Key {
paste: boolean;
sequence: string;
kittyProtocol?: boolean;
pasteImage?: boolean;
}
export type KeypressHandler = (key: Key) => void;
@ -390,7 +392,7 @@ export function KeypressProvider({
}
};
const handleKeypress = (_: unknown, key: Key) => {
const handleKeypress = async (_: unknown, key: Key) => {
if (key.sequence === FOCUS_IN || key.sequence === FOCUS_OUT) {
return;
}
@ -400,14 +402,28 @@ export function KeypressProvider({
}
if (key.name === 'paste-end') {
isPaste = false;
broadcast({
name: '',
ctrl: false,
meta: false,
shift: false,
paste: true,
sequence: pasteBuffer.toString(),
});
if (pasteBuffer.toString().length > 0) {
broadcast({
name: '',
ctrl: false,
meta: false,
shift: false,
paste: true,
sequence: pasteBuffer.toString(),
});
} else {
const hasImage = await clipboardHasImage();
broadcast({
name: '',
ctrl: false,
meta: false,
shift: false,
paste: true,
pasteImage: hasImage,
sequence: pasteBuffer.toString(),
});
}
pasteBuffer = Buffer.alloc(0);
return;
}
@ -722,6 +738,7 @@ export function KeypressProvider({
};
let rl: readline.Interface;
if (usePassthrough) {
rl = readline.createInterface({
input: keypressStream,