Skip to content

Commit 5686c7f

Browse files
fix(images): add automatic descriptions when users upload images
When users upload images via @path syntax or auto-detection, the AI now receives descriptive text explaining what images are attached. This solves the issue where the AI didn't know what uploaded images contained. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent 3d7fae3 commit 5686c7f

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

npm-app/src/cli.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,11 +1265,30 @@ export class CLI {
12651265
DiffManager.startUserInput()
12661266

12671267
// Build message content with images
1268+
const textParts: Array<{ type: 'text'; text: string }> = [
1269+
{ type: 'text', text: cleanedInput },
1270+
]
1271+
1272+
// Add automatic image descriptions when images are attached
1273+
if (imageParts.length > 0) {
1274+
const imageDescriptions = imageParts.map((part, index) => {
1275+
const filename = part.filename || `image_${index + 1}`
1276+
return `Image ${index + 1}: ${filename}`
1277+
})
1278+
1279+
const imageDescriptionText =
1280+
imageParts.length === 1
1281+
? `[Attached Image: ${imageDescriptions[0]}]`
1282+
: `[Attached Images:\n${imageDescriptions.map((desc) => `- ${desc}`).join('\n')}]`
1283+
1284+
textParts.push({ type: 'text', text: imageDescriptionText })
1285+
}
1286+
12681287
const messageContent: Array<
12691288
| { type: 'text'; text: string }
12701289
| { type: 'image'; image: string; mediaType: string }
12711290
> = [
1272-
{ type: 'text', text: cleanedInput },
1291+
...textParts,
12731292
...imageParts.map((part) => ({
12741293
type: 'image' as const,
12751294
image: part.image,

0 commit comments

Comments
 (0)