Skip to content

[8.19] [Embeddables] Serialized State Only (#215947)#220308

Merged
nreese merged 7 commits intoelastic:8.19from
nreese:backport/8.19/pr-215947
May 7, 2025
Merged

[8.19] [Embeddables] Serialized State Only (#215947)#220308
nreese merged 7 commits intoelastic:8.19from
nreese:backport/8.19/pr-215947

Conversation

@nreese
Copy link
Contributor

@nreese nreese commented May 6, 2025

Backport

This will backport the following commits from main to 8.19:

Questions ?

Please refer to the Backport tool documentation

Closes elastic#205531
Closes elastic#219877.
Closes elastic#213153
Closes elastic#150920
Closes elastic#203130

### Overview
The embeddable framework has two types of state: `SerializedState` and
`RuntimeState`.

`SerializedState` is the form of the state when saved into a Dashboard
saved object. I.e. the References are extracted, and state saved
externally (by reference) is removed. In contrast `RuntimeState` is an
exact snapshot of the state used by the embeddable to render.

<b>Exposing SerializedState and RuntimeState was a mistake</b> that
caused numerous regressions and architectural complexities.

This PR simplifies the embeddable framework by only exposing
`SerializedState`. `RuntimeState` stays localized to the embeddable
implementation and is never leaked to the embeddable framework.

### Whats changed
* `ReactEmbeddableFactory<SerializedState, RuntimeState, Api>` =>
`EmbeddableFactory<SerializedState, Api>`
* `deserializeState` removed from embeddable factory. Instead,
`SerializedState` is passed directly into `buildEmbeddable`.
* `buildEmbeddable` parameter `buildApi` replaced with `finalizeApi`.
`buildApi({ api, comparators })` => `finalizeApi(api)`.
* The embeddable framework previously used its knowledge of
`RuntimeState` to setup and monitor unsaved changes. Now, unsaved
changes setup is pushed down to the embeddable implementation since the
embeddable framework no longer has knowledge of embeddable RuntimeState.

### Reviewer instructions
<b>Please prioritize reviews.</b> This is a large effort from our team
and is blocking many other initiatives. Getting this merged is a top
priority.

This is a large change that would best be reviewed by manually testing
the changes
* adding/editing your embeddable types
* Ensuring dashboard shows unsaved changes as expected
* Ensuring dashboard resets unsaved changes as expected
* Ensuring dashboard does not show unsaved changes after save and reset
* Returning to a dashboard with unsaved changes renders embeddables with
those unsaved changes

---------

Co-authored-by: Hannah Mudge <Heenawter@users.noreply.github.com>
Co-authored-by: Nathan Reese <reese.nathan@elastic.co>
Co-authored-by: Nick Peihl <nick.peihl@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Catherine Liu <catherine.liu@elastic.co>
Co-authored-by: Ola Pawlus <98127445+olapawlus@users.noreply.github.com>
(cherry picked from commit 3e882d8)

# Conflicts:
#	packages/kbn-optimizer/limits.yml
#	src/platform/plugins/shared/dashboard/public/dashboard_app/top_nav/share/show_share_modal.tsx
#	src/platform/plugins/shared/discover/public/embeddable/get_search_embeddable_factory.tsx
#	src/platform/plugins/shared/unified_doc_viewer/public/components/observability/traces/components/trace.tsx
#	x-pack/platform/plugins/shared/aiops/public/embeddables/change_point_chart/embeddable_change_point_chart_factory.tsx
#	x-pack/platform/plugins/shared/aiops/public/embeddables/log_rate_analysis/embeddable_log_rate_analysis_factory.tsx
#	x-pack/platform/plugins/shared/aiops/public/embeddables/pattern_analysis/embeddable_pattern_analysis_factory.tsx
#	x-pack/platform/plugins/shared/lens/public/plugin.ts
#	x-pack/platform/plugins/shared/ml/public/plugin.ts
#	x-pack/solutions/observability/plugins/apm/public/embeddable/trace_waterfall/react_embeddable_factory.tsx
#	x-pack/solutions/observability/plugins/apm/tsconfig.json
#	x-pack/solutions/observability/plugins/infra/public/components/log_stream/log_stream_react_embeddable.tsx
@nreese nreese requested a review from kibanamachine as a code owner May 6, 2025 21:55
@nreese nreese added the backport This PR is a backport of another PR label May 6, 2025
@nreese nreese enabled auto-merge (squash) May 6, 2025 21:55
@botelastic botelastic bot added Feature:Embedding Embedding content via iFrame Team:obs-ux-infra_services - DEPRECATED DEPRECATED - Use Team:obs-presentation. Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. labels May 6, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@nreese nreese merged commit f48439e into elastic:8.19 May 7, 2025
8 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
aiops 586 587 +1
apm 1898 1909 +11
canvas 1323 1361 +38
controls 371 372 +1
dashboard 677 678 +1
discover 1242 1252 +10
embeddableAlertsTable 268 279 +11
imageEmbeddable 138 137 -1
maps 1275 1285 +10
total +82

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/presentation-containers 68 73 +5
@kbn/presentation-publishing 204 213 +9
controls 138 140 +2
embeddable 131 125 -6
total +10

Async chunks

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

id before after diff
aiops 444.6KB 450.6KB +6.0KB
apm 2.5MB 2.6MB +4.5KB
canvas 1.1MB 1.1MB +1.5KB
cases 1.3MB 1.3MB +13.0B
controls 482.1KB 484.3KB +2.2KB
dashboard 617.5KB 615.7KB -1.8KB
dataVisualizer 617.1KB 618.7KB +1.7KB
discover 992.6KB 994.4KB +1.8KB
embeddable 1.6KB 1.6KB -1.0B
embeddableAlertsTable 796.5KB 798.1KB +1.6KB
imageEmbeddable 60.6KB 61.1KB +529.0B
infra 1.6MB 1.6MB +316.0B
investigateApp 200.8KB 200.8KB +36.0B
lens 1.4MB 1.4MB +1.5KB
links 55.5KB 57.9KB +2.4KB
logsShared 219.4KB 219.4KB -5.0B
maps 3.1MB 3.1MB +1.8KB
ml 5.4MB 5.4MB +16.6KB
presentationPanel 36.8KB 36.8KB +4.0B
securitySolution 9.2MB 9.2MB +23.0B
slo 926.4KB 929.1KB +2.7KB
synthetics 972.4KB 974.5KB +2.1KB
triggersActionsUi 1.4MB 1.4MB +23.0B
visTypeVega 2.1MB 2.1MB -1.0B
visualizations 346.1KB 345.2KB -964.0B
total +44.3KB

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
dashboard 10 11 +1
embeddable 2 1 -1
total -0

Page load bundle

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

id before after diff
aiops 17.4KB 17.4KB +49.0B
controls 10.9KB 11.4KB +533.0B
dashboard 17.4KB 17.6KB +137.0B
discover 21.9KB 21.9KB +29.0B
embeddable 20.5KB 18.8KB -1.7KB
embeddableEnhanced 7.2KB 7.3KB +38.0B
imageEmbeddable 6.2KB 6.2KB +11.0B
infra 54.3KB 55.6KB +1.3KB
inputControlVis 8.6KB 8.6KB +2.0B
lens 58.4KB 58.8KB +377.0B
links 7.7KB 7.7KB +40.0B
maps 40.1KB 40.1KB +14.0B
ml 80.8KB 81.5KB +679.0B
slo 42.6KB 42.6KB +87.0B
visTypeVega 33.9KB 33.9KB -1.0B
visualizations 35.2KB 35.1KB -97.0B
total +1.5KB
Unknown metric groups

API count

id before after diff
@kbn/presentation-containers 79 84 +5
@kbn/presentation-publishing 240 253 +13
controls 142 144 +2
dashboard 90 89 -1
embeddable 158 149 -9
total +10

async chunk count

id before after diff
ml 111 115 +4
visualizations 20 19 -1
total +3

ESLint disabled line counts

id before after diff
discover 23 24 +1

References to deprecated APIs

id before after diff
@kbn/presentation-containers 2 0 -2
controls 18 16 -2
dashboard 13 11 -2
embeddable 12 5 -7
total -13

Total ESLint disabled count

id before after diff
discover 25 26 +1

History

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 Feature:Embedding Embedding content via iFrame Team:actionable-obs Formerly "obs-ux-management", responsible for SLO, o11y alerting, significant events, & synthetics. Team:obs-ux-infra_services - DEPRECATED DEPRECATED - Use Team:obs-presentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants