Skip to content

[Security solution] Template wrapper fixes, route changes.#212808

Draft
kqualters-elastic wants to merge 20 commits intoelastic:mainfrom
kqualters-elastic:fix-wrappers-via-routes
Draft

[Security solution] Template wrapper fixes, route changes.#212808
kqualters-elastic wants to merge 20 commits intoelastic:mainfrom
kqualters-elastic:fix-wrappers-via-routes

Conversation

@kqualters-elastic
Copy link
Contributor

@kqualters-elastic kqualters-elastic commented Feb 28, 2025

Summary

This pr is an attempt at fixing several performance issues in security solution via reworking routes and page templates. In short, the idea behind showTimeline: boolean in security solution sub plugins is currently essentially pointless, as the PluginTemplateWrapper component is destroyed and re-rendered in full any time a user navigates to a new page. With timeline now being based around discover, this results in a whole lot of needlessly duplicated bootstrapping logic running on every page change. This pr changes it so that PluginTemplateWrapper is rendered only once on initially navigating to the security solution, and destroyed when leaving. We probably won't even need showTimeline anymore, but can revisit this later. Navigating from page to page should be significantly faster with this change. Originally this came about from an investigation into an SDH, where I saw a user who had a large amount of fields, try to navigate from 'sub plugin' to 'sub plugin' in security solution rapidly, and the browser would block for upwards of 10 seconds on some pages. Navigation is definitely faster, both in terms of less renders overall and in less renders that block the page for extended periods of time, and nothing should have changed from a user experience point of view. Will update this description with more specific numbers soon. Changes unrelated to the routes and page/plugin wrappers in security solution were mostly found from a combination of why-did-you-render and react devtools.

Checklist

@kqualters-elastic kqualters-elastic force-pushed the fix-wrappers-via-routes branch from 243d765 to ed80b7b Compare March 7, 2025 02:57
@kqualters-elastic kqualters-elastic changed the title [WIP][DRAFT]Security solution template wrapper fixes [Security solution] Template wrapper fixes, route changes. Apr 2, 2025
@kqualters-elastic kqualters-elastic added v9.1.0 release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels Team:Threat Hunting:Investigations Security Solution Threat Hunting Investigations Team labels Apr 2, 2025
@kqualters-elastic kqualters-elastic marked this pull request as ready for review April 2, 2025 04:40
@kqualters-elastic kqualters-elastic requested review from a team as code owners April 2, 2025 04:40
@kqualters-elastic kqualters-elastic requested review from a team as code owners April 2, 2025 04:40
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting-investigations (Team:Threat Hunting:Investigations)

<ApplicationUsageTrackingProvider>
{children ??
(subPluginRoutes && <AppRoutes subPluginRoutes={subPluginRoutes} services={services} />)}
<AppRoutes subPluginRoutes={subPluginRoutes} services={services} />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: Keep this change, render

const { ManagementSettings } = await this.lazyAssistantSettingsManagement();

in a different way

path: RULES_LANDING_PATH,
component: RulesLandingPage,
},
// {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove commented code

];

