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

Add some additional keybindings, improve re-opening an already open bot #1203

Merged
merged 8 commits into from
Jan 8, 2019

Conversation

cwhitten
Copy link
Member

@cwhitten cwhitten commented Dec 29, 2018

(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.

@coveralls
Copy link

coveralls commented Dec 29, 2018

Pull Request Test Coverage Report for Build 1715

  • 14 of 19 (73.68%) changed or added relevant lines in 3 files are covered.
  • 568 unchanged lines in 26 files lost coverage.
  • Overall coverage decreased (-2.3%) to 56.782%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/app/client/src/ui/shell/mdi/tabBar/tabBar.tsx 6 7 85.71%
packages/app/client/src/ui/helpers/activeBotHelper.ts 0 4 0.0%
Files with Coverage Reduction New Missed Lines %
packages/app/client/src/data/action/presentationActions.ts 1 50.0%
testSetup.js 1 66.67%
packages/app/main/src/settingsData/reducers/frameworkReducer.ts 1 66.67%
packages/sdk/shared/built/ipc/channel.js 1 85.71%
packages/app/main/src/settingsData/actions/frameworkActions.ts 1 50.0%
packages/app/client/src/ipc.ts 1 41.67%
packages/sdk/shared/built/utils/bot.js 1 94.12%
packages/app/client/src/data/action/endpointServiceActions.ts 1 71.43%
packages/emulator/core/lib/types/log/util.js 2 46.67%
packages/app/client/src/data/reducer/resourcesReducer.ts 2 73.33%
Totals Coverage Status
Change from base Build 1703: -2.3%
Covered Lines: 3570
Relevant Lines: 5603

💛 - Coveralls

@@ -82,6 +82,14 @@ export class TabBar extends React.Component<TabBarProps, TabBarState> {
};
}

public componentDidMount() {
window.addEventListener('keydown', this.keyboardListener);
Copy link
Contributor

@justinwilaby justinwilaby Dec 30, 2018

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.

Copy link
Member Author

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;
Copy link
Contributor

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

Copy link
Member Author

@cwhitten cwhitten Dec 30, 2018

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;
Copy link
Contributor

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', () => {
Copy link
Contributor

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

@justinwilaby
Copy link
Contributor

justinwilaby commented Dec 31, 2018

@cwhitten -

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:

  1. It changes the functionality of how a bot it opened - this PR eliminates the message to the user that a bot is already open and to click on an endpoint to open a new conversation. Instead, the user is presented with a dialog to switch bots (even though the bot they are switching to is already open). This has the side effect of irreversibly wiping out all previous conversations from that bot. The current implementation is intentional and was put in place to avoid this. This PR removes that intentional design and introduces a defect.

  2. The keyboard shortcuts in this PR deviate from, or provides an incomplete solution to the accepted and approved design listed in Menu items need shortcut keys #560.

My suggestion is to revert the changes to how a bot is opened and implement the shortcuts as described in #560.

@cwhitten
Copy link
Member Author

It changes the functionality of how a bot it opened - this PR eliminates the message to the user that a bot is already open and to click on an endpoint to open a new conversation. Instead, the user is presented with a dialog to switch bots (even though the bot they are switching to is already open). This has the side effect of irreversibly wiping out all previous conversations from that bot. The current implementation is intentional and was put in place to avoid this. This PR removes that intentional design and introduces a defect.

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 has the side effect of irreversibly wiping out all previous conversations from that bot. The current implementation is intentional and was put in place to avoid this.

This implementation is weak, simply put. We should improve it.

@cwhitten
Copy link
Member Author

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.

@cwhitten
Copy link
Member Author

cwhitten commented Jan 2, 2019

I've updated the diff to include a candidate change to the confirmAndSwitchBots implementation in activeBotHelper.ts, essentially removing the confirmation step and just moving on with the "switch" portion of the implementation. There are two call sites for this function in the live code, both in botCommands.ts. Can someone explain to me why we can't do something like this this?

Copy link
Contributor

@tonyanziano tonyanziano left a 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}/>
Copy link
Contributor

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());
Copy link
Contributor

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.

tonyanziano
tonyanziano previously approved these changes Jan 8, 2019
Copy link
Contributor

@tonyanziano tonyanziano left a comment

Choose a reason for hiding this comment

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

Looks good now!

@justinwilaby
Copy link
Contributor

justinwilaby commented Jan 8, 2019

Looks like this PR causes a small defect. Unless this is WOD....

Repro

  1. Open Bot 1 and start a conversation
  2. Open Bot 1 again

Notice 2 Chat windows are now open

Expected behavior

The existing chat window should become focused and a second window should not appear.

notes

  1. If I have a bot with multiple endpoints open and am working with an endpoint at index=1, then open the same bot, I would not expect another chat window to open with endpoint at index=0 selected. It seems more appropriate that if I already have a chat window open and try to open the same bot again, the existing chat window will move into focus.

Copy link
Contributor

@justinwilaby justinwilaby left a 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.

@cwhitten
Copy link
Member Author

cwhitten commented Jan 8, 2019

@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.

@justinwilaby
Copy link
Contributor

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!

justinwilaby
justinwilaby previously approved these changes Jan 8, 2019
@cwhitten cwhitten dismissed stale reviews from justinwilaby and tonyanziano via bd05f7f January 8, 2019 18:06
Copy link
Contributor

@justinwilaby justinwilaby left a comment

Choose a reason for hiding this comment

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

:shipit:

@cwhitten cwhitten merged commit f74cb46 into master Jan 8, 2019
@cwhitten cwhitten deleted the keyboard-bindings branch January 8, 2019 18:30
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.

None yet

4 participants