-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Bust cache in generated image preview #7860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
763492d
80876ab
84962cf
d40af13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -244,7 +244,11 @@ export async function generateImageTool( | |||||||||
| const fullImagePath = path.join(cline.cwd, finalPath) | ||||||||||
|
|
||||||||||
| // Convert to webview URI if provider is available | ||||||||||
| const imageUri = provider?.convertToWebviewUri?.(fullImagePath) ?? vscode.Uri.file(fullImagePath).toString() | ||||||||||
| let imageUri = provider?.convertToWebviewUri?.(fullImagePath) ?? vscode.Uri.file(fullImagePath).toString() | ||||||||||
|
|
||||||||||
| // Add cache-busting parameter to prevent browser caching issues | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be helpful to add a brief comment explaining why cache-busting is needed? This could help future maintainers understand the context, something like:
Suggested change
|
||||||||||
| const cacheBuster = Date.now() | ||||||||||
| imageUri = imageUri.includes("?") ? `${imageUri}&t=${cacheBuster}` : `${imageUri}?t=${cacheBuster}` | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using a more descriptive parameter name for clarity. Instead of
Suggested change
|
||||||||||
|
|
||||||||||
| // Send the image with the webview URI | ||||||||||
| await cline.say("image", JSON.stringify({ imageUri, imagePath: fullImagePath })) | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great test coverage! Consider adding an additional test case to verify the behavior when the URI already contains query parameters (testing the
includes("?")branch). This would ensure both code paths are covered: