-
Notifications
You must be signed in to change notification settings - Fork 35
Add space and move the cursor after drag and drop to empty prompt, ch… #387
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
Conversation
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.
It seems like the drag & drop functionality in demo app is broken, this makes it hard for others to validate the functionality of this feature Screen.Recording.2025-07-03.at.8.57.27.AM.mov |
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.
I'm not fan of strictly defining the whole drag drop functionality just for images. This will cause duplication of code whenever we need different file types to be handled. However, you can do note it as a future TODO
.
However, please avoid using hard coded strings for check statements. It is pretty open to mistakes. And not future proof. Please move the image
string comparison to type. in the QuickActionCommand
type definition command
can be string | ImageCommandTypes
which you can define. Then the consumer has to follow it.
MynahUITabsStore.getInstance().addListenerToDataStore(props.tabId, 'contextCommands', (contextCommands: QuickActionCommandGroup[]) => { | ||
// Feature flag for image context command | ||
this.imageContextFeatureEnabled = contextCommands?.some(group => | ||
group.commands.some((cmd: QuickActionCommand) => cmd.command.toLowerCase() === 'image') |
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.
Still not fan of using static text comparisons, please avoid doing it.
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.
Define file type list if possible, since you can make the same thing for different file types in the future. I'm pretty sure that it will not be limited to image files in close future.
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.
If possible, grab them from config with their icons.
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.
This is the feature flags, will be removed after image context is launched in all IDEs.
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.
The IDE controls image-related functionality through the imageContextEnabled feature flag. When this flag is set to true, the language server adds the Image option to the available context types.
Users can add images to the context in Mynah UI through three methods:
- Using the context command menu
- Typing the @image: command
- Dragging and dropping images
To maintain consistency, we've implemented a centralized feature flag that controls the visibility of all three image-adding methods. This ensures that image functionality is either entirely available or unavailable across for an IDE.
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.
There is no imageContextEnabled feature flag thats controllable by a consumer, from what I can see in this PR you still depend on filtering contextCommands to see if image is in there, and thats how you set imageContextEnabled
@@ -193,72 +220,27 @@ export class ChatWrapper { | |||
persistent: true, | |||
events: { | |||
dragenter: (e: DragEvent) => { | |||
if (!this.hasImageContextCommand()) return; | |||
if (!this.imageContextFeatureEnabled) return; |
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.
Sill don't understand why we're strictly defining this feature for image, I still don't see it as a future proof implementation. What if we want to have more files in the future? Will we define everything one by one?
classNames: [ 'mynah-drag-overlay-content' ], | ||
children: [ | ||
new Icon({ icon: MynahIcons.IMAGE }).render, | ||
{ type: 'span', children: [ 'Add image to context' ] } |
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.
no text should be hardcoded, the string and icon should come from config, as Dogus pointed out in other comments
hardcoding it here means that the consumer has no control over what appears here. mynah-ui changes will be needed every time we want to change the string
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.
Fixed
…ange image icon and improve overlay removal's latency
Fix typo Co-authored-by: Avi Alpert <[email protected]>
@@ -789,6 +790,7 @@ export interface ConfigOptions { | |||
codeInsertToCursorEnabled?: boolean; | |||
codeCopyToClipboardEnabled?: boolean; | |||
test?: boolean; | |||
dragOverlayIcon?: MynahIcons | MynahIconsType | CustomIcon; |
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.
TODO: Please add documentation to CONFIG.md for these new fields
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.
Will send followup pr to fix this
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.
yeah thats fine
@@ -66,6 +71,26 @@ export class ChatWrapper { | |||
type: 'div', | |||
classNames: [ 'mynah-chat-wrapper-header-spacer' ] | |||
}); | |||
|
|||
/* | |||
The IDE controls image-related functionality through the imageContextEnabled feature flag. |
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.
This comment is not true. You did not add an imageContextEnabled feature flag that the IDE can control. This PR sets imageContextEnabled based on whether an image
command is included in the contextCommands
Please either fix the comment or preferably, fix the functionality and have it as a feature flag set in config
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background: rgba(255,255,255,0.7); |
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.
hardcoding colors is not allowed, you need to use variables (an existing one or add your own)
There are several reasons why we don't hardcode colors in mynah-ui, the main one being is this may break on different themes
flex-direction: column; | ||
align-items: center; | ||
z-index: 2; | ||
font-size: 1.2em; |
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.
do not use hardcoded font size, use font size variable
align-items: center; | ||
z-index: 2; | ||
font-size: 1.2em; | ||
color: #333; |
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.
another hardcoded color
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.
+1
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.
I will approve to unblock launch - however please refer back to this PR's comments to be addressed in a follow up
…ange image icon and improve overlay removal's latency
Problem
This is to fix the issue found during bug bash
Solution
Force repaint before dispatch the event
The
insertContextToPosition
is not able to handle the case when cursor position is 0, this is only happen in drag&drop, since customer does not need to type/click to trigger add context.This is reproducable when first click on
@Pin Context
, then does not select anything. Since thetopBarTitleClick
is still true in this case, the context added through drag&drop will be added to pinned context. Dispatch the eventRESET_TOP_BAR_CLICKED
(Renamed fromCONTEXT_INSERTED
) to reset the trigger source before add the context.Tests
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.