Skip to content

Commit 80876ab

Browse files
committed
fix: normalize path separators for Windows compatibility in generateImageTool
- Replace backslashes with forward slashes in imagePath to ensure consistent behavior across platforms - Fixes test failure on Windows where path.join() creates OS-specific separators
1 parent 763492d commit 80876ab

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/core/tools/generateImageTool.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ export async function generateImageTool(
241241

242242
// Get the webview URI for the image
243243
const provider = cline.providerRef.deref()
244+
// Use forward slashes for consistency across platforms in the imagePath
244245
const fullImagePath = path.join(cline.cwd, finalPath)
246+
const normalizedImagePath = fullImagePath.replace(/\\/g, "/")
245247

246248
// Convert to webview URI if provider is available
247249
let imageUri = provider?.convertToWebviewUri?.(fullImagePath) ?? vscode.Uri.file(fullImagePath).toString()
@@ -250,8 +252,8 @@ export async function generateImageTool(
250252
const cacheBuster = Date.now()
251253
imageUri = imageUri.includes("?") ? `${imageUri}&t=${cacheBuster}` : `${imageUri}?t=${cacheBuster}`
252254

253-
// Send the image with the webview URI
254-
await cline.say("image", JSON.stringify({ imageUri, imagePath: fullImagePath }))
255+
// Send the image with the webview URI (use normalized path for consistency)
256+
await cline.say("image", JSON.stringify({ imageUri, imagePath: normalizedImagePath }))
255257
pushToolResult(formatResponse.toolResult(getReadablePath(cline.cwd, finalPath)))
256258

257259
return

0 commit comments

Comments
 (0)