-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Security solution] Attack Discovery "View in AI Assistant" button fix #192416
Conversation
Pinging @elastic/security-solution (Team: SecuritySolution) |
} catch (e) { | ||
/* empty */ | ||
} |
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.
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.
...lic/attack_discovery/attack_discovery_panel/view_in_ai_assistant/use_view_in_ai_assistant.ts
Outdated
Show resolved
Hide resolved
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.
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! 🎉
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
elastic#192416) (cherry picked from commit ea6bb9e)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…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>
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
inuseCurrentConversation
only. I eliminated the need for it elsewhere in cases of default conversations. However, for new custom conversations created viauseAssistantOverlay
we still need thecreateConversation
. I tried to approach it fromuseCurrentConversation
, 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 thelastConversationId
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 bringcreateConversation
back touseAssistantOverlay
. To prevent from calling this when we do not intend, I added a conditionshouldCreateConversation
that explicitly tells theshowOverlay
call to create a new conversation. So far the only place whereshouldCreateConversation = true
is coming fromuseViewInAiAssistant
(this already had the second boolean passed toshowOverlay
, 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