Skip to content

[9.5] [Entity Analytics] Fix entity summary showing stale content when switching to entity with no summary (#285247) - #288448

Merged
CAWilson94 merged 1 commit into
elastic:9.5from
CAWilson94:backport/9.5/pr-285247
Sep 1, 2026
Merged

[9.5] [Entity Analytics] Fix entity summary showing stale content when switching to entity with no summary (#285247)#288448
CAWilson94 merged 1 commit into
elastic:9.5from
CAWilson94:backport/9.5/pr-285247

Conversation

@CAWilson94

Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.5:

Questions ?

Please refer to the Backport tool documentation

…ching to entity with no summary (elastic#285247)

## Summary

Fixes elastic/security-team#18414.

When switching from an entity with a persisted AI summary to one
without, the **Entity summary** section continued to show the previous
entity's content. The flyout header and risk badge updated correctly;
only the summary was stale.

**Root cause:** The stored-summary hydration effect in
`useFetchEntityDetailsHighlights` only ran its body when `storedSummary`
was truthy, so `assistantResult` was never cleared when `storedSummary`
became `null`:

```typescript
// Before
useEffect(() => {
  if (storedSummary && !userTriggeredGeneration.current) {
    setAssistantResult(buildResultFromStoredSummary(storedSummary));
  }
}, [storedSummary]);
```

**Fix:** Add the else branch so `assistantResult` is cleared when
`storedSummary` becomes `null` and the user has not triggered generation
in the current mount cycle:

```typescript
// After
useEffect(() => {
  if (userTriggeredGeneration.current) return;
  setAssistantResult(storedSummary ? buildResultFromStoredSummary(storedSummary) : null);
}, [storedSummary]);
```

This is a client-side state management fix only - no API, schema, or
index changes.

## Demo

https://github.com/user-attachments/assets/32934f34-2a79-41d1-b420-eb5fbc80a95e

## Desk Testing

1. Open entity flyout for a user/host entity that has a persisted AI
summary — confirm summary shows
2. Without closing the flyout, switch to a user/host entity that has
**no** persisted summary — confirm the Entity summary section shows the
Generate state (not the previous entity's summary)
3. Switching between two entities that **both** have summaries should
still work correctly
4. Service entities unaffected

Unit test added: `clears the result when switching to an entity that has
no stored summary`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

(cherry picked from commit 5846418)
@kibanamachine

Copy link
Copy Markdown
Contributor

💚 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 13.6MB 13.6MB +3.0B

@CAWilson94
CAWilson94 merged commit 1c4441c into elastic:9.5 Sep 1, 2026
60 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