MCPcopy
hub / github.com/codeaashu/claude-code / onImagePaste

Function onImagePaste

src/components/PromptInput/PromptInput.tsx:1151–1183  ·  view source on GitHub ↗
(image: string, mediaType?: string, filename?: string, dimensions?: ImageDimensions, sourcePath?: string)

Source from the content-addressed store, hash-verified

1149 }));
1150 }
1151 function onImagePaste(image: string, mediaType?: string, filename?: string, dimensions?: ImageDimensions, sourcePath?: string) {
1152 logEvent('tengu_paste_image', {});
1153 onModeChange('prompt');
1154 const pasteId = nextPasteIdRef.current++;
1155 const newContent: PastedContent = {
1156 id: pasteId,
1157 type: 'image',
1158 content: image,
1159 mediaType: mediaType || 'image/png',
1160 // default to PNG if not provided
1161 filename: filename || 'Pasted image',
1162 dimensions,
1163 sourcePath
1164 };
1165
1166 // Cache path immediately (fast) so links work on render
1167 cacheImagePath(newContent);
1168
1169 // Store image to disk in background
1170 void storeImage(newContent);
1171
1172 // Update UI
1173 setPastedContents(prev => ({
1174 ...prev,
1175 [pasteId]: newContent
1176 }));
1177 // Multi-image paste calls onImagePaste in a loop. If the ref is already
1178 // armed, the previous pill's lazy space fires now (before this pill)
1179 // rather than being lost.
1180 const prefix = pendingSpaceAfterPillRef.current ? ' ' : '';
1181 insertTextAtCursor(prefix + formatImageRef(pasteId));
1182 pendingSpaceAfterPillRef.current = true;
1183 }
1184
1185 // Prune images whose [Image #N] placeholder is no longer in the input text.
1186 // Covers pill backspace, Ctrl+U, char-by-char deletion — any edit that drops

Callers 3

PromptInputFunction · 0.70
SelectInputOptionFunction · 0.50
usePasteHandlerFunction · 0.50

Calls 5

logEventFunction · 0.85
cacheImagePathFunction · 0.85
storeImageFunction · 0.85
insertTextAtCursorFunction · 0.85
formatImageRefFunction · 0.85

Tested by

no test coverage detected