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

[Observability AI Assistant] Chat tweaks + keyboard shortcut #176350

Merged
merged 5 commits into from
Feb 8, 2024

Conversation

CoenWarmer
Copy link
Contributor

@CoenWarmer CoenWarmer commented Feb 6, 2024

Summary

Some small tweaks for the Chat Flyout.

  • Adds an expand flyout button so the user can toggle the flyout between 'normal' width and 100% width
  • Adds a 'navigate to conversations app' button in the flyout
  • Adds a keyboard handler for <control> + <;> (semicolon) to open the assistant.

What it looks like

Screen.Recording.2024-02-06.at.23.25.14.mov

@CoenWarmer CoenWarmer requested a review from a team as a code owner February 6, 2024 22:31
@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@CoenWarmer CoenWarmer added the release_note:skip Skip the PR/issue when compiling release notes label Feb 6, 2024
@klacabane
Copy link
Contributor

Triggered this error when opening conversation app from flyout

conversation_open_error.mov

@@ -30,6 +30,20 @@ export function ObservabilityAIAssistantActionMenuItem() {

const initialMessages = useMemo(() => [], []);

useEffect(() => {
const keyboardListener = (event: KeyboardEvent) => {
if (event.ctrlKey && event.code === 'Semicolon') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this documented anywhere for users ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not yet. Perhaps we can add something instead of the friendly Moose image. @boriskirov ?

Copy link
Member

@sorenlouv sorenlouv Feb 7, 2024

Choose a reason for hiding this comment

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

What about a tooltip on the AI Assistant button that describes the shortcut?

image

Similar to what the desktop menus do:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like it! @boriskirov wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, good idea!

<EuiButtonIcon
aria-label={i18n.translate(
'xpack.observabilityAiAssistant.chatHeader.euiButtonIcon.navigateToConversationsLabel',
{ defaultMessage: 'Navigate to conversations' }
Copy link
Contributor

@klacabane klacabane Feb 7, 2024

Choose a reason for hiding this comment

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

It's not obvious to me what this button does since it only has icon, wonder if we should add a tooltip to it ?

Copy link
Member

Choose a reason for hiding this comment

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

I was about to say the same thing. I intuitively understand 3 out of 4 icons but not the "Navigate to conversations" icon.

image

I think it's especially important to make it clear what the "Navigate to conversations" icon does because it performs an actual page navigation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I considered that, was wondering if it wouldn't make the UI too busy. But yeah, can be added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Comment on lines +72 to +83
const handleNavigateToConversations = () => {
if (conversationId) {
router.navigateToConversationsApp('/conversations/{conversationId}', {
path: {
conversationId,
},
query: {},
});
} else {
router.navigateToConversationsApp('/conversations/new', { path: {}, query: {} });
}
};
Copy link
Member

Choose a reason for hiding this comment

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

I'm getting this error when starting a new conversation, then clicking on the conversations icon

Conversation not found

Could not find a conversation with id :conversationId. Make sure the conversation exists and you have access to it.

URL is /observabilityAIAssistant/conversations/%7BconversationId%7D

image

Copy link
Member

Choose a reason for hiding this comment

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

Picking an existing conversation leads, then clicking the icon results in the same error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed with b03cd4d

Comment on lines 53 to 55
navigateToConversationsApp: (path, ...args) => {
navigateToApp('observabilityAIAssistant', { path, ...args });
},
Copy link
Member

Choose a reason for hiding this comment

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

I suggest keeping the router api simple and using push/replace directly.

Suggested change
navigateToConversationsApp: (path, ...args) => {
navigateToApp('observabilityAIAssistant', { path, ...args });
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See earlier comment

Copy link
Member

Choose a reason for hiding this comment

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

In order to do so we have to change push and replace to use navigateToApp:

      push: (...args) => {
        const next = link(...args);
        navigateToApp('observabilityAIAssistant', { path: next, replace: false });
      },
      replace: (path, ...args) => {
        const next = link(path, ...args);
        navigateToApp('observabilityAIAssistant', { path: next, replace: true });
      },

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But then we would also use the navigateToApp method when it is not needed, like when we are in the conversations app.

Copy link
Member

Choose a reason for hiding this comment

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

But then we would also use the navigateToApp method when it is not needed, like when we are in the conversations app.

Is that an actual problem?

Copy link
Member

Choose a reason for hiding this comment

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

We could also have two pairs of push/replace methods. One pair for navigating within the app (current ones) and the other pair for navigating from another app into the AI Assistant app. But I am not sure if it's actually necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if it's an actual problem. FWIW, I always found it slightly odd that Kibana has a separate navigate and navigateToApp method. Unsure as to why that is, do you know?

Copy link
Member

Choose a reason for hiding this comment

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

No, I don't either

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tried using replace from the existing router API:

      replace: (path, ...args) => {
        const next = link(path, ...args);
        history.replace(next);
      },
      link: (path, ...args) => {
        return http.basePath.prepend('/app/observabilityAIAssistant' + link(path, ...args));
      },

it really does not navigate the user to a different app, even though it uses link with the http.basePath.prepend etc.

It seems we need a dedicated method when navigating from another app into the conversations app.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented b03cd4d

Copy link
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

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

really nice improvements!

Comment on lines +56 to +77
const sanitized = routeParam.replace('{', '').replace('}', '');

const pathKey = args[0]?.path;

if (typeof pathKey !== 'object') {
return;
}

if (Object.keys(pathKey).length === 0) {
navigateToApp('observabilityAIAssistant', {
path: route,
});
return;
}

if (Object.keys(pathKey).length === 1) {
navigateToApp('observabilityAIAssistant', {
// @ts-expect-error
path: `${route}/${pathKey[sanitized]}`,
});
return;
}
Copy link
Contributor Author

@CoenWarmer CoenWarmer Feb 7, 2024

Choose a reason for hiding this comment

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

I really dislike this code, but the combination of this API with the Typescript typing is throwing me for a loop. This works but is not ideal. Better suggestions welcome.

Copy link
Member

Choose a reason for hiding this comment

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

Did you try this?

      push: (...args) => {
        const next = link(...args);
        navigateToApp('observabilityAIAssistant', { path: next, replace: false });
      },

@CoenWarmer
Copy link
Contributor Author

Triggered this error when opening conversation app from flyout

conversation_open_error.mov

Addressed with b03cd4d

@CoenWarmer
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
observabilityAIAssistant 165.4KB 168.6KB +3.2KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@klacabane klacabane left a comment

Choose a reason for hiding this comment

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

Nice change!

@CoenWarmer CoenWarmer merged commit 52f35fc into elastic:main Feb 8, 2024
16 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Feb 8, 2024
CoenWarmer added a commit to CoenWarmer/kibana that referenced this pull request Feb 15, 2024
fkanout pushed a commit to fkanout/kibana that referenced this pull request Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants