Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[9.0] [SecuritySolution] Make last conversation local storage keys space aware (#214794) #216214

Open
wants to merge 9 commits into
base: 9.0
Choose a base branch
from

Conversation

angorayc
Copy link
Contributor

Backport

This will backport the following commits from main to 9.0:

angorayc and others added 2 commits March 27, 2025 11:56
…are (elastic#214794)

Issue and steps to reproduce:
elastic#214114

https://github.com/user-attachments/assets/881fb082-a879-4816-b251-da3f2af77661

The best approach to fix this is to make local storage keys space aware.
In this use case, the current key is
`elasticAssistantDefault.lastSelectedConversation`.

Ideally it should be e.g.:
`elasticAssistantDefault.lastSelectedConversation.{spaceId}`

To retrieve spaceId properly, we have to make sure spaceId has been
available when reading the local storage. In other words, the spaceId
cannot be null, undefined, or a fallback value when accessing it.

To achieve that, we have to only render the assistant overlay after
spaceId is available and remove existing spaceId from the
AssistantContext. The reason I removed spaceId from AssistantContext is
because it is at the top of the rendering tree and can block the entire
app if waiting for the spaceId becomes available there.

`useAssistantSpaceId` comes from `SpaceIdContext` which should be render
only when spaceId is available, should be safe to access the exact
spaceId inside Assistant overly.

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 169abec)
@angorayc angorayc marked this pull request as ready for review March 27, 2025 17:27
@angorayc angorayc requested a review from kibanamachine as a code owner March 27, 2025 17:27
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
automaticImport 732 735 +3
securitySolution 6935 6938 +3
total +6

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/elastic-assistant 144 150 +6

Async chunks

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

id before after diff
securitySolution 8.8MB 8.8MB +1.3KB
Unknown metric groups

API count

id before after diff
@kbn/elastic-assistant 172 178 +6

History

@angorayc angorayc requested a review from stephmilovic March 29, 2025 18:51
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants