Skip to content

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

Merged
angorayc merged 9 commits intoelastic:9.0from
angorayc:backport/9.0/pr-214794
Mar 31, 2025
Merged

[9.0] [SecuritySolution] Make last conversation local storage keys space aware (#214794)#216214
angorayc merged 9 commits intoelastic:9.0from
angorayc:backport/9.0/pr-214794

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 added the backport This PR is a backport of another PR label Mar 27, 2025
@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
@angorayc angorayc merged commit 2276a37 into elastic:9.0 Mar 31, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants