Skip to content

Conversation

zuoyaofu
Copy link
Contributor

@zuoyaofu zuoyaofu commented Jun 21, 2025

Types of changes

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

Description

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • 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.

@zuoyaofu zuoyaofu changed the title Image feat(q): add image context support Jun 21, 2025
@zuoyaofu zuoyaofu changed the title feat(q): add image context support feat(amazonq): add image context support Jun 21, 2025
}
}
OPEN_FILE_DIALOG -> {
handleChat(AmazonQChatServer.showOpenFileDialog, node)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you walk me through the message flow? does it actually need to transit through flare before requesting the file picker?

Copy link
Contributor Author

@zuoyaofu zuoyaofu Jun 25, 2025

Choose a reason for hiding this comment

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

Flow:

  1. chat-client will send openFileDialog request to flare
  2. Flare will send to extension the params, including canSelectMany (multiple files), filters (what file extension types are allowed)
  3. Extension will then handle file selection logic and send back the list of URIs.
  4. Flare will then send to chat-client the file uri to display in chat.

- does it actually need to transit through flare before requesting the file picker?

  • In @yzhangok's design, yes. Flare is also telling client what type of files are supported in file picker as well(step 2)

// Set DropTarget on the browser component and its children
browserInstance.component()?.let { component ->
component.dropTarget = dropTarget
// Also try setting on parent if needed
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is to make sure all chat window is drop area

}
}

// Set DropTarget on the browser component and its children
Copy link
Contributor

Choose a reason for hiding this comment

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

how are the children involved

Copy link
Contributor

Choose a reason for hiding this comment

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

We want the whole chat window to be "drag & drop zone"

FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()
}

val chosenFiles = FileChooser.chooseFiles(descriptor, project, null)
Copy link
Contributor

Choose a reason for hiding this comment

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

why aren't images from this flow subject to constraints?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, they are now with the new commit.

Copy link
Contributor

Choose a reason for hiding this comment

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

what about the file size and dimensional limits?

Copy link
Contributor

Choose a reason for hiding this comment

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

The validation of the images chosen from file picker is done in language-server

@zuoyaofu zuoyaofu marked this pull request as ready for review June 26, 2025 22:38
@zuoyaofu zuoyaofu requested review from a team as code owners June 26, 2025 22:38
FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()
}

val chosenFiles = FileChooser.chooseFiles(descriptor, project, null)
Copy link
Contributor

Choose a reason for hiding this comment

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

what about the file size and dimensional limits?

continue
}
if (img.height > maxDimension) {
errorMessages.add("$fileName: Image must be no more than 8,000px in height.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't all these checks also in language-server? Do they need to be duplicated on the client?

Copy link
Contributor

Choose a reason for hiding this comment

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

Due to the restriction of Jetbrain webveiw, we have to handle the drag&drop natively

Comment on lines +145 to +147
val allowedTypes = setOf("jpg", "jpeg", "png", "gif", "webp")
val maxFileSize = 3.75 * 1024 * 1024 // 3.75MB in bytes
val maxDimension = 8000
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this here, can you please add a comment to the flare location that this picks up the values from?

Copy link
Contributor

Choose a reason for hiding this comment

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

JCEF does not propagate OS-level dragenter, dragOver and drop into DOM. As an alternative, enabling the native drag in JCEF, and let the native handling the drop event, and update the UI through JS bridge.
The same logic of filtering the images are implemented on both language server and JetBrain

@zuoyaofu
Copy link
Contributor Author

zuoyaofu commented Jul 8, 2025

@samgst-amazon
Copy link
Contributor

/retryBuilds

@samgst-amazon samgst-amazon merged commit 83ac4f5 into aws:main Jul 9, 2025
11 of 12 checks passed
samgst-amazon added a commit that referenced this pull request Jul 9, 2025
aws-toolkit-automation pushed a commit that referenced this pull request Jul 9, 2025
samgst-amazon added a commit that referenced this pull request Jul 9, 2025
bryceitoc9 added a commit that referenced this pull request Jul 10, 2025
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.

6 participants