-
Notifications
You must be signed in to change notification settings - Fork 748
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
Add some additional keybindings, improve re-opening an already open bot #1203
Conversation
@@ -82,6 +82,14 @@ export class TabBar extends React.Component<TabBarProps, TabBarState> { | |||
}; | |||
} | |||
|
|||
public componentDidMount() { | |||
window.addEventListener('keydown', this.keyboardListener); |
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.
Event naming should follow JS best practices. in this case onKeyDown
or onWindowKeyDown
is recommended.
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.
👍
const key = event.key.toLowerCase(); | ||
|
||
if (ctrlOrCmdPressed && key === 'o') { | ||
const { Commands: { Bot: { OpenBrowse }} } = SharedConstants; |
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 const
declaration is redundant since it is only ever used once. Consider just using SharedConstants.commands.Bot.OpenBrowse
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 going to hoist this declaration as the following (and leave the destructuring in place)
const { Commands: { Bot: { OpenBrowse }, UI: { ShowBotCreationDialog }} } = SharedConstants;
} | ||
|
||
if (ctrlOrCmdPressed && key === 'n') { | ||
const { Commands: { UI: { ShowBotCreationDialog }} } = SharedConstants; |
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.
same here: redundant const
declaration
} | ||
})); | ||
|
||
describe('#globalHandlers', () => { |
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.
Consider making this test suite read like a sentence. Instead of #globalHandlers handles CMD+O
, use The globalHandlers should call OpenBrowse when CMD+O is pressed
There are a few things about this pull request that gives me pause. I strongly believe this PR should not be accepted in its current state for the following reasons:
My suggestion is to revert the changes to how a bot is opened and implement the shortcuts as described in #560. |
Ah, I didn't notice that the Switch Bots message shows up when a bot's tab is already opened, I can look into removing that message in that scenario. When I use the Endpoint to open a bot conversation, I also lose all conversation history. You alluded to this not being the case in some scenarios. Can you explain this a bit more?
This implementation is weak, simply put. We should improve it. |
Additionally, we should re-evaluate the accepted keybindings for Windows. I'd like to introduce the following that we can reference https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf The intention of these few bindings in this change was considered really low-hanging and not meant to be comprehensive. |
I've updated the diff to include a candidate change to the |
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.
Looks good to me! Had one minor nitpick about formatting.
👍
const closeTabSpy = jest.fn(); | ||
|
||
mount( | ||
<TabBar tabOrder={ [] } documents={ {} } activeDocumentId={ '1234' } closeTab={closeTabSpy}/> |
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.
padding between curly braces:
closeTab={ closeTabSpy }
const result = await this.confirmSwitchBot(); | ||
|
||
if (result) { | ||
store.dispatch(EditorActions.closeNonGlobalTabs()); |
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.
On second glance, I noticed that this closeNonGlobalTabs()
is never being called in the updated version of switchBots()
.
This means that if you previously had a livechat tab open with BotFile1
, and were now switching to BotFile2
, the livechat tab corresponding to BotFile1
would not be closed, meaning that we would have a hanging livechat with a bot file that is not currently active. This doesn't really fit within the Emulator's concept of having one "active" bot file.
e5aed83
to
720c81d
Compare
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.
Looks good now!
Looks like this PR causes a small defect. Unless this is WOD.... Repro
Notice 2 Chat windows are now open Expected behaviorThe existing chat window should become focused and a second window should not appear. notes
|
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.
Looks like there still could be an issue here.
@justinwilaby I saw https://github.com/Microsoft/BotFramework-Emulator/blob/85b220825625068b79245f7df2a6ed811ba7be10/packages/app/client/src/ui/helpers/activeBotHelper.ts#L270-L280 and opted to go with selecting the first endpoint in the list of services as it seemed to be a bit of a convention. I actually like the idea of opening multiple tabs. To me, it's still VSCode-like and relatively intuitive (though redundant in many cases). The point of the change was not to do the ultimate and best experience possible, to be honest. It's improving a considerably poor existing experience. I'm happy to revisit down the road with some proper scope and prioritization, but something needs to land in the interim. |
I can certainly relate to that! |
bd05f7f
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.
(CMD/CTRL) + W now closes the active tab if there is one, currently the binding closes the application entirely.
(CMD/CTRL) + O now prompts the user to select a .bot file to open. currently there is no behavior with this binding.
(CMD/CTRL) + N now opens the new bot configuration modal. currently there is no behavior with this binding.
Bugfixes/Improvements:
When a conversation tab is closed and opened again via an open dialog, the user receives an error about the bot already being open. This is nonsensical. To achieve this behavior successfully it requires a click on the correct Endpoint item to re-open the conversation tab. This change makes it so that the tab is automatically re-opened without the error when the user opens an already open bot with an open dialog.