Skip to content

[Explore] Add AI summary component in explore plugin #9975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

FriedhelmWS
Copy link
Contributor

@FriedhelmWS FriedhelmWS commented Jun 25, 2025

Description

Screenshot 2025-06-25 at 15 05 45

Issues Resolved

Screenshot

Testing the changes

Changelog

  • skip

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link

codecov bot commented Jun 25, 2025

Codecov Report

Attention: Patch coverage is 3.27869% with 118 lines in your changes missing coverage. Please review.

Please upload report for BASE (query_explore@ac67424). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...mponents/results_summary/results_summary_panel.tsx 2.83% 103 Missing ⚠️
...lic/components/results_summary/results_summary.tsx 6.25% 15 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##             query_explore    #9975   +/-   ##
================================================
  Coverage                 ?   60.08%           
================================================
  Files                    ?     4065           
  Lines                    ?   103587           
  Branches                 ?    16456           
================================================
  Hits                     ?    62244           
  Misses                   ?    37212           
  Partials                 ?     4131           
Flag Coverage Δ
Linux_1 28.00% <ø> (?)
Linux_2 41.63% <ø> (?)
Linux_3 39.31% <ø> (?)
Windows_1 28.01% <ø> (?)
Windows_2 41.61% <ø> (?)
Windows_3 39.32% <ø> (?)
Windows_4 29.42% <3.27%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@kavilla kavilla left a comment

Choose a reason for hiding this comment

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

modifying global styles

* SPDX-License-Identifier: Apache-2.0
*/

/* stylelint-disable @osd/stylelint/no_modifying_global_selectors */
Copy link
Member

Choose a reason for hiding this comment

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

please avoid doing this if possible. this is so we don't accidentally modify styles globally

if any plugin uses the class resultSummary then we would be modifying them which might be likely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, I personally think this would be intentional as we want to custom the accordion component (i.e. add buttons to the header). Could you please suggest a better approach without modifying the global style if possible? Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

hey. thanks for the quick response.

for some context the stylelinter was added to prevent visual regression bugs. and resultsSummary seems like it has a high likelihood to change the styling of a component unrelated to this component without the plugin owners knowledge.

we could potentially make this component class name more specific but my rule of thumb has been if its failing the stylelinter then we should revisit the actual ux design.

oui component supports the button in the header if im not mistaken but do you mean the styling? looking at the oui props https://oui.opensearch.org/1.19/#/layout/accordion there should be ability to pass in classNames to the component to style without using global selectors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’ve updated some of the CSS class names to be more distinctive and to use custom className passing. There are still a few global styles that we can’t work around, but I hope these changes help reduce the risk of future style collisions.


const ACCORDION_STATE_LOCAL_STORAGE_KEY = 'resultsSummary.summaryAccordionState';

export const convertResult = (body: IDataFrame) => {
Copy link
Member

Choose a reason for hiding this comment

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

how come we don't use the proper search functionality?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not the search but convert the result data frame to proper JSON object, I think this is only relevant to t2ppl API.

Copy link
Member

Choose a reason for hiding this comment

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

for more context, PPL search essentially does the same. and it's structured like search via
hits.

so to me it looks like we generally treat this feature as search where we could just leverage existing code rather no copy and pasting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For discover, we retrieve the raw data from an subscribed observable, we actually not doing a search again as all results are relevant, no result will be filter out in this function and it is just simply a utils function to convert result from one format to another.

import React from 'react';
import { i18n } from '@osd/i18n';

export enum FeedbackStatus {
Copy link
Member

Choose a reason for hiding this comment

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

ive seen this defined multiple times in this project we shouldn't redefine it if i t can be available at a different place

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could we leave this to a later PR for refactoring? Since this one is only add the component to the page, there would be another PR for fully integrate with t2ppl feature by @ruchidh, add unit test, remove mocks, clean up the code, etc.


const renderExploreFlavor = (flavor: ExploreFlavor, props: ExploreComponentProps) => {
switch (flavor) {
case ExploreFlavor.Logs:
return <LogsPage setHeaderActionMenu={props.setHeaderActionMenu} />;
return (
<LogsPage setHeaderActionMenu={props.setHeaderActionMenu} dataSetup={props.dataSetup} />
Copy link
Member

Choose a reason for hiding this comment

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

eventually if any access to services and plugins. it would make more sense to use the OpenSearch Dashboards react context

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it be appropriate to put a setup dependency in the context of explore service?

Copy link
Member

Choose a reason for hiding this comment

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

@FriedhelmWS I think you can use data from the context which is DataPublicPluginStart

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, sorry for didn't noticed that QueryStart and SearchStart are also valid to be used.

loading: boolean;
onGenerateSummary: () => void;
brandingLabel?: string;
sampleSize: number;
Copy link
Member

Choose a reason for hiding this comment

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

are we not respecting the advanced settings sample size

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the sample size for AI agent so I think it should not be the same sample size we defined in advanced settings. In the future, we can add another setting option for AI-related sample size.

Copy link
Member

Choose a reason for hiding this comment

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

apologies. do you mind explaining more. i assumed the results summary should be the summary on the results provided to the user. the summary utilizes the query from the user right? if so then that should be the sample size from advanced settings

if not regardless of the returned results we are just generating a summary of a static number? if the user gets 10 results, wouldn't it be confusing to display a summary on 100 results because we statically defined it for 100 results.

@FriedhelmWS FriedhelmWS force-pushed the owen-explore branch 2 times, most recently from 398af81 to ba667e9 Compare June 25, 2025 08:57
&.resultsSummary_accordion {
.euiAccordion__triggerWrapper {
/* stylelint-disable @osd/stylelint/no_restricted_values */
background: lightOrDarkTheme(linear-gradient(to left, #edf7ff, #f9f4ff), $euiColorEmptyShade);
Copy link
Member

Choose a reason for hiding this comment

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

iif this is absolutely required and there is no SASS variable already then we should define them. as this shouldn't be the only place this is used

@FriedhelmWS FriedhelmWS force-pushed the owen-explore branch 5 times, most recently from b6f604b to 6ba3d6a Compare June 26, 2025 05:02
ruanyl
ruanyl previously approved these changes Jun 26, 2025
Signed-off-by: Owen Wang <owenwyk@amazon.com>
Signed-off-by: Owen Wang <owenwyk@amazon.com>
Signed-off-by: Owen Wang <owenwyk@amazon.com>
Signed-off-by: Owen Wang <owenwyk@amazon.com>
Signed-off-by: Owen Wang <owenwyk@amazon.com>
@FriedhelmWS FriedhelmWS requested a review from kavilla June 27, 2025 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
seasoned-contributor Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants