Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion web/packages/teleport/src/Assist/contexts/messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,22 @@ export const remoteCommandToMessage = async (
errorMsg = 'no users found';
}

// If the login has been selected, use it.
let avLogin = execCmd.selectedLogin;
if (!avLogin) {
// If the login has not been selected, use the first one.
avLogin = availableLogins ? availableLogins[0] : '';
} else {
// If the login has been selected, check if it is available.
// Updated query could have changed the available logins.
if (!availableLogins.includes(avLogin)) {
avLogin = availableLogins ? availableLogins[0] : '';
}
Comment on lines +142 to +147
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

elseif?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TS complains as it expects else block (potentially not all cases are covered with if and else if).

}

return {
...execCmd,
selectedLogin: availableLogins ? availableLogins[0] : '',
selectedLogin: avLogin,
availableLogins: availableLogins,
errorMsg: errorMsg,
};
Expand Down