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

[Security solution] Attack Discovery "View in AI Assistant" button fix #192416

Merged
merged 4 commits into from
Sep 12, 2024

Conversation

stephmilovic
Copy link
Contributor

@stephmilovic stephmilovic commented Sep 9, 2024

Summary

In #190151 I inadvertently broke the Attack Discovery "View in AI Assistant" button. In the past, clicking this button would open a conversation titled whatever the discovery was titled. Now in main, clicking this button will add the context to welcome convo.

I had tried to keep calls to createConversation in useCurrentConversation only. I eliminated the need for it elsewhere in cases of default conversations. However, for new custom conversations created via useAssistantOverlay we still need the createConversation. I tried to approach it from useCurrentConversation, however there was no way for me to determine if an undefined conversation title is coming from something like the "View In AI Assistant" button or from the lastConversationId in local storage (valid case where a convo gets deleted, and we do not want to re-create it because of an undefined conversation title). Therefore, I decided to bring createConversation back to useAssistantOverlay. To prevent from calling this when we do not intend, I added a condition shouldCreateConversation that explicitly tells the showOverlay call to create a new conversation. So far the only place where shouldCreateConversation = true is coming from useViewInAiAssistant (this already had the second boolean passed to showOverlay, I think a stale property)

Additional consideration

Well... what if a month from now I have a discovery named the same thing as another one I've already opened a conversation for? The old conversation will load with the new context. Sounds confusing. To prevent this, I added the last 5 digits of the UUID of the attack discovery id to the title.

To test

  1. Have connectors installed and attack discoveries generated
  2. Click Attack Discovery "View in AI Assistant" button
  3. Observe a new conversation created, named after your attack discovery.

@stephmilovic stephmilovic added release_note:fix Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Security Generative AI Security Generative AI v8.16.0 v8.15.2 labels Sep 9, 2024
@stephmilovic stephmilovic requested a review from a team as a code owner September 9, 2024 22:31
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

Comment on lines +156 to +158
} catch (e) {
/* empty */
}
Copy link
Member

Choose a reason for hiding this comment

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

Was curious about the error behavior here so tested a bit and all looks good. 👍 If thrown, createConversation will throw up a toast, and the assistant flyout will open to the lastConversationId with the AttackDiscovery context available.

Copy link
Member

@spong spong left a comment

Choose a reason for hiding this comment

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

Checked out, tested locally, and code reviewed -- LGTM! 👍

Appreciate the additional tests and thorough description around the ways this could've been addressed and your logic in providing the fix. Thanks @stephmilovic! 🎉

@stephmilovic
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
securitySolution 20.3MB 20.3MB +33.9KB

History

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

@stephmilovic stephmilovic merged commit ea6bb9e into elastic:main Sep 12, 2024
39 checks passed
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 12, 2024
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.15

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Sep 12, 2024
…t" button fix (#192416) (#192709)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[Security solution] Attack Discovery "View in AI Assistant"
button fix (#192416)](#192416)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Steph
Milovic","email":"stephanie.milovic@elastic.co"},"sourceCommit":{"committedDate":"2024-09-12T14:35:44Z","message":"[Security
solution] Attack Discovery \"View in AI Assistant\" button fix
(#192416)","sha":"ea6bb9e0b76088cf08d2786e653d73bee5152dd3","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:
SecuritySolution","Team:Security Generative
AI","v8.16.0","v8.15.2"],"title":"[Security solution] Attack Discovery
\"View in AI Assistant\" button
fix","number":192416,"url":"https://github.com/elastic/kibana/pull/192416","mergeCommit":{"message":"[Security
solution] Attack Discovery \"View in AI Assistant\" button fix
(#192416)","sha":"ea6bb9e0b76088cf08d2786e653d73bee5152dd3"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192416","number":192416,"mergeCommit":{"message":"[Security
solution] Attack Discovery \"View in AI Assistant\" button fix
(#192416)","sha":"ea6bb9e0b76088cf08d2786e653d73bee5152dd3"}},{"branch":"8.15","label":"v8.15.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Steph Milovic <stephanie.milovic@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:fix Team:Security Generative AI Security Generative AI Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.15.2 v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants