Skip to content

Conversation

yzhangok
Copy link
Contributor

Types of changes

  • [ x ] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

Problem

Bug report: Windows filepicker for JB lets you choose any file (not constrained to images), and selecting an unsupported file shows an error in a modal (as opposed to chat, like when you submit a file that's too large)

Solution

Starting Version 2024.3, use withExtensionFilter to hide unallowed files.

Reference: https://youtrack.jetbrains.com/issue/IJPL-179805/FileChooserDescriptorwithFileFilter-doenst-work-in-2024.3-and-later-vesion

Screenshot 2025-07-16 at 4 27 17 PM

Checklist

  • [ x ] My code follows the code style of this project
  • I have added tests to cover my changes
  • [ x ] A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@yzhangok yzhangok requested a review from a team as a code owner July 16, 2025 23:27
@yzhangok yzhangok changed the title File chooser fix(amazonq): change to use withExtensionFilter to hide unallowed files Jul 17, 2025
@@ -0,0 +1,4 @@
{
"type" : "bugfix",
"description" : "change to use withExtensionFilter to hide unallowed files when selecting image"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"description" : "change to use withExtensionFilter to hide unallowed files when selecting image"
"description" : "Fix unsupported files being shown in file picker when selecting images for adding image context in Windows"

if (isExtensionFilterSupported()) {
// Use reflection to call withExtensionFilter which is only available in 2024.3+
try {
val method = this.javaClass.getMethod("withExtensionFilter", String::class.java, Array<String>::class.java)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have different source modules that support code compatibility based on versions. Instead of using reflection, we can use those? This code can be added to src-243+. Will this still be an issue on 242?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

* The withExtensionFilter method was introduced in IntelliJ Platform 2024.3 (baseline version 243).
* For older versions, fall back to withFileFilter which provides similar functionality
*/
interface FileChooserCompat {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this interface, can we just add a separate function in the separate modules?

@samgst-amazon samgst-amazon enabled auto-merge (squash) July 31, 2025 17:46
@samgst-amazon samgst-amazon merged commit 2c23e5c into aws:main Jul 31, 2025
11 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants