Skip to content

[8.x] [SecuritySolution] Make last conversation local storage keys space aware (#214794)#216085

Merged
kibanamachine merged 2 commits intoelastic:8.xfrom
kibanamachine:backport/8.x/pr-214794
Mar 27, 2025
Merged

[8.x] [SecuritySolution] Make last conversation local storage keys space aware (#214794)#216085
kibanamachine merged 2 commits intoelastic:8.xfrom
kibanamachine:backport/8.x/pr-214794

Conversation

@kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

…are (elastic#214794)

## Summary

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.

### Checklist

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)
@kibanamachine kibanamachine force-pushed the backport/8.x/pr-214794 branch from 6fb7244 to 54f296e Compare March 26, 2025 16:42
@elasticmachine
Copy link
Contributor

elasticmachine commented Mar 26, 2025

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Scout: [ observability / observability_onboarding ] plugin / stateful - Observability Onboarding - Custom logs configuration - should navigate to the onboarding home page when the back button clicked

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
integrationAssistant 490 493 +3
securitySolution 7136 7139 +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 135 141 +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 9.1MB 9.1MB +1.6KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/elastic-assistant 9 11 +2
Unknown metric groups

API count

id before after diff
@kbn/elastic-assistant 164 170 +6

History

cc @angorayc

@kibanamachine kibanamachine merged commit a1c1173 into elastic:8.x Mar 27, 2025
8 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.

3 participants