Skip to content

Centralize phase colors and descriptions#266680

Merged
SoniaSanzV merged 7 commits into
elastic:mainfrom
SoniaSanzV:centralize_phases_colors_and_descriptions
May 5, 2026
Merged

Centralize phase colors and descriptions#266680
SoniaSanzV merged 7 commits into
elastic:mainfrom
SoniaSanzV:centralize_phases_colors_and_descriptions

Conversation

@SoniaSanzV
Copy link
Copy Markdown
Contributor

Closes #266417

Summary

  • ILM phase labels, titles, short/long descriptions, and theme-aware colors were independently defined in both the index_lifecycle_management and streams_app plugins, causing duplicated i18n tokens and a behavioral divergence in the delete phase color.
  • Introduces a new shared package @kbn/data-lifecycle-phases (owner: @elastic/kibana-management) that exports PHASE_ORDER, PHASE_NAMES, PHASE_TITLES, PHASE_SHORT_DESCRIPTIONS, PHASE_DESCRIPTIONS, and usePhaseColors. Both plugins now import from it.
  • The delete phase color was misaligned: streams_app declared borderBasePlain in use_ilm_phases_color_and_description.tsx but individual components (lifecycle_phase.tsx, downsampling_bar.tsx) were silently overriding it with euiTheme.colors.backgroundBaseSubdued directly — so the declared value was never actually used. The canonical token is now backgroundBaseSubdued, defined once in usePhaseColors and consumed everywhere.
  • use_phase_colors.ts in ILM (a trivial re-export shim) is removed; consumers import usePhaseColors directly from @kbn/data-lifecycle-phases.
  • ILM_PHASE_ORDER and PHASE_LABELS aliases in x-pack/platform/plugins/shared/streams_app/public/components/stream_management/data_management/stream_detail_lifecycle/downsampling/edit_ilm_phases_flyout/constants.ts are removed; call sites now use the canonical PHASE_ORDER and PHASE_NAMES directly from @kbn/data-lifecycle-phases.

How to test

  1. Navigate to Stack Management → Index Lifecycle Policies. Open any policy with multiple phases.
    • Verify the timeline color bars (hot/warm/cold/frozen/delete) render correctly.
    • Verify phase icons in the policy editor match their phase colors.
  2. Open a policy flyout from the policy list and confirm phase indicator dots show the correct colors.
  3. Navigate to the Streams app → a stream with an ILM lifecycle.
    • Verify the lifecycle summary bar shows the correct phase colors including the delete phase (subdued background).
    • Open the Edit ILM phases flyout and confirm phase descriptions and colors are shown correctly.
    • Verify the DSL lifecycle summary and the Failure Store summary both render the hot/delete colors correctly.
  4. Confirm no visible regression in the downsampling bar when a delete segment is present.

@SoniaSanzV SoniaSanzV self-assigned this Apr 30, 2026
@SoniaSanzV SoniaSanzV requested a review from a team as a code owner April 30, 2026 14:26
@SoniaSanzV SoniaSanzV requested review from a team as code owners April 30, 2026 14:26
@SoniaSanzV SoniaSanzV added Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t// Feature:Streams This is the label for the Streams Project release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Apr 30, 2026
@SoniaSanzV SoniaSanzV enabled auto-merge (squash) May 4, 2026 07:02
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
indexLifecycleManagement 195 196 +1
streamsApp 1845 1847 +2
total +3

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/data-lifecycle-phases - 1 +1

Async chunks

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

id before after diff
indexLifecycleManagement 153.5KB 151.3KB -2.2KB
streamsApp 2.0MB 2.0MB +1.2KB
total -1.1KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
indexLifecycleManagement 31.2KB 33.8KB +2.7KB
Unknown metric groups

API count

id before after diff
@kbn/data-lifecycle-phases - 28 +28

History

cc @SoniaSanzV

Copy link
Copy Markdown
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Onboarding changes LGTM< just adding a new type dependency

Copy link
Copy Markdown
Contributor

@damian-polewski damian-polewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this improvement! Code looks good and everything works well, I added one small nit but overall LGTM!

}
),
},
return {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking: are we removing useMemo here intentionally? We still might want to keep the values cached.

@SoniaSanzV SoniaSanzV merged commit 671047a into elastic:main May 5, 2026
29 checks passed
@SoniaSanzV SoniaSanzV deleted the centralize_phases_colors_and_descriptions branch May 5, 2026 07:45
mbondyra added a commit to mbondyra/kibana that referenced this pull request May 5, 2026
…ilder_new_vis_attachment

* commit '6fd683609eb6dee81f242f8ff6951edbe3bfd66c': (226 commits)
  Remove Model Author group-by option from external inference endpoints (elastic#264761)
  [Streams][Streamlang] Align ES|QL condition transpiler with Painless on null propagation (elastic#264751)
  chore(axios,workflows-eng): remove axios from workflows connector utils (elastic#267512)
  [failed-test-reporter] avoid opening issues for scout env failures (elastic#267649)
  [kbn-api-contracts] Detect request-body additionalProperties:false tightening (elastic#267546)
  [main] Sync bundled packages with Package Storage (elastic#267644)
  Centralize phase colors and descriptions (elastic#266680)
  [Unified Waterfall] Add "Scroll to origin" button  (elastic#266594)
  [APM] Add alert and SLO badges to the service map embeddable (elastic#266360)
  [CI] Speed up telemetry_check by pre-filtering to collector files (elastic#265978)
  [Discover] Address flaky large CSV test (elastic#266642)
  avoid passing unrelated props within integration card icon component conditional render (elastic#266569)
  [Cases][Templates] Extend cases search by template field label (elastic#266414)
  [Background search] Migrate custom SplitButton to EuiSplitButton (elastic#267447)
  [i18n] Report translation coverage during integrate (elastic#264124)
  [api-docs] 2026-05-05 Daily api_docs build (elastic#267639)
  [Scout] Update test config manifests (elastic#267636)
  [content list] Add saved object provider services (elastic#266428)
  [Fleet] Otel UI add health and implement it in OTelComponentDetail (elastic#267292)
  Update dependency msw to v2.13.4 (main) (elastic#266770)
  ...
SoniaSanzV added a commit that referenced this pull request May 8, 2026
## Summary

On the Streams retention management page
(`/app/streams/{name}/management/retention`), the `GET
/internal/streams/{name}/lifecycle/_explain` endpoint was being called
in an infinite loop. Every render triggered a new fetch, which caused a
state update, which triggered another render, and so on.

The root cause was referential instability in `usePhaseColors`
(`kbn-data-lifecycle-phases`): it returned a plain object literal on
every render with no memoization. This made `ilmPhases` (built from
`phaseColors` in `useIlmPhasesColorAndDescription`) also a new reference
every render. Since `ilmPhases` was in the dependency array of
`useIngestionRatePerTier`, the fetch — including the `_explain` call —
re-ran on every render. This was caused by
#266680

Two fixes:

- `usePhaseColors` now wraps its return value in `useMemo`, keyed on the
individual EUI theme color tokens. The color map is only recreated on
theme changes (e.g. dark/light mode toggle).
- `useIlmPhasesColorAndDescription` now wraps `ilmPhases` in `useMemo`
keyed on `phaseColors`. Since `phaseColors` is now stable, `ilmPhases`
is also stable, and `useIngestionRatePerTier` no longer re-fires on
every render.

### Test plan

- Navigate to `/app/streams/{name}/management/retention` on a
non-serverless environment with a stream that has an ILM policy.
- Open the browser network tab and filter for `lifecycle/_explain`.
- Verify the endpoint is called once on page load (and again only when
the time range changes), not continuously.
js-jankisalvi pushed a commit to js-jankisalvi/kibana that referenced this pull request May 12, 2026
## Summary

On the Streams retention management page
(`/app/streams/{name}/management/retention`), the `GET
/internal/streams/{name}/lifecycle/_explain` endpoint was being called
in an infinite loop. Every render triggered a new fetch, which caused a
state update, which triggered another render, and so on.

The root cause was referential instability in `usePhaseColors`
(`kbn-data-lifecycle-phases`): it returned a plain object literal on
every render with no memoization. This made `ilmPhases` (built from
`phaseColors` in `useIlmPhasesColorAndDescription`) also a new reference
every render. Since `ilmPhases` was in the dependency array of
`useIngestionRatePerTier`, the fetch — including the `_explain` call —
re-ran on every render. This was caused by
elastic#266680

Two fixes:

- `usePhaseColors` now wraps its return value in `useMemo`, keyed on the
individual EUI theme color tokens. The color map is only recreated on
theme changes (e.g. dark/light mode toggle).
- `useIlmPhasesColorAndDescription` now wraps `ilmPhases` in `useMemo`
keyed on `phaseColors`. Since `phaseColors` is now stable, `ilmPhases`
is also stable, and `useIngestionRatePerTier` no longer re-fires on
every render.

### Test plan

- Navigate to `/app/streams/{name}/management/retention` on a
non-serverless environment with a stream that has an ILM policy.
- Open the browser network tab and filter for `lifecycle/_explain`.
- Verify the endpoint is called once on page load (and again only when
the time range changes), not continuously.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:ILM Feature:Streams This is the label for the Streams Project release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t// v9.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ILM] Centralize ILM phase metadata (name, color, descriptions)

4 participants