[Discover] Add support for restorable state for doc viewer flyout tabs#249030
Conversation
davismcphee
left a comment
There was a problem hiding this comment.
Changes are looking good! Left some initial feedback.
src/platform/packages/shared/kbn-unified-doc-viewer/src/services/types.ts
Outdated
Show resolved
Hide resolved
src/platform/packages/shared/kbn-unified-doc-viewer/src/services/types.ts
Outdated
Show resolved
Hide resolved
src/platform/packages/shared/kbn-unified-doc-viewer/src/services/types.ts
Outdated
Show resolved
Hide resolved
...platform/plugins/shared/discover/public/application/main/state_management/redux/constants.ts
Outdated
Show resolved
Hide resolved
davismcphee
left a comment
There was a problem hiding this comment.
Thanks for the updates, looks great! Once we fix the conflicts from #248203 and add some tests, this looks ready to ship to me 🚀
…thub.com:akowalska622/kibana into discover-support-restorable-state-for-doc-viewer
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
davismcphee
left a comment
There was a problem hiding this comment.
Latest changes look great!
Just one final ask: could you please update an example profile to use the restorable state functionality and add FTR tests for it here?
It would also probably be helpful to add some inline documentation about how consumers can use the restorable functionality to the type definition (or add it to the Unified Doc Viewer readme and link from here):
kibana/src/platform/plugins/shared/discover/public/context_awareness/types.ts
Lines 536 to 542 in 56a2f10
...platform/packages/shared/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer_tab.tsx
Outdated
Show resolved
Hide resolved
Ah this sounds like much better solution than my dedicated branch for example 😅 On it! |
…thub.com:akowalska622/kibana into discover-support-restorable-state-for-doc-viewer
|
Thanks @davismcphee! All asks addressed. I've created a new dedicated component for a doc viewer tab with restorable state in example profile, so the original custom tab is kept leaner. When I initially added it there, I felt that too much is going on there and maybe it's worth keeping it separated, but I'm open for changes! |
| * The trace waterfall does not show in components since it's an Embeddable and we're not mocking everything out. | ||
| * The "(X% of trace)" component is never rendered because we are not fetching parent span data. |
There was a problem hiding this comment.
This gets auto adjusted on save in VSC
There was a problem hiding this comment.
VSC knew it was wrong 🙂
davismcphee
left a comment
There was a problem hiding this comment.
Excellent work on this, you're now officially our resident doc viewer expert! I'm gonna trigger a flaky test run against the new tests to be sure, but assuming that passes, this LGTM 🚀
...ofile_providers/example/example_data_source_profile/components/restorable_state_doc_view.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Wonderful documentation, thank you!
| * The trace waterfall does not show in components since it's an Embeddable and we're not mocking everything out. | ||
| * The "(X% of trace)" component is never rendered because we are not fetching parent span data. |
There was a problem hiding this comment.
VSC knew it was wrong 🙂
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#10541[✅] src/platform/test/functional/apps/discover/context_awareness/config.ts: 50/50 tests passed. |
Co-authored-by: Davis McPhee <davismcphee@hotmail.com>
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
async chunk count
History
|
elastic#249030) ## Summary Resolves: elastic#248564 This pull request introduces state persistence and restoration capabilities for the DocViewer in Discover. It enables each doc viewer tab to save and restore its own state, and wires this state handling through the Redux store and all relevant components. This improves user experience by maintaining tab-specific state across navigation and document changes. It's also prepared to save and restore any other state, apart from doc viewer tab state and gives profiles possibility to register components with restorable state. It prepares us to specifically save `Table` and `JSON` tabs as per: [[Discover] [Unified Doc Viewer] Support restorable state in the Table doc viewer tab elastic#248567](elastic#248567) [[Discover] [Unified Doc Viewer] Support restorable state in the JSON doc viewer tab elastic#248568](elastic#248568) [Here](akowalska622@a82b54f) you can find an example how to use it as a consumer. Video of an example usage: https://github.com/user-attachments/assets/2caaaaa9-cbc0-48bb-9fe0-d9723efb3b57 ### Acceptance criteria - [x] Doc viewer tab state is stored within Discover's state management, scoped per tab. - [x] Doc viewer tab state is restored when switching between Discover tabs with open flyouts. - [x] Doc viewer tab state is cleared when the flyout is closed or the expanded document changes. - [x] Discover profiles are able to register doc viewer tabs with restorable state. - [x] (Optional) Discover profiles can pass `initialTabState` to their doc viewer tabs when calling the `setExpandedDoc` extension point action ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] 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) - [x] [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) - [ ] 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. - [ ] [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) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Davis McPhee <davismcphee@hotmail.com>
Summary
Resolves: #248564
This pull request introduces state persistence and restoration capabilities for the DocViewer in Discover. It enables each doc viewer tab to save and restore its own state, and wires this state handling through the Redux store and all relevant components. This improves user experience by maintaining tab-specific state across navigation and document changes.
It's also prepared to save and restore any other state, apart from doc viewer tab state and gives profiles possibility to register components with restorable state.
It prepares us to specifically save
TableandJSONtabs as per:[Discover] [Unified Doc Viewer] Support restorable state in the Table doc viewer tab #248567
[Discover] [Unified Doc Viewer] Support restorable state in the JSON doc viewer tab #248568
Here you can find an example how to use it as a consumer.
Video of an example usage:
Screen.Recording.2026-01-16.at.13.12.12.mov
Acceptance criteria
initialTabStateto their doc viewer tabs when calling thesetExpandedDocextension point actionChecklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
release_note:breakinglabel should be applied in these situations.release_note:*label is applied per the guidelinesbackport:*labels.Identify risks
Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss.
Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging.