Skip to content

(feat): Add context selector to prompt input #62

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

Merged
merged 7 commits into from
Jun 20, 2024

Conversation

dogusata
Copy link
Collaborator

Problem

Exactly like the quick action commands selector, a context selector should be implemented into the prompt input field. But unlike the quick action commands, it can be picked multiple times and should be written inside the prompt text. It should also send the selected context items in an additional attribute in the prompt object.
The available context items should be provided through the data model like the QuickAction commands but in a new attribute field.

We want to allow users to specify a target for the context like workspace or in the future file or folder.

Solution

  • A new field added in the tabStore data model which is called contextCommands and accepts an array of QuickActionCommandGroup
  • Prompt input text field listens @ character insertion and enables the overlay picker for the provided context items if there is any.
  • Prompt input checks if the letter trying to be removed with DEL or BACKSPACE, it checks if the cursor position is in a word which is a mention (starts with @) and removes the whole word/mention.
  • All DOCS are updated with the according information of contextCommands addition.
  • Example app is also updated to showcase the context selector functionality.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

dogusata added 6 commits June 19, 2024 17:00
added contextCommands to store model
updated prompt input text view with dynamic span
added bold wrapping for escapedPrompt to prompt rendering
updated data models
@dogusata dogusata requested a review from a team as a code owner June 20, 2024 14:02
@dogusata dogusata merged commit f0d8173 into main Jun 20, 2024
1 check passed
@ege0zcan ege0zcan deleted the dogusata/add-context-selector-to-prompt-input branch June 21, 2024 13:21
Copy link
Contributor

@ege0zcan ege0zcan left a comment

Choose a reason for hiding this comment

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

I wasn't able to finish my review before this got merged, I only noticed small typos in the PR

* */
cancelButtonWhenLoading?: boolean;
/**
* Quick Action commands to show when user hits / to the input initially
*/
quickActionCommands?: QuickActionCommandGroup[];
/**
* Context commands to show when user hits @ to the input any point
*/
contextCommands?: QuickActionCommandGroup[];
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe it is time to think of a more generic name for these given they are now shared, something like CommandGroup

mynahUI.updateStore('tab-1', {
contextCommands: [
{
groupName: 'Metion code',
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: typo Mention

---

## ChatPrompt
This is the object model which will be send along with the `onChatPrompt` event.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: typo, sent

@@ -101,7 +101,7 @@ export const QuickActionCommands:QuickActionCommandGroup[] = [
},
],
},
];
] as QuickActionCommandGroup[];
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: why is this as QuickActionCommandGroup[] needed, doesn't line 12 already ensure the type?

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