Skip to content
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

feat: update discover summary UX #8700

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ruanyl
Copy link
Member

@ruanyl ruanyl commented Oct 24, 2024

Description

Trigger summary generation on initial query, add manual trigger for subsequent queries.

This PR updates the summary generation logic to improve user experience. Previously, summaries were auto-triggered on every ppl query. Now, summaries will only be auto-generated on the first query execution. For any subsequent queries, users will need to click the "Generate Summary" button to trigger the summary generation manually.

Screen.Recording.2024-10-24.at.18.42.46.mov

Issues Resolved

Screenshot

Testing the changes

Changelog

  • feat: trigger discover summary generation on initial query add manual trigger for subsequent queries

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
Contributor

❌ Empty Changelog Section

The Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section.

Copy link
Contributor

❌ Empty Changelog Section

The Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section.

opensearch-changeset-bot bot added a commit to ruanyl/OpenSearch-Dashboards that referenced this pull request Oct 24, 2024
Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 85.24590% with 9 lines in your changes missing coverage. Please review.

Project coverage is 60.75%. Comparing base (53e8404) to head (63f292f).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...c/query_assist/components/query_assist_summary.tsx 86.00% 1 Missing and 6 partials ⚠️
...nts/public/query_assist/utils/create_extension.tsx 77.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8700      +/-   ##
==========================================
+ Coverage   60.71%   60.75%   +0.03%     
==========================================
  Files        3798     3798              
  Lines       90662    90668       +6     
  Branches    14260    14263       +3     
==========================================
+ Hits        55047    55081      +34     
+ Misses      32163    32093      -70     
- Partials     3452     3494      +42     
Flag Coverage Δ
Linux_1 29.06% <ø> (+<0.01%) ⬆️
Linux_2 56.39% <ø> (?)
Linux_3 37.58% <ø> (+<0.01%) ⬆️
Linux_4 29.84% <85.24%> (+0.01%) ⬆️
Windows_1 29.08% <ø> (+<0.01%) ⬆️
Windows_2 56.34% <ø> (ø)
Windows_3 37.58% <ø> (+<0.01%) ⬆️
Windows_4 29.84% <85.24%> (+0.01%) ⬆️

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.

const manualTriggerVisible =
!shouldAutoTrigger &&
canGenerateSummary &&
lastUsedQueryStateRef.current?.answer !== queryState.answer;
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we compare result as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe unnecessary and too much to have a deep equality check on the results? The "Generate summary" button will be available to for a manual trigger if needed when results updated.

Copy link
Contributor

@chishui chishui left a comment

Choose a reason for hiding this comment

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

Thanks for making this change, there are some minor UX changes which might not
be covered:

  1. The title "Response" needs update?
  2. Summary panel should be under PPL edit panel?
  3. "Generate Summary" with a sparkling icon next to it?
  4. From UX mock in the video, it looks like, even the summary is generated, the "Generate summary" is also clickable?

@@ -88,6 +87,7 @@ export const QueryAssistBar: React.FC<QueryAssistInputProps> = (props) => {
language: params.language,
dataset: selectedDataset,
});
updateQueryState({ question: previousQuestionRef.current, answer: response.query });
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a much better implementation. 👍

question: string;
question$: BehaviorSubject<string>;
updateQuestion: (question: string) => void;
answer: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

answer is quite vague, can we use generatedQuery or xxxQuery to make it more specific?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I will update

queryState.answer && queryState.answer !== props.data.query.queryString.getQuery().query;
// It can generate summary when
// 1. it has the current generated query(answer)
// 2. the generated query didn't been changed by user
Copy link
Contributor

Choose a reason for hiding this comment

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

query didn't been changed by user

The definition of it means user doesn't click "run" button after changing query, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, let me update the comment so it's more precise.

// 1. it has the current generated query(answer)
// 2. the generated query didn't been changed by user
// 3. there are search results
const canGenerateSummary = Boolean(results.length) && Boolean(queryState.answer) && !queryChanged;
Copy link
Contributor

Choose a reason for hiding this comment

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

There could be a case that when question changes and answer remains the same, but we can't generate summary, is that expected?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it can generated summary in such case. canGenerateSummary should be true

canGenerateSummary &&
lastUsedQueryStateRef.current?.answer !== queryState.answer;
// The visibility of panel action buttons: thumbs up/down and copy to clipboard buttons
const actionButtonVisible = summary && !loading && !queryChanged && !manualTriggerVisible;
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we also check if text to ppl is loading?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds reasonable to me, but seems no good way to read the PPL loading state, I think I'll keep it simple for now

const getPanelMessage = useCallback(() => {
if (loading) {
return (
<EuiText size="s" data-test-subj="queryAssist_summary_loading">
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: (refactor suggestion):(non-blocking)
Looks like some duplicate code could be saved:

if (xxx) {
  return (
     <EuiText xxxx>
)
}

What about

const renderConditionalText = (shouldRender, dataTestSubj, i18nKey, default) {
  if (!shouldRender) return null;
  return (
 <EuiText size="s" data-test-subj={dataTestSubj}>....
  )
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if I fully understood, but to my understanding, renderConditionalText is pretty much doing what EuiText does, I don't see much value to move the conditional logic into the function.

},
[props.usageCollection, METRIC_APP]
);
const queryChanged =
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this be recalculated whenever there's state change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the change of queryState will make the component rerender.

@ruanyl
Copy link
Member Author

ruanyl commented Oct 29, 2024

Thanks for making this change, there are some minor UX changes which might not be covered:

  1. The title "Response" needs update?
  2. Summary panel should be under PPL edit panel?
  3. "Generate Summary" with a sparkling icon next to it?
  4. From UX mock in the video, it looks like, even the summary is generated, the "Generate summary" is also clickable?

Thank you very much for the detailed review

  1. Will update
  2. Will be in another PR
  3. Will update I will wait for this icon added to OUI
  4. Yes, I think that will allow user to click and regenerate

ruanyl and others added 5 commits October 29, 2024 12:31
It will only auto-trigger the summary generating the first time a ppl
query was generated. The following summary generation requires user to
click a "Generate summary" button.

Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Yulong Ruan <[email protected]>
+ change variable `answer` -> `generatedQuery` to be more specific

Signed-off-by: Yulong Ruan <[email protected]>
@ruanyl ruanyl force-pushed the discover-results-summary-ui-tweaks branch from eae71a9 to 63f292f Compare October 29, 2024 06:01
@ruanyl ruanyl added the v2.19.0 label Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants