Skip to content

[9.4] [Discover] Reset layout on profile change (#265174)#266238

Merged
davismcphee merged 2 commits into
elastic:9.4from
davismcphee:backport/9.4/pr-265174
Apr 29, 2026
Merged

[9.4] [Discover] Reset layout on profile change (#265174)#266238
davismcphee merged 2 commits into
elastic:9.4from
davismcphee:backport/9.4/pr-265174

Conversation

@davismcphee
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.4:

Questions ?

Please refer to the Backport tool documentation

## Summary

This PR fixes the layout carry-over that happens when Discover switches
between profiles. Currently when resolving the metrics profile first and
then switching to logs, the collapsed table state from metrics leaks
into logs even though logs doesn't define that as a profile default:
<img
src="https://github.com/user-attachments/assets/80a7280c-f2df-4580-83fe-c9c7fd0d769f"
/>

Now Discover treats initial profile resolution differently from later
profile switches. On profile change, Discover restores saved state for
that profile when it exists, otherwise it resets layout state back to
the shared local storage values before applying profile defaults. This
keeps metrics defaults intact while preventing logs from inheriting the
table layout when switching from metrics.

The PR also moves layout local storage helpers to `@kbn/discover-utils`,
simplifies how panel toggle actions are wired into unified histogram,
and adds test coverage for the new layout reset behaviour.

### Testing notes

Setup:
- Ingest some logs and metrics, e.g. with `node scripts/synthtrace
logs_and_metrics.ts`.
- Create a new o11y space in Kibana.
- Use a clean local storage (e.g. private window).

The table should shown in this case (same as before):
1. Start with `FROM logs-*` (by refreshing the page once you run that
query)
2. `TS metrics-*`
3. `FROM logs-*`

The table should now also be shown in this case (new to this PR):
1. Start with `TS metrics-*` (by refreshing the page once you run that
query)
2. `FROM logs-*`

Resolves elastic#266092.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [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
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 09769b0)

# Conflicts:
#	src/platform/plugins/shared/discover/public/components/panels_toggle/panels_toggle.test.tsx
#	x-pack/platform/plugins/private/translations/translations/de-DE.json
#	x-pack/platform/plugins/private/translations/translations/fr-FR.json
#	x-pack/platform/plugins/private/translations/translations/ja-JP.json
#	x-pack/platform/plugins/private/translations/translations/zh-CN.json
@davismcphee davismcphee added the backport This PR is a backport of another PR label Apr 28, 2026
@davismcphee davismcphee enabled auto-merge (squash) April 28, 2026 22:32
@davismcphee davismcphee self-assigned this Apr 28, 2026
@davismcphee davismcphee added the Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// label Apr 28, 2026
@infra-vault-gh-plugin-prod
Copy link
Copy Markdown

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@davismcphee davismcphee requested a review from a team April 28, 2026 22:33
Copy link
Copy Markdown
Contributor

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

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

Tested in 9.4 and things work as expected. LGTM!

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
alertingVTwo 970 971 +1
apm 2123 2124 +1
cloudSecurityPosture 768 769 +1
datasetQuality 1073 1072 -1
dataVisualizer 877 878 +1
discover 2013 2012 -1
esql 981 982 +1
esqlDataGrid 437 438 +1
eventAnnotationListing 703 704 +1
fleet 1613 1614 +1
infra 1866 1867 +1
lens 1739 1740 +1
logsShared 450 451 +1
ml 4224 4225 +1
observability 1741 1742 +1
observabilityLogsExplorer 254 255 +1
osquery 757 758 +1
queryActivity 257 258 +1
searchPlayground 567 568 +1
securitySolution 9353 9354 +1
slo 1320 1321 +1
streamsApp 1802 1803 +1
triggersActionsUi 1398 1399 +1
unifiedDocViewer 913 914 +1
workflowsManagement 1606 1607 +1
total +21

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/discover-utils 378 402 +24
@kbn/unified-histogram 88 73 -15
total +9

Async chunks

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

id before after diff
datasetQuality 523.2KB 523.2KB +2.0B
discover 1.9MB 1.9MB -450.0B
total -448.0B
Unknown metric groups

API count

id before after diff
@kbn/discover-utils 449 481 +32
@kbn/unified-histogram 128 107 -21
total +11

History

cc @davismcphee

@davismcphee davismcphee merged commit bef8ae2 into elastic:9.4 Apr 29, 2026
21 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 Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t//

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants