[Discover] Prevent document-level doc viewer tabs from re-mounting when refreshing#248203
Conversation
…logs profile to stabilize component identity
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
davismcphee
left a comment
There was a problem hiding this comment.
Thanks for taking this over! The latest changes LGTM, but I can't approve since I originally opened it. @akowalska622 Could we get your review on this one please?
src/platform/packages/shared/kbn-unified-doc-viewer/src/services/types.ts
Outdated
Show resolved
Hide resolved
…es/types.ts Co-authored-by: Davis McPhee <davis.mcphee@elastic.co>
| indexes: ObservabilityIndexes; | ||
| } | ||
|
|
||
| const LogOverviewTab = ({ |
There was a problem hiding this comment.
Thank you for cleaning this into a proper component
tonyghiani
left a comment
There was a problem hiding this comment.
Code review only, the DocViewer change LGTM 👌
💔 Build Failed
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
Public APIs missing exports
Page load bundle
History
|
|
CI failures seem to be unrelated, retrying... |
|
Starting backport for target branches: 9.2, 9.3 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
…en refreshing (elastic#248203) ## 📝 Summary This PR fixes an issue where document-level doc viewer tabs were unnecessarily re-mounting on every refresh, causing poor performance and degraded user experience. closes elastic#248047 ## 🔎 Background The doc viewer registry was using inline components that lacked stable component identities, causing React to treat them as new components on each render cycle. This in turn caused a complete loss of component state (like the AI insights as reported in elastic#248047) in the React hierarchy, which can interrupt the user's workflow. After this change doc viewer registry to use render functions instead of components. This ensures component identity remains stable across renders, preventing unnecessary re-mounts. This is aligned with the implementation of the Discover chart section extension point from elastic#245035. ## 🎨 Previews **Before** https://github.com/user-attachments/assets/27efbc9a-810b-4c26-81ff-7947a92cfb76 **After** https://github.com/user-attachments/assets/d0a164c2-7334-4e3b-bf74-003f05c129ed ## 🔧 Detailed Changes - Modified doc viewer registry API to accept `render` functions instead of `component` props - Updated all doc viewer tab implementations to provide render functions ## 🔢 Testing Hints - Open the Discover fly-out for a document matching a specialized data source and document profile such as logs, traces or security events. - Modify the fly-out state by expanding an accordion section and starting an AI insight request. - Click refresh in the Discover query bar or enable auto-refresh. - Verify document viewer tabs no longer flicker and retain their state when the refresh finishes. - Verify that the hit index in the fly-out header is updated correctly. - Test with multiple data views and document types ## Release Notes Prevent loss of UI state in signal-specific Discover fly-out tabs when refreshing a query --------- Co-authored-by: Felix Stürmer <felix.stuermer@elastic.co> Co-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 244764a) # Conflicts: # src/platform/packages/shared/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer.test.tsx
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…en refreshing (elastic#248203) ## 📝 Summary This PR fixes an issue where document-level doc viewer tabs were unnecessarily re-mounting on every refresh, causing poor performance and degraded user experience. closes elastic#248047 ## 🔎 Background The doc viewer registry was using inline components that lacked stable component identities, causing React to treat them as new components on each render cycle. This in turn caused a complete loss of component state (like the AI insights as reported in elastic#248047) in the React hierarchy, which can interrupt the user's workflow. After this change doc viewer registry to use render functions instead of components. This ensures component identity remains stable across renders, preventing unnecessary re-mounts. This is aligned with the implementation of the Discover chart section extension point from elastic#245035. ## 🎨 Previews **Before** https://github.com/user-attachments/assets/27efbc9a-810b-4c26-81ff-7947a92cfb76 **After** https://github.com/user-attachments/assets/d0a164c2-7334-4e3b-bf74-003f05c129ed ## 🔧 Detailed Changes - Modified doc viewer registry API to accept `render` functions instead of `component` props - Updated all doc viewer tab implementations to provide render functions ## 🔢 Testing Hints - Open the Discover fly-out for a document matching a specialized data source and document profile such as logs, traces or security events. - Modify the fly-out state by expanding an accordion section and starting an AI insight request. - Click refresh in the Discover query bar or enable auto-refresh. - Verify document viewer tabs no longer flicker and retain their state when the refresh finishes. - Verify that the hit index in the fly-out header is updated correctly. - Test with multiple data views and document types ## Release Notes Prevent loss of UI state in signal-specific Discover fly-out tabs when refreshing a query --------- Co-authored-by: Felix Stürmer <felix.stuermer@elastic.co> Co-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 244764a) # Conflicts: # src/platform/packages/shared/kbn-discover-utils/src/data_types/metrics/custom_doc_view.tsx # src/platform/packages/shared/kbn-unified-doc-viewer/src/components/doc_viewer/doc_viewer.test.tsx # src/platform/plugins/shared/discover/public/context_awareness/profile_providers/example/example_data_source_profile/profile.tsx # src/platform/plugins/shared/discover/public/context_awareness/profile_providers/observability/log_document_profile/accessors/get_doc_viewer.tsx
…ing when refreshing (#248203) (#249289) # Backport This will backport the following commits from `main` to `9.3`: - [[Discover] Prevent document-level doc viewer tabs from re-mounting when refreshing (#248203)](#248203) <!--- Backport version: 10.2.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Davis McPhee","email":"davis.mcphee@elastic.co"},"sourceCommit":{"committedDate":"2026-01-15T17:16:35Z","message":"[Discover] Prevent document-level doc viewer tabs from re-mounting when refreshing (#248203)\n\n## 📝 Summary\n\nThis PR fixes an issue where document-level doc viewer tabs were\nunnecessarily re-mounting on every refresh, causing poor performance and\ndegraded user experience.\n\ncloses #248047\n\n## 🔎 Background\n\nThe doc viewer registry was using inline components that lacked stable\ncomponent identities, causing React to treat them as new components on\neach render cycle. This in turn caused a complete loss of component\nstate (like the AI insights as reported in #248047) in the React\nhierarchy, which can interrupt the user's workflow.\n\nAfter this change doc viewer registry to use render functions instead of\ncomponents. This ensures component identity remains stable across\nrenders, preventing unnecessary re-mounts. This is aligned with the\nimplementation of the Discover chart section extension point from\nhttps://github.com//pull/245035.\n\n## 🎨 Previews\n\n**Before**\n\n\nhttps://github.com/user-attachments/assets/27efbc9a-810b-4c26-81ff-7947a92cfb76\n\n**After**\n\n\nhttps://github.com/user-attachments/assets/d0a164c2-7334-4e3b-bf74-003f05c129ed\n\n## 🔧 Detailed Changes\n\n- Modified doc viewer registry API to accept `render` functions instead\nof `component` props\n- Updated all doc viewer tab implementations to provide render functions\n\n## 🔢 Testing Hints\n\n- Open the Discover fly-out for a document matching a specialized data\nsource and document profile such as logs, traces or security events.\n- Modify the fly-out state by expanding an accordion section and\nstarting an AI insight request.\n- Click refresh in the Discover query bar or enable auto-refresh.\n- Verify document viewer tabs no longer flicker and retain their state\nwhen the refresh finishes.\n- Verify that the hit index in the fly-out header is updated correctly.\n- Test with multiple data views and document types\n\n## Release Notes\n\nPrevent loss of UI state in signal-specific Discover fly-out tabs when\nrefreshing a query\n\n---------\n\nCo-authored-by: Felix Stürmer <felix.stuermer@elastic.co>\nCo-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"244764a170a2aa1bb53409262f88abdb623546da","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:DataDiscovery","backport:version","v9.3.0","Team:obs-exploration","v9.4.0","v9.2.5"],"title":"[Discover] Prevent document-level doc viewer tabs from re-mounting when refreshing","number":248203,"url":"https://github.com/elastic/kibana/pull/248203","mergeCommit":{"message":"[Discover] Prevent document-level doc viewer tabs from re-mounting when refreshing (#248203)\n\n## 📝 Summary\n\nThis PR fixes an issue where document-level doc viewer tabs were\nunnecessarily re-mounting on every refresh, causing poor performance and\ndegraded user experience.\n\ncloses #248047\n\n## 🔎 Background\n\nThe doc viewer registry was using inline components that lacked stable\ncomponent identities, causing React to treat them as new components on\neach render cycle. This in turn caused a complete loss of component\nstate (like the AI insights as reported in #248047) in the React\nhierarchy, which can interrupt the user's workflow.\n\nAfter this change doc viewer registry to use render functions instead of\ncomponents. This ensures component identity remains stable across\nrenders, preventing unnecessary re-mounts. This is aligned with the\nimplementation of the Discover chart section extension point from\nhttps://github.com//pull/245035.\n\n## 🎨 Previews\n\n**Before**\n\n\nhttps://github.com/user-attachments/assets/27efbc9a-810b-4c26-81ff-7947a92cfb76\n\n**After**\n\n\nhttps://github.com/user-attachments/assets/d0a164c2-7334-4e3b-bf74-003f05c129ed\n\n## 🔧 Detailed Changes\n\n- Modified doc viewer registry API to accept `render` functions instead\nof `component` props\n- Updated all doc viewer tab implementations to provide render functions\n\n## 🔢 Testing Hints\n\n- Open the Discover fly-out for a document matching a specialized data\nsource and document profile such as logs, traces or security events.\n- Modify the fly-out state by expanding an accordion section and\nstarting an AI insight request.\n- Click refresh in the Discover query bar or enable auto-refresh.\n- Verify document viewer tabs no longer flicker and retain their state\nwhen the refresh finishes.\n- Verify that the hit index in the fly-out header is updated correctly.\n- Test with multiple data views and document types\n\n## Release Notes\n\nPrevent loss of UI state in signal-specific Discover fly-out tabs when\nrefreshing a query\n\n---------\n\nCo-authored-by: Felix Stürmer <felix.stuermer@elastic.co>\nCo-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"244764a170a2aa1bb53409262f88abdb623546da"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","9.2"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/248203","number":248203,"mergeCommit":{"message":"[Discover] Prevent document-level doc viewer tabs from re-mounting when refreshing (#248203)\n\n## 📝 Summary\n\nThis PR fixes an issue where document-level doc viewer tabs were\nunnecessarily re-mounting on every refresh, causing poor performance and\ndegraded user experience.\n\ncloses #248047\n\n## 🔎 Background\n\nThe doc viewer registry was using inline components that lacked stable\ncomponent identities, causing React to treat them as new components on\neach render cycle. This in turn caused a complete loss of component\nstate (like the AI insights as reported in #248047) in the React\nhierarchy, which can interrupt the user's workflow.\n\nAfter this change doc viewer registry to use render functions instead of\ncomponents. This ensures component identity remains stable across\nrenders, preventing unnecessary re-mounts. This is aligned with the\nimplementation of the Discover chart section extension point from\nhttps://github.com//pull/245035.\n\n## 🎨 Previews\n\n**Before**\n\n\nhttps://github.com/user-attachments/assets/27efbc9a-810b-4c26-81ff-7947a92cfb76\n\n**After**\n\n\nhttps://github.com/user-attachments/assets/d0a164c2-7334-4e3b-bf74-003f05c129ed\n\n## 🔧 Detailed Changes\n\n- Modified doc viewer registry API to accept `render` functions instead\nof `component` props\n- Updated all doc viewer tab implementations to provide render functions\n\n## 🔢 Testing Hints\n\n- Open the Discover fly-out for a document matching a specialized data\nsource and document profile such as logs, traces or security events.\n- Modify the fly-out state by expanding an accordion section and\nstarting an AI insight request.\n- Click refresh in the Discover query bar or enable auto-refresh.\n- Verify document viewer tabs no longer flicker and retain their state\nwhen the refresh finishes.\n- Verify that the hit index in the fly-out header is updated correctly.\n- Test with multiple data views and document types\n\n## Release Notes\n\nPrevent loss of UI state in signal-specific Discover fly-out tabs when\nrefreshing a query\n\n---------\n\nCo-authored-by: Felix Stürmer <felix.stuermer@elastic.co>\nCo-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"244764a170a2aa1bb53409262f88abdb623546da"}},{"branch":"9.2","label":"v9.2.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Davis McPhee <davis.mcphee@elastic.co>
…ing when refreshing (#248203) (#249353) # Backport This will backport the following commits from `main` to `9.2`: - [[Discover] Prevent document-level doc viewer tabs from re-mounting when refreshing (#248203)](#248203) <!--- Backport version: 10.2.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Davis McPhee","email":"davis.mcphee@elastic.co"},"sourceCommit":{"committedDate":"2026-01-15T17:16:35Z","message":"[Discover] Prevent document-level doc viewer tabs from re-mounting when refreshing (#248203)\n\n## 📝 Summary\n\nThis PR fixes an issue where document-level doc viewer tabs were\nunnecessarily re-mounting on every refresh, causing poor performance and\ndegraded user experience.\n\ncloses #248047\n\n## 🔎 Background\n\nThe doc viewer registry was using inline components that lacked stable\ncomponent identities, causing React to treat them as new components on\neach render cycle. This in turn caused a complete loss of component\nstate (like the AI insights as reported in #248047) in the React\nhierarchy, which can interrupt the user's workflow.\n\nAfter this change doc viewer registry to use render functions instead of\ncomponents. This ensures component identity remains stable across\nrenders, preventing unnecessary re-mounts. This is aligned with the\nimplementation of the Discover chart section extension point from\nhttps://github.com//pull/245035.\n\n## 🎨 Previews\n\n**Before**\n\n\nhttps://github.com/user-attachments/assets/27efbc9a-810b-4c26-81ff-7947a92cfb76\n\n**After**\n\n\nhttps://github.com/user-attachments/assets/d0a164c2-7334-4e3b-bf74-003f05c129ed\n\n## 🔧 Detailed Changes\n\n- Modified doc viewer registry API to accept `render` functions instead\nof `component` props\n- Updated all doc viewer tab implementations to provide render functions\n\n## 🔢 Testing Hints\n\n- Open the Discover fly-out for a document matching a specialized data\nsource and document profile such as logs, traces or security events.\n- Modify the fly-out state by expanding an accordion section and\nstarting an AI insight request.\n- Click refresh in the Discover query bar or enable auto-refresh.\n- Verify document viewer tabs no longer flicker and retain their state\nwhen the refresh finishes.\n- Verify that the hit index in the fly-out header is updated correctly.\n- Test with multiple data views and document types\n\n## Release Notes\n\nPrevent loss of UI state in signal-specific Discover fly-out tabs when\nrefreshing a query\n\n---------\n\nCo-authored-by: Felix Stürmer <felix.stuermer@elastic.co>\nCo-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"244764a170a2aa1bb53409262f88abdb623546da","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:DataDiscovery","backport:version","v9.3.0","Team:obs-exploration","v9.4.0","v9.2.5"],"title":"[Discover] Prevent document-level doc viewer tabs from re-mounting when refreshing","number":248203,"url":"https://github.com/elastic/kibana/pull/248203","mergeCommit":{"message":"[Discover] Prevent document-level doc viewer tabs from re-mounting when refreshing (#248203)\n\n## 📝 Summary\n\nThis PR fixes an issue where document-level doc viewer tabs were\nunnecessarily re-mounting on every refresh, causing poor performance and\ndegraded user experience.\n\ncloses #248047\n\n## 🔎 Background\n\nThe doc viewer registry was using inline components that lacked stable\ncomponent identities, causing React to treat them as new components on\neach render cycle. This in turn caused a complete loss of component\nstate (like the AI insights as reported in #248047) in the React\nhierarchy, which can interrupt the user's workflow.\n\nAfter this change doc viewer registry to use render functions instead of\ncomponents. This ensures component identity remains stable across\nrenders, preventing unnecessary re-mounts. This is aligned with the\nimplementation of the Discover chart section extension point from\nhttps://github.com//pull/245035.\n\n## 🎨 Previews\n\n**Before**\n\n\nhttps://github.com/user-attachments/assets/27efbc9a-810b-4c26-81ff-7947a92cfb76\n\n**After**\n\n\nhttps://github.com/user-attachments/assets/d0a164c2-7334-4e3b-bf74-003f05c129ed\n\n## 🔧 Detailed Changes\n\n- Modified doc viewer registry API to accept `render` functions instead\nof `component` props\n- Updated all doc viewer tab implementations to provide render functions\n\n## 🔢 Testing Hints\n\n- Open the Discover fly-out for a document matching a specialized data\nsource and document profile such as logs, traces or security events.\n- Modify the fly-out state by expanding an accordion section and\nstarting an AI insight request.\n- Click refresh in the Discover query bar or enable auto-refresh.\n- Verify document viewer tabs no longer flicker and retain their state\nwhen the refresh finishes.\n- Verify that the hit index in the fly-out header is updated correctly.\n- Test with multiple data views and document types\n\n## Release Notes\n\nPrevent loss of UI state in signal-specific Discover fly-out tabs when\nrefreshing a query\n\n---------\n\nCo-authored-by: Felix Stürmer <felix.stuermer@elastic.co>\nCo-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"244764a170a2aa1bb53409262f88abdb623546da"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","9.2"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/248203","number":248203,"mergeCommit":{"message":"[Discover] Prevent document-level doc viewer tabs from re-mounting when refreshing (#248203)\n\n## 📝 Summary\n\nThis PR fixes an issue where document-level doc viewer tabs were\nunnecessarily re-mounting on every refresh, causing poor performance and\ndegraded user experience.\n\ncloses #248047\n\n## 🔎 Background\n\nThe doc viewer registry was using inline components that lacked stable\ncomponent identities, causing React to treat them as new components on\neach render cycle. This in turn caused a complete loss of component\nstate (like the AI insights as reported in #248047) in the React\nhierarchy, which can interrupt the user's workflow.\n\nAfter this change doc viewer registry to use render functions instead of\ncomponents. This ensures component identity remains stable across\nrenders, preventing unnecessary re-mounts. This is aligned with the\nimplementation of the Discover chart section extension point from\nhttps://github.com//pull/245035.\n\n## 🎨 Previews\n\n**Before**\n\n\nhttps://github.com/user-attachments/assets/27efbc9a-810b-4c26-81ff-7947a92cfb76\n\n**After**\n\n\nhttps://github.com/user-attachments/assets/d0a164c2-7334-4e3b-bf74-003f05c129ed\n\n## 🔧 Detailed Changes\n\n- Modified doc viewer registry API to accept `render` functions instead\nof `component` props\n- Updated all doc viewer tab implementations to provide render functions\n\n## 🔢 Testing Hints\n\n- Open the Discover fly-out for a document matching a specialized data\nsource and document profile such as logs, traces or security events.\n- Modify the fly-out state by expanding an accordion section and\nstarting an AI insight request.\n- Click refresh in the Discover query bar or enable auto-refresh.\n- Verify document viewer tabs no longer flicker and retain their state\nwhen the refresh finishes.\n- Verify that the hit index in the fly-out header is updated correctly.\n- Test with multiple data views and document types\n\n## Release Notes\n\nPrevent loss of UI state in signal-specific Discover fly-out tabs when\nrefreshing a query\n\n---------\n\nCo-authored-by: Felix Stürmer <felix.stuermer@elastic.co>\nCo-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"244764a170a2aa1bb53409262f88abdb623546da"}},{"branch":"9.2","label":"v9.2.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: Davis McPhee <davis.mcphee@elastic.co>
📝 Summary
This PR fixes an issue where document-level doc viewer tabs were unnecessarily re-mounting on every refresh, causing poor performance and degraded user experience.
closes #248047
🔎 Background
The doc viewer registry was using inline components that lacked stable component identities, causing React to treat them as new components on each render cycle. This in turn caused a complete loss of component state (like the AI insights as reported in #248047) in the React hierarchy, which can interrupt the user's workflow.
After this change doc viewer registry to use render functions instead of components. This ensures component identity remains stable across renders, preventing unnecessary re-mounts. This is aligned with the implementation of the Discover chart section extension point from #245035.
🎨 Previews
Before
screen-recording-discover-fly-out-remounting-broken-2026-01-09.mov
After
screen-recording-discover-fly-out-remounting-fixed-2026-01-09.mov
🔧 Detailed Changes
renderfunctions instead ofcomponentprops🔢 Testing Hints
Release Notes
Prevent loss of UI state in signal-specific Discover fly-out tabs when refreshing a query