const RulesContainerComponent: React.FC = () => {
const RulesContainerComponent: React.FC = (props) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

props is unused

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this PR still maintained? I can see no actions for 2 months.

@elasticmachine
Copy link
Contributor

elasticmachine commented Apr 3, 2025

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #18 / when not on enterprise plan should render specified children
  • [job] [logs] Jest Tests #18 / when not on enterprise plan should render specified children
  • [job] [logs] FTR Configs #5 / Cases cases list "after all" hook in "cases list"
  • [job] [logs] FTR Configs #5 / Cases cases list "after all" hook in "cases list"
  • [job] [logs] FTR Configs #5 / Cases cases list filtering "after all" hook for "loads the initial state correctly"
  • [job] [logs] FTR Configs #5 / Cases cases list filtering "after all" hook for "loads the initial state correctly"
  • [job] [logs] FTR Configs #5 / Cases cases list filtering "after each" hook for "filters cases by the first cases all user assignee"
  • [job] [logs] FTR Configs #5 / Cases cases list filtering "after each" hook for "filters cases by the first cases all user assignee"
  • [job] [logs] Explore - Security Solution Cypress Tests #1 / Display not found page navigates to the alerts page with incorrect link navigates to the alerts page with incorrect link
  • [job] [logs] Serverless Explore - Security Solution Cypress Tests #2 / Display not found page navigates to the alerts page with incorrect link navigates to the alerts page with incorrect link
  • [job] [logs] Jest Tests #17 / home change home route should render a link to change the default route in advanced settings if advanced settings is enabled
  • [job] [logs] Jest Tests #17 / home change home route should render a link to change the default route in advanced settings if advanced settings is enabled
  • [job] [logs] Jest Tests #17 / home directories should not render directory entry when showOnHomePage is false
  • [job] [logs] Jest Tests #17 / home directories should not render directory entry when showOnHomePage is false
  • [job] [logs] Jest Tests #17 / home directories should render ADMIN directory entry in "Manage your data" panel
  • [job] [logs] Jest Tests #17 / home directories should render ADMIN directory entry in "Manage your data" panel
  • [job] [logs] Jest Tests #17 / home directories should render solutions in the "solution section"
  • [job] [logs] Jest Tests #17 / home directories should render solutions in the "solution section"
  • [job] [logs] Jest Tests #17 / home isNewKibanaInstance should safely handle exceptions
  • [job] [logs] Jest Tests #17 / home isNewKibanaInstance should safely handle exceptions
  • [job] [logs] Jest Tests #17 / home isNewKibanaInstance should set isNewKibanaInstance to false when there are index patterns
  • [job] [logs] Jest Tests #17 / home isNewKibanaInstance should set isNewKibanaInstance to false when there are index patterns
  • [job] [logs] Jest Tests #17 / home should render home component
  • [job] [logs] Jest Tests #17 / home should render home component
  • [job] [logs] FTR Configs #41 / integrations Endpoint Exceptions should add event.module=endpoint to entry if only wildcard operator is present
  • [job] [logs] FTR Configs #64 / integrations Endpoint Exceptions should add event.module=endpoint to entry if only wildcard operator is present
  • [job] [logs] FTR Configs #64 / integrations Endpoint Exceptions should add event.module=endpoint to entry if only wildcard operator is present
  • [job] [logs] FTR Configs #41 / integrations Endpoint Exceptions should add event.module=endpoint to entry if only wildcard operator is present
  • [job] [logs] Jest Tests #18 / IntegrationsGuard should render empty page when no indicators are found and no ti integrations are installed
  • [job] [logs] Jest Tests #18 / IntegrationsGuard should render empty page when no indicators are found and no ti integrations are installed
  • [job] [logs] Jest Tests #18 / IntegrationsGuard should render loading when indicator count and integrations are being loaded
  • [job] [logs] Jest Tests #18 / IntegrationsGuard should render loading when indicator count and integrations are being loaded
  • [job] [logs] Jest Tests #18 / IntegrationsGuard should render loading when indicator only is loading
  • [job] [logs] Jest Tests #18 / IntegrationsGuard should render loading when indicator only is loading
  • [job] [logs] Jest Tests #18 / IntegrationsGuard should render loading when integrations only are loading
  • [job] [logs] Jest Tests #18 / IntegrationsGuard should render loading when integrations only are loading
  • [job] [logs] Jest Tests #17 / it renders with custom logo
  • [job] [logs] Jest Tests #17 / it renders with custom logo
  • [job] [logs] Jest Tests #17 / it renders without crashing
  • [job] [logs] Jest Tests #17 / it renders without crashing
  • [job] [logs] FTR Configs #98 / machine learning - data visualizer data drift with ft_farequote_filter_and_kuery from index selection page KQL saved search and filters loads the source data in data drift
  • [job] [logs] FTR Configs #98 / machine learning - data visualizer data drift with ft_farequote_filter_and_kuery from index selection page KQL saved search and filters loads the source data in data drift
  • [job] [logs] Jest Tests #13 / ResizableLayout should render without any issues
  • [job] [logs] Jest Tests #13 / ResizableLayout should render without any issues
  • [job] [logs] Jest Tests #2 / Security Solution Navigation while chrome style is undefined should return proper navigation props
  • [job] [logs] Jest Tests #2 / Security Solution Navigation while chrome style is undefined should return proper navigation props
  • [job] [logs] Jest Tests #16 / SecuritySolutionTemplateWrapper when navigation props are undefined (loading) should not render the children
  • [job] [logs] Jest Tests #16 / SecuritySolutionTemplateWrapper when navigation props are undefined (loading) should not render the children
  • [job] [logs] FTR Configs #19 / serverless security UI navigation "before all" hook for "has security serverless side nav"
  • [job] [logs] FTR Configs #19 / serverless security UI navigation "before all" hook for "has security serverless side nav"

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
threatIntelligence 177 176 -1

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/shared-ux-page-no-data-config 9 8 -1
@kbn/shared-ux-page-solution-nav 3 2 -1
@kbn/shared-ux-router 15 11 -4
total -6

Async chunks

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

id before after diff
automaticImport 1.1MB 1.1MB +1.1KB
canvas 1017.1KB 1018.2KB +1.1KB
dashboard 553.2KB 554.3KB +1.1KB
discover 947.1KB 952.7KB +5.7KB
enterpriseSearch 1.3MB 1.3MB +1.1KB
eventAnnotationListing 208.0KB 209.1KB +1.1KB
filesManagement 106.5KB 107.6KB +1.1KB
graph 389.7KB 390.8KB +1.1KB
home 108.2KB 109.3KB +1.1KB
indexManagement 705.5KB 706.6KB +1.1KB
infra 1.2MB 1.2MB +1.1KB
kibanaOverview 47.8KB 48.9KB +1.1KB
lens 1.4MB 1.4MB +5.7KB
management 31.6KB 32.7KB +1.1KB
maps 3.0MB 3.0MB +1.1KB
ml 5.4MB 5.4MB +1.1KB
observabilityShared 37.1KB 38.2KB +1.1KB
osquery 1.0MB 1.0MB +1.1KB
searchHomepage 33.8KB 34.9KB +1.1KB
searchIndices 180.9KB 182.0KB +1.1KB
searchInferenceEndpoints 104.6KB 105.7KB +1.1KB
searchPlayground 202.2KB 203.3KB +1.1KB
searchSynonyms 51.5KB 52.6KB +1.1KB
security 515.6KB 516.7KB +1.1KB
securitySolution 8.9MB 8.9MB +1.5KB
securitySolutionEss 36.0KB 37.1KB +1.1KB
securitySolutionServerless 101.0KB 102.1KB +1.1KB
spaces 209.2KB 210.3KB +1.1KB
threatIntelligence 754.1KB 753.9KB -138.0B
visualizations 342.4KB 343.5KB +1.1KB
workchatApp 71.6KB 72.7KB +1.1KB
total +42.6KB

Page load bundle

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

id before after diff
core 432.4KB 432.8KB +468.0B
esUiShared 88.4KB 89.5KB +1.1KB
kbnUiSharedDeps-srcJs 3.6MB 3.6MB +31.0B
securitySolution 88.8KB 88.9KB +19.0B
threatIntelligence 13.0KB 12.7KB -362.0B
total +1.3KB
Unknown metric groups

API count

id before after diff
@kbn/shared-ux-page-solution-nav 5 6 +1
@kbn/shared-ux-router 16 13 -3
total -2

History

Copy link
Contributor

@seanrathier seanrathier left a comment

Choose a reason for hiding this comment

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

Approving: x-pack/solutions/security/plugins/security_solution/public/cloud_security_posture/routes.tsx

Copy link
Contributor

@lgestc lgestc left a comment

Choose a reason for hiding this comment

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

clicked around this a bit as well, looking good:) I like the changes though threat intelligence plugin seems to fail

if you can hold this off for a while, we might be able to remove some of the code that allows reconfiguring props on the template for threat intelligence plugin

Copy link
Contributor

@lgestc lgestc left a comment

Choose a reason for hiding this comment

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

other than failing tests looks alright and seems to improve things a lot, thanks

@CAWilson94
Copy link
Contributor

clicked around this a bit as well, looking good:) I like the changes though threat intelligence plugin seems to fail

if you can hold this off for a while, we might be able to remove some of the code that allows reconfiguring props on the template for threat intelligence plugin

Hey there! Is this PR currently on hold for this?

@paul-tavares paul-tavares removed their request for review May 28, 2025 13:00
@dhurley14 dhurley14 removed their request for review June 9, 2025 20:06
@PhilippeOberti PhilippeOberti removed the request for review from a team June 23, 2025 06:53
@PhilippeOberti PhilippeOberti marked this pull request as draft August 1, 2025 12:45
@elasticmachine
Copy link
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!

@gergoabraham gergoabraham removed their request for review February 2, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Investigations Security Solution Threat Hunting Investigations Team v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants