Skip to content

Commit 57a9899

Browse files
committed
Change clipboard image display to clean [image #N] format
Users now see clean labels like [image #1], [image #2] instead of full paths. The system automatically transforms these to @.gemini-clipboard/image-N.png when submitting. Display: [image #1] [image #2] Internal: @.gemini-clipboard/image-1.png @.gemini-clipboard/image-2.png
1 parent c1e81d5 commit 57a9899

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

packages/cli/src/ui/components/InputPrompt.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,18 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
234234
if (shellModeActive) {
235235
shellHistory.addCommandToHistory(submittedValue);
236236
}
237+
238+
// Transform [image #N] to @.gemini-clipboard/image-N.png before submission
239+
// Most clipboard images are PNG format
240+
const transformedValue = submittedValue.replace(
241+
/\[image #(\d+)\]/g,
242+
'@.gemini-clipboard/image-$1.png',
243+
);
244+
237245
// Clear the buffer *before* calling onSubmit to prevent potential re-submission
238246
// if onSubmit triggers a re-render while the buffer still holds the old value.
239247
buffer.setText('');
240-
onSubmit(submittedValue);
248+
onSubmit(transformedValue);
241249
resetCompletionState();
242250
resetReverseSearchCompletionState();
243251
},
@@ -340,11 +348,14 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
340348
// Ignore cleanup errors
341349
});
342350

343-
// Get relative path from current directory
344-
const relativePath = path.relative(config.getTargetDir(), imagePath);
351+
// Extract image number from filename (e.g., "image-1.png" -> 1)
352+
const filename = path.basename(imagePath);
353+
const imageNumberMatch = filename.match(/image-(\d+)\./);
354+
const imageNumber = imageNumberMatch ? imageNumberMatch[1] : '?';
345355

346-
// Insert @path reference
347-
const insertText = `@${relativePath}`;
356+
// Insert friendly label only: [image #1]
357+
// The actual path will be resolved at submit time
358+
const insertText = `[image #${imageNumber}]`;
348359
const currentText = buffer.text;
349360
const offset = buffer.getOffset();
350361

0 commit comments

Comments
 (0)