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

(DEVHUB-1898, UP-6913) Add Hotkey Functionality #506

Closed
wants to merge 4 commits into from

Conversation

max-melo
Copy link
Collaborator

@max-melo max-melo commented Sep 17, 2024

Jira: https://jira.mongodb.org/browse/DEVHUB-1898, https://jira.mongodb.org/browse/UP-6913

Changes

  • Adds shouldUseHotkey prop on the ModalView and ChatWindow components that controls whether pressing the hotkey (/) will open the window, and whether the hotkey indicator is shown on the input bar.

Notes

  • Named the prop shouldUseHotkey but open to suggestions if we want to change this
  • I wasn't sure whether it made more sense to have this as a view prop, or as part of the chatbot context. I think this decision would hinge on whether we predict that the hotkey indicator will be used on an implementation that uses the InputBarTrigger, or if this is a Button trigger/ModalView-only feature. If we determine that using context makes more sense, I have a separate branch that implements it that way.

@@ -40,6 +40,7 @@ export function DevCenterChatbot(props: DevCenterChatbotProps) {
/>
</>
),
shouldUseHotkey: true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I know we aren't using this component, but I set this to true here so it would show up in the tester

docs/docs/ui.md Outdated
@@ -124,4 +124,5 @@ The `<ModalView />` component renders a chat message feed in a modal window. It
| `initialMessageText` | `string?` | The text content of an initial assistant message at the top of the message feed. | If no text is specified, then no message is shown. |
| `inputBarPlaceholder` | `string?` | The placeholder text shown when the input bar is empty. | If not specified, the input bar uses default placeholders. |
| `inputBottomText` | `string?` | Text that appears immediately below the input bar. | If not specified, no bottom text is shown. |
| `shouldUseHotkey` | `boolean?` | If `true`, the chat window will show on hotkey press (`/`) | `false` |
Copy link
Collaborator

Choose a reason for hiding this comment

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

perhaps rename to 'shouldUseSlashHotkey` to be more specific.

alternatively, could make sense to let the user define what the hotkey is. then user could set it to "/", "s", etc

Copy link
Collaborator

@nlarew nlarew Sep 17, 2024

Choose a reason for hiding this comment

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

+1 for customizable hotkey. I think ideally hotkey stuff would be handled outside of our library, but we can add it as a convenience for this case.

Taking a step back, I think the most composable pattern is to present this as a new type of trigger component, a HotkeyTrigger. You can use this alongside the input bar trigger inside of the chatbot provider.

function MyApp() {
  return (
    <Chatbot>
      <HotkeyTrigger onKey="/" />
      <DevCenterInputBarTrigger />
    </Chatbot>
  )
}

Let me know if you have thoughts / questions on how to implement!

Copy link
Collaborator Author

@max-melo max-melo Sep 17, 2024

Choose a reason for hiding this comment

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

I can go ahead and rename it to shouldUseSlashHotkey. I would lean towards this option because the slash in the indicator is hardcoded in leafygreen (with the justification being to keep the usage consistent across different sites' implementations)
edit: @nlarew Sorry didn't see your comment. If we went this route I think there would need to be follow up work in leafygreen, as currently the visual indicator (and focus listener) are hardcoded to /.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's quietly ship shouldUseSlashHotkey as a Chatbot prop and then remove it in favor of a more customizable trigger.

Copy link
Collaborator

@mongodben mongodben left a comment

Choose a reason for hiding this comment

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

see suggestion. also we should wait for nick to return and review before merge since he has been the primary developer on the mongodb-chatbot-ui package. he's out this week but should be back next

@max-melo
Copy link
Collaborator Author

see suggestion. also we should wait for nick to return and review before merge since he has been the primary developer on the mongodb-chatbot-ui package. he's out this week but should be back next

We have a bit of a tight deadline to get the chatbot on DevCenter/University--UAT starts next Tuesday, and I would still need to raise a couple of PRs to our repos following this one being merged. Is there a possibility that we can get this merged, and then if Nick has any suggestions when he returns I can create a follow-up PR, or something along those lines?

@gfunk1230
Copy link

see suggestion. also we should wait for nick to return and review before merge since he has been the primary developer on the mongodb-chatbot-ui package. he's out this week but should be back next

I am commenting on Max's comment on whether we can try to merge this. It would be great if someone could approve it in Nick's absence so that it can get merged. If we're concerned about cutting a release that may break someone else's experience, we could cut a release just for our project on university and developer center.

@mongodben
Copy link
Collaborator

see suggestion. also we should wait for nick to return and review before merge since he has been the primary developer on the mongodb-chatbot-ui package. he's out this week but should be back next

We have a bit of a tight deadline to get the chatbot on DevCenter/University--UAT starts next Tuesday, and I would still need to raise a couple of PRs to our repos following this one being merged. Is there a possibility that we can get this merged, and then if Nick has any suggestions when he returns I can create a follow-up PR, or something along those lines?

I am commenting on Max's comment on whether we can try to merge this. It would be great if someone could approve it in Nick's absence so that it can get merged. If we're concerned about cutting a release that may break someone else's experience, we could cut a release just for our project on university and developer center.

given the tight deadline, let me make a pre-release that you can pull from npm. Will just make from this branch so nothing touches main branch.

@nlarew
Copy link
Collaborator

nlarew commented Oct 16, 2024

Closing in favor of #512 and #530 - thanks for the work to set this up!

@nlarew nlarew closed this Oct 16, 2024
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.

4 participants