Skip to content
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

feat: allow drag and drop of image file in prompt textArea #566

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

PhilKes
Copy link
Contributor

@PhilKes PhilKes commented May 16, 2024

This PR closes #554

Adds support for drag&drop of a single image file into the prompt
codegpt-drop-image2

@PhilKes
Copy link
Contributor Author

PhilKes commented May 16, 2024

@carlrobertoh no idea why the ChatToolWindowTabPanelTest.testSendingOpenAIMessageWithImage fails, it succeeds locally.
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
https://github.com/carlrobertoh/CodeGPT/actions/runs/9112340838/job/25051402045?pr=566#step:4:724

@carlrobertoh
Copy link
Owner

Noice! 👍

It happens because the tests on the Github runner are executed in headless mode. You can replicate this by running export JAVA_TOOL_OPTIONS='-Djava.awt.headless=true' before executing the tests. Not sure what the fix is yet.

@PhilKes
Copy link
Contributor Author

PhilKes commented May 17, 2024

Noice! 👍

It happens because the tests on the Github runner are executed in headless mode. You can replicate this by running export JAVA_TOOL_OPTIONS='-Djava.awt.headless=true' before executing the tests. Not sure what the fix is yet.

Ah I see, in the DropTarget constructor:

public DropTarget(Component c, int ops, DropTargetListener dtl,   boolean act, FlavorMap fm)  throws HeadlessException   {
        if (GraphicsEnvironment.isHeadless()) {
            throw new HeadlessException();
        }
      ...
}

var t = evt.getTransferable();
var isSupportedFile = false;
try {
List<File> files = (List<File>) t.getTransferData(
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, apparently this results in null on macOS, or at least it doesn't work for me. 😞

Here's bit of a context: https://stackoverflow.com/a/64926775

I tried using the latest JB JRE while running the plugin locally, as suggested. I also installed the plugin manually on my actual IDE, but both scenarios resulted in a NPE. I haven't tried the first option yet tho.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm that is quite annoying. Unfortunately I do not have macOS so I can't try it out myself 🙃

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.

Add support for drag and drop document attachment
2 participants