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 3 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 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

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]>
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.

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.84%. Comparing base (12d072d) to head (eae71a9).
Report is 7 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.86%   60.84%   -0.02%     
==========================================
  Files        3793     3793              
  Lines       90442    90492      +50     
  Branches    14198    14216      +18     
==========================================
+ Hits        55045    55062      +17     
- Misses      31910    31940      +30     
- Partials     3487     3490       +3     
Flag Coverage Δ
Linux_1 29.07% <ø> (-0.02%) ⬇️
Linux_2 56.39% <ø> (+0.01%) ⬆️
Linux_3 37.66% <ø> (-0.02%) ⬇️
Linux_4 29.85% <85.24%> (+<0.01%) ⬆️
Windows_1 29.08% <ø> (-0.02%) ⬇️
Windows_2 56.35% <ø> (+0.01%) ⬆️
Windows_3 37.67% <ø> (-0.02%) ⬇️
Windows_4 29.85% <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.

Signed-off-by: Yulong Ruan <[email protected]>
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?

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?

// 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?

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?

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}>....
  )
}

)}
</EuiFlexItem>
)}
<EuiSpacer size="m" style={{ borderLeft: '1px solid #D3DAE6', height: '20px' }} />
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: style in css file? Does it work with dark mode as well?

</EuiFlexItem>
</>
)}
<EuiSpacer size="m" style={{ borderLeft: '1px solid #D3DAE6', height: '20px' }} />
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make it a css class to avoid duplication and ensure they are consistent?

},
[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?

